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]);
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.