[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] Publish does not appear in Broker

Andy,

MQTT-SN was used by mistake, meanwhile I have some code which is nearly identically to the example from the Eclipse webpage:

 ÂMQTTPacket_connectData Âdata="">
 ÂMQTTString       Âtopic=MQTTString_initializer;

--> open TCP/IP connection to broker
 Âdata.clientID.cstring=(char*)instData->m_machineID->c_str();
 Âdata.cleansession=1;
 Âlen = MQTTSerialize_connect(buf,MAX_BUFLEN,&data); /* 1 */

 Âtopic.cstring=(char*)topicData->c_str();
 Âstrncpy(payload,payData->c_str(),200);
 Âpayloadlen=strlen(payload);

 Âlen+=MQTTSerialize_publish(buf+len,MAX_BUFLEN-len,0,3,0,0,topic,(unsigned char*)payload,payloadlen); /* 2 */

 Âlen+=MQTTSerialize_disconnect(buf+len,MAX_BUFLEN-len); /* 3 */

--> send "buf" with length "len" to the broker via the previously opened connection


What could be wrong?

Mike







On Fri, Jul 20, 2018 at 10:34 AM, Andy Stanford-Clark <ANDYSC@xxxxxxxxxx> wrote:
it would be better to start from an MQTT example, rather than trying to adapt an MQTT-SN example.

There are several examples included with the Paho MQTT client.

Andy

Andy Stanford-Clark
IBM CTO - UK and Ireland

Distinguished Engineer, Master Inventor, Member IBM Academy of Technology, Fellow BCS
Visiting Professor at Newcastle, Southampton and UEA.

Tel: +44 (0)7801 787096 [internal: 37 277624] Â twitter: @andysc




From: Â Â Â ÂMike Maikaefer <mike.maikaefer@xxxxxxxxx>
To: Â Â Â ÂGeneral development discussions for paho project <paho-dev@xxxxxxxxxxx>
Date: Â Â Â Â20/07/2018 06:43
Subject: Â Â Â ÂRe: [paho-dev] Publish does not appear in Broker
Sent by: Â Â Â Âpaho-dev-bounces@xxxxxxxxxxx




OK, changed all to the non-SN-functions but with only few success. Bevywise now logs an incoming connection in the console and lists the client-ID, but does not show any of my publications. In HiveMQ nothing has changed, it shows small peaks in the "Connections"-field but I also can't see the publication anywhere...

On Thu, Jul 19, 2018 at 1:47 PM, Mike Maikaefer <mike.maikaefer@xxxxxxxxx> wrote:
This sounds good - I didn't notice the difference between both. Thanks, I'll try it!


On Thu, Jul 19, 2018 at 1:30 PM, Dominik Obermaier <dominik.obermaier@xxxxxxxxx> wrote:
Hi Mike,

Iâm not an expert with the C/C++ lib and the APIs, but it seems youâre trying to use MQTT-SN instead of plain MQTT. At least HiveMQ does currently not support MQTT-SN.

Could this be the source of the problem?

Best,
Dominik



On 19 Jul 2018, at 13:07, Mike Maikaefer wrote:

Hi,

I'm using the embedded C/C++ variant of the PAHO-project out of a
microcontroller. My Problem: although the data are sent (can be verified
with WireShark), a broker these data sent to does not recognise them and
does not show the related data. This was testedwith HiveMQ and BevyWise
MQTTRoute.

This is what I'm doing to create and send a message (pseudo-code due to
some microcontroller-specific function calls):

 ÂMQTTSNPacket_connectData data="">initializer;
 Âint           rc=0,payloadlen,len;
 Âunsigned char      buf[MAX_BUFLEN+1];
 ÂMQTTSN_topicid     Âtopic;
 Âchar          Âpayload[200+1];
 Âchar          Âid[200+1];

--> open a TCP/IP conection to the broker here

 Âdata.clientID.cstring=(char*)m_machineID->c_str(); // get identifier
from std::string
 Âdata.cleansession=1;
 Âlen = MQTTSNSerialize_connect(buf,MAX_BUFLEN,&data);

 Âtopic.data.long_.name=(char*)topicData->c_str(); // get the topic data
 Âtopic.data.long_.len=strlen(topic.data.long_.name);
 Âstrncpy(payload,payData->c_str(),200); // get the data to be sent
 Âpayloadlen=strlen(payload);


Âlen+=MQTTSNSerialize_publish(buf+len,MAX_BUFLEN-len,0,3,0,0,topic,(unsigned
char*)payload,payloadlen);
 Â// here the fourth parameter has to be "3", when setting it to "0", the
topic does not become part
 Â// of the data in "buf"

 Âlen+=MQTTSNSerialize_disconnect(buf+len,MAX_BUFLEN-len,200);

--> send the data in "buf" with the length "len" here - this is successful
--> close the TCP/IP connection to the broker here

Any idea what I'm doing wrong here?

Thanks!

_______________________________________________
paho-dev mailing list

paho-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit

https://dev.eclipse.org/mailman/listinfo/paho-dev
_______________________________________________
paho-dev mailing list

paho-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit

https://dev.eclipse.org/mailman/listinfo/paho-dev

_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/paho-dev


Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU

_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/paho-dev