Send 500 bytes to Xively via UDP (low data plan), using C on an MCU

361 Views Asked by At

We have our own Freescale K60 microcontroller board running MQX RTOS. We can POST (and most likely GET) data to Xively via TCP but our data plan is limited and TCP resends and chews up a ton of overhead. I have heard that UDP seems to be our best solution. We are having difficulty knowing how to GET and POST via UDP to Xively. We know we would have to write our own layer, any get tips? Also, are there any tricks to getting Xively to ack back to the microcontroller client?

1

There are 1 best solutions below

1
On

Xively currently supports only TCP-based protocols, which are:

  • HTTP and HTTPS
  • WebSocket, Telnet and MQTT (each with and without TLS)

You should try using HTTP with CSV data format first, it's very likely that the TCP payload will end up being small enough. For this purpose you can use Xively C library which is very portable. I have checked Freescale Application Note AN3907 and it looks lik porting of C library should be trivial, as "MQX RTCS sockets are compatible with Unix BSD 4.4". So you should be able to use existing POSIX communication layer, although you might need to include some different headers and make sure you have initialised the stack as well as configured the device either with a static IP or using DHCP. To account for amount of data being sent, please refer to the RX/TX counters provided by RTCS.

You could, however opt to use MQTT instead. You will end-up sending much smaller packets. Basic functionality for MQTT should be added to the Xively C library pretty soon.

If you are saying that you need a way of what you call "ack back to our controller", then MQTT is what you need for this. It's a publish/subscribe protocol, although you will need to keep a persistent connection.