MQTT library on a microcontroller

I want to use the MQtt protocol as the messing protocol. I want to port the Mqtt library on a TMS470 microcontroller (Texas Instrument) using the CCS compiler. Since I am new to this protocol, can any body suggest me how to use this protocol using the GPRS module. I learned MQtt. But I don’t know where to start. After opening TCP / IP, how to publish or sign data. Generally, how to port a library. And where will I get the library

+6
source share
2 answers

You can use the Paho built-in client library: https://eclipse.org/paho/clients/c/embedded .

Using this library, you only need to implement the logic for writing and reading from your GPRS module (Network) and time management (Timer).

As an example, you can look at my MQTT library for Arduino: https://github.com/256dpi/arduino-mqtt . The Paho embedded client repository has a few more examples.

+8
source

I have a similar problem, I use STM32F405 and GPRS module (Quectell M95). I can not get the MQTT package correctly. In my experience, with the C PAHO built-in library, I can post a test post to iot.eclipse.org.

Benjamin MQTT with the CC3200 example is very good for understanding the concept. Watch the video tutorial.

http://blog.benjamin-cabe.com/2014/08/26/mqtt-on-the-ti-cc3200-launchpad-thanks-to-paho-embedded-client

As I understand it, PAHO has a built-in C library serilaze MQTT, and you need to implement the transport method in the library. (Send / Recive / Connect / Disconnect)

This is my transport_sendPacketBuffer () function, it just puts a buffer in the gprs module. Do not use printf. reason, the MQTT packet may contain 0x00 or any data type. "buflen" is computed by the library.

int transport_sendPacketBuffer(int out, char* buf, int buflen) { int i=0; for(i=0;i<=buflen;i++){ put(buf[i]); // Put One char to GPRS modem . } } 

Before you transport_data you need to connect a socket with an AT command. There are several ways to connect. It depends on your GSM AT + Command / TCP documantation (Transparent / Multiple Connect) module. If you have a library for your GSM module, this will also help.

This is a simple Quectel M95 TCP socket connection command, AT + QIOPEN

 int CONNECT_SERVER_SOC (char *ip,int soc ){ char bf[128]; sprintf(bf,"AT+QIOPEN=\"TCP\",\"%s\",%d\r\n",ip,soc); // ip= "198.41.30.241", port:1883 // iot.eclipse.org printf("%s",bf); } 

If you can process the return message, I will be happy to hear it.

+6
source

Source: https://habr.com/ru/post/980268/


All Articles