MQTT protocol on AT32UC3 processor

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have problem with publish any MQTT message via Telit GSM GL865 Quad. Firstly I am connecting to test broker (iot.eclipse.org or test.mosquitto.org):

AT+CGDCONT=1,"ip","internet"
AT&K0

AT#SCFG= 1,1,300,90,600,50AT+CGATT?                                             
AT#SGACT=1,1                                    

AT#SD=1,0,1883,"test.mosquitto.org"

Then I got message: "CONNECT" and then I suppose that I can send data via MQTT.

So I have implemented PAHO embedded C library (this tutorial helped me: https://www.youtube.com/watch?v=...) in my AVR32UC3A0512 processor: 

MQTTPacket_connectData data = MQTTPacket_connectData_initializer;
int rc = 0;
char buf[200];
MQTTString topicString = MQTTString_initializer;
char* payload = "mypayloadnew";
int payloadlen = strlen(payload);
int buflen = sizeof(buf);
data.clientID.cstring = "me";
data.keepAliveInterval = 20;
data.cleansession = 1;
int len = MQTTSerialize_connect(buf, buflen, &data); /* 1 */
topicString.cstring = "public/mytopic";
len += MQTTSerialize_publish(buf + len, buflen - len, 0, 0, 0, 0, topicString, payload, payloadlen); /* 2 */
len += MQTTSerialize_disconnect(buf + len, buflen - len);
                                     
                                       
int i=0;
for(i=0;i<=len;i++){
       usart_putchar(&AVR32_USART0, buf[i]);
}

After initialization of connection I send following frame (I see that on terminal): [01][0E][00][04]MQTT[04]@[00][14][00][02]me[03][1C][00][0E]public/mytopicmypayloadnew[0E][00][00], where my topic is "public/mytopic" and my payload is "mypayloadnew". 

After a few seconds I get answer from GSM: NO CARRIER what means: connection lost and any message is not delivered. Please advise me what is wrong? I installed MQTT Lens to Chrome Browser and I can see what I get. I tried to install android app (My MQTT), publish some text, then subscribe on MQTT Lens and it works. Is that frame ([01][0E][00][04]MQTT...) proper?

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

MQTT uses TCP/IP for transport.

 

Do you have a TCP/IP stack in place?

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Telit GL865 Quad has built-in TCP/IP. I think the problem is in the frame of MQTT, I am trying to analyse it, 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So, setting aside MQTT, does the basic TCP/IP part work?

 

You seem to be just dumping the buffer to the UART - does that work?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

So, setting aside MQTT, does the basic TCP/IP part work?

 

You seem to be just dumping the buffer to the UART - does that work?

 

    I have the same problem.. If i only publish like below every second, the message gets delivered but there's a problem with the timing. It gets all 3 messsages after 3 seconds. BTW i use Telit GL850 module. Before sending these packets, i open a tcp socket to iot.eclipse.org:1883

 

    First connect,

 

 

    MQTTPacket_connectData data = MQTTPacket_connectData_initializer;
    data.clientID.cstring = "me";
    data.keepAliveInterval = 20;
    data.cleansession = 1;
    len = MQTTSerialize_connect(buf, buflen, &data);

    for ( i=0;i<len;i++) {
        Board_UARTPutChar(buf[i]);
    }

 

 

 

   Then publish your message like below every sec. without disconnecting. 

 

    

    MQTTString topicString = MQTTString_initializer;
    topicString.cstring = "mytopic";

    char buf2[50];
    int buflen2 = sizeof(buf2);
    int len2=0;
    int i = 0;
    len2 = MQTTSerialize_publish(buf2, buflen2, 0, 0, 0, 0, topicString, "10.290", 6);

    for ( i=0;i<len2;i++) {
        Board_UARTPutChar(buf2[i]);
    }

 

   But if i do it like below, i get NO CARRIER.. If you did find a solution, can you please share ? Thanks

 

        MQTTPacket_connectData data = MQTTPacket_connectData_initializer;

		int rc = 0;

		char buf[200];

		int buflen = sizeof(buf);


		MQTTString topicString = MQTTString_initializer;

		char* payload = "10.000";
		int payloadlen = strlen(payload);
		int len = 0;


		data.clientID.cstring = "me";
		data.keepAliveInterval = 20;
		data.cleansession = 1;

		len = MQTTSerialize_connect((unsigned char *)buf, buflen, &data);

		topicString.cstring = "mytopic";
		len += MQTTSerialize_publish((unsigned char *)(buf + len), buflen - len, 0, 0, 0, 0, topicString, (unsigned char *)payload, payloadlen);

		len += MQTTSerialize_disconnect((unsigned char *)(buf + len), buflen - len);

		
		for (int k=0;k<len;k++) {
			Board_UARTPutChar(buf[k]);
		}

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi, i´m trying to put the paho working with telit modem and i have the some issue when i send the mqtt data i recieved the no carrier information and the data is not recieved by the broker  test.mosquito.org.  Above i see what you have and i have the some, do you fix the problem can you help me?

 

Best regards,