MQTT Library on Microcontroller

后端 未结 2 431
执念已碎
执念已碎 2021-02-09 14:47

I want use MQtt Protocol as Messing protocol. I want to port the Mqtt Library on Microcontroller TMS470(Texas Instrument) with CCS Compiler. Since I am new to this Protocol, Can

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-09 15:31

    I have similar problem, I'm using STM32F405 and GPRS module( Quectell M95 ). I can't receive MQTT package correctly. As my experience, With PAHO embedded C library , I can publish a test Message to iot.eclipse.org.

    Benjamin MQTT with CC3200 example is very good to understand 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, PAHO embedded C library serilaze MQTT package and you need to implant transport method to library. ( Send /Recive / Connect / Disconnect )

    This is my transport_sendPacketBuffer() function, It just puts buffer to gprs module. Don't use printf. cause, MQTT package can be contain 0x00 , or any type of data. "buflen" is calculated by 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 socket with AT Command, There are several methods to connect. It depends on your GSM module AT+Command / TCP documantation ( Transparent / Multiple Connect ) If you have an library for your GSM module it will be help much too.

    This is 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 handle recive message I will glad to hear it.

提交回复
热议问题