- 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]);
- }
--
To learn more about MQTT please visit http://mqtt.org
---
You received this message because you are subscribed to the Google Groups "MQTT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+uns...@googlegroups.com.
To post to this group, send email to mq...@googlegroups.com.
Visit this group at http://groups.google.com/group/mqtt.
For more options, visit https://groups.google.com/d/optout.
I have not used the C embedded client. But, shouldn't your connect call have the broker location details too? Is the AT command to connect 'cover' the MQTT connect call also?
Sent from tablet. Pardon brevity, grammar mistakes or typos.
CONNECT:
0x10 – 0001(connect) + 0000 (flags)
0x13 – Remaining Length (decimal = 19)
0x00, 0x04 – Length of ‘MQTT’
0x4D, 0x51, 0x54, 0x54 – ‘MQTT’
0x04 – Protocol Level
0x02 – Clean session=1
0x00, 0x78 – Keep alive = 120
0x00, 0x07 – length of Client ID
0x4E, 0x6F, 0x72, 0x62, 0x65, 0x72, 0x74 – client ID “Norbert”
PUBLISH:
0x30 – 0011(publish) + 0000 (flags – QOS=0)
0x0F – Remaining length (decimal =15)
0x00,0x06 – legth of topic
0x70, 0x75, 0x62, 0x74, 0x6F, 0x70 – name of topic “pubtop”
0x70, 0x61, 0x79, 0x6C, 0x6F, 0x61, 0x64 – name of payload “payload”
DISCONNECT:
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]); }
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]); }
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]); }
--
To learn more about MQTT please visit http://mqtt.org
---
You received this message because you are subscribed to the Google Groups "MQTT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mqtt/06af04c3-fe27-4f8e-bd44-ba851e3d2fe4%40googlegroups.com.