Greetings to everybody, I am currently working in an update to the actual Ubidots Particle library, we would like to support both Boron and Argon devices for sending data using UDP. Actually, the Argon works properly but we have faced an issue with the routine to send data using the Boron.
I have created a debug script so anyone in the community may give me some hints to solve the problem, this script works properly using an Electron (which is the other cellular device by Particle) but unfortunately it does not work as expected with the Boron
/****************************************
* Include Libraries
****************************************/
/****************************************
* Define Constants
****************************************/
const char *HOST = "industrial.api.ubidots.com";
const int PORT = 9012;
const char *USER_AGENT = "Ubidots/Boron";
const char *TOKEN = "BBFF";
const char *DEVICE_LABEL = "boron";
const char *VARIABLE_LABEL = "udp";
const int MAX_BUFFER_SIZE = 700;
UDP _client_udp_ubi;
/****************************************
* Auxiliar Functions
****************************************/
// Put here your auxiliar functions
IPAddress getServerIp(const char *hostName)
{
IPAddress serverIpAddress;
serverIpAddress = Cellular.resolve(hostName);
return serverIpAddress;
}
/****************************************
* Main Functions
****************************************/
void setup()
{
// Sets the max buffer size to send data
_client_udp_ubi.setBuffer(MAX_BUFFER_SIZE + 1);
}
void loop()
{
/* Builds payload */
float value = random(0, 1000) * 1.0;
char payload[MAX_BUFFER_SIZE];
sprintf(payload, "%s|POST|%s|%s:%s=>%s:%f", USER_AGENT, TOKEN, DEVICE_LABEL,
DEVICE_LABEL, VARIABLE_LABEL, value);
Serial.printf("payload: %s\n", payload);
/* Sends data */
IPAddress serverIpAddress = getServerIp(HOST);
Serial.print("Solved IP:");
Serial.println(serverIpAddress);
_client_udp_ubi.begin(PORT);
Serial.println("Sending value");
if (!(_client_udp_ubi.beginPacket(serverIpAddress, PORT) &&
_client_udp_ubi.write(payload) && _client_udp_ubi.endPacket()))
{
Serial.println("ERROR sending values with UDP");
}
else
{
Serial.println("Value sent");
}
_client_udp_ubi.stop();
delay(5000);
}
The Ip Address is solved properly but these lines:
if (!(_client_udp_ubi.beginPacket(serverIpAddress, PORT) &&
_client_udp_ubi.write(payload) && _client_udp_ubi.endPacket()))
{
Serial.println("ERROR sending values with UDP");
}
else
{
Serial.println("Value sent");
}
plots me in the serial Port that the values were sent without errors, but, we do not see any of them in our cloud. Is there any issue with this way for sending data using UDP? I have just read the official Particle docs but I do not see any error. I also tried setting a fixed IP address, without success.
The tests were run in a device owned by @Backpacker87 as at my actual location there is not LTE CAT-M1, @Backpacker87 may you gently share in this post your firmware device version?
Any help from the community is really appreciated.