About using verified Particle library with Electron

I am not an IoT specialist, and I am wondering something that can be sound trivial for many of you.
I am planning to use the Electron with a library called Ubidots, which I am currently successfully testing with Photon.
I am wondering which is the data path to the cloud if I use only that library with Electron.
This point to the data consume for the Electron.
My doubt is if the data is also reaching the Particle cloud and from there it goes to Ubidots Cloud.
Thank for any inside on that.

The Ubidots library is using TCP/UDP transfer which is independent of the Particle cloud.

  TCPClient _client;
  UDP _clientUDP;
  UDP _clientTMP;
  ...
/**
 * Send all package via UDP method
 * @arg buffer the message to send
 * @return true upon success, false upon error.
 */

bool Ubidots::sendAllUDP(char* buffer) {
  int size;
  IPAddress ipAddress;

  // Obtains the remote server's IP
  HAL_IPAddress ip;
  network_interface_t t;
  ipAddress = (inet_gethostbyname(_server, strlen(_server), &ip, t, NULL)<0) ?
       IPAddress(uint32_t(0)) : IPAddress(ip);

  if (! ipAddress){
    if (_debug) {
      Serial.println("ERROR, could not solve IP Address of the remote server, please check your DNS setup");
    }
    _currentValue = 0;
    _clientUDP.stop();
    _dirty = false;
    free(buffer);
    return false;
  }


  // Routine to send data through UDP
  _clientUDP.begin(PORT);
  if (! (_clientUDP.beginPacket(ipAddress, PORT)
      && _clientUDP.write(buffer)
      && _clientUDP.endPacket())) {
    if (_debug) {
      Serial.println("ERROR sending values with UDP");
    }
    _currentValue = 0;
    _clientUDP.stop();
    _dirty = false;
    free(buffer);
    return false;
  }

  _currentValue = 0;
  _clientUDP.stop();
  _dirty = false;
  free(buffer);
  return true;
}


/**
 * Send all package via TCP method
 * @arg buffer the message to send
 * @return true upon success, false upon error.
 */

bool Ubidots::sendAllTCP(char* buffer) {
  int i = 0;
  while (!_client.connected() && i < 6) {
    i++;
    if (_debug) {
      Serial.println("not connected, trying to connect again");
    }
    _client.connect(_server, PORT);
    if (i == 5) {
      if (_debug) {
        Serial.println("Max attempts to connect reached, data could not be sent");
      }
      free(buffer);
      _dirty = false;
      return false;
    }
  }

  if (_client.connected()) {    // Connect to the server
    if (_debug) {
      Serial.println("Sending data");
    }
    _client.println(buffer);
    _client.flush();
    _client.stop();
    free(buffer);
    _dirty = false;
    _currentValue = 0;
    return true;
  }

  free(buffer);
  _dirty = false;
  _currentValue = 0;
  return false; // If any of the above conditions is reached, returns false to indicate an unexpected issue
}

In this context where Electron sim car is used !!!

If you are refering to the Particle SIM card that came with your Electron, then you need to know that the cellular service is not provided by Particle but by services Particle has service agreements with (e.g. T-Mobile, AT&T, …) but that does not mean that all cellular traffic will go via the Particle cloud.

Since the Electron uses UDP as transport layer and Ubidots has a sendAllUDP() function my statement that the Particle cloud won’t see any of your Ubidots data as long you don’t actively send it there too.

However, if your concern is the data consumption of the Ubidots library, that is counted by the cell service provider as it happens, irrelevant of destination (cloud or not).

1 Like