MQTTPacket_connectData data = "">
int rc = 0;
unsigned char buf[200];
int buflen = sizeof(buf);
int mysock = 0;
int msgid = 1;
MQTTString topicString = MQTTString_initializer;
int req_qos = 0;
char* payload = "TESTA";
int payloadlen = strlen(payload);
int len = 0;
char *host = "broker.hivemq.com";
int port = 1883;
stop_init();
if (argc > 1)
host = argv[1];
if (argc > 2)
port = atoi(argv[2]);
mysock = transport_open(host,port);
if(mysock < 0)
return mysock;
printf("Sending to hostname %s
port %d\n", host, port);
data.clientID.cstring = "me";
data.keepAliveInterval = 60;
data.cleansession = 1;
data.username.cstring = "testuser";
data.password.cstring = "testpassword";
data.MQTTVersion = 4;
len = MQTTSerialize_connect(buf, buflen,
&data);
rc = transport_sendPacketBuffer(mysock,
buf, len);
/* wait for connack */
if (MQTTPacket_read(buf, buflen,
transport_getdata) == CONNACK)
{
unsigned char sessionPresent, connack_rc;
if (MQTTDeserialize_connack(&sessionPresent,
&connack_rc, buf, buflen) != 1 || connack_rc != 0)
{
printf("Unable to connect, return
code %d\n", connack_rc);
goto exit;
}
}
else
goto exit;
/* loop getting msgs on subscribed
topic*/
topicString.cstring = "LaHermosa/Zona2";
while (!toStop)
{
// transport_getdata() has a built-in
1 second timeout, your mileage will vary
if (MQTTPacket_read(buf, buflen,
transport_getdata) == PUBLISH)
{
unsigned char dup;
int qos;
unsigned char retained;
unsigned short msgid;
int payloadlen_in;
unsigned char* payload_in;
int rc;
MQTTString receivedTopic;
rc = MQTTDeserialize_publish(&dup,
&qos, &retained, &msgid, &receivedTopic,
&payload_in, &payloadlen_in,
buf, buflen);
printf("message arrived %.*s\n",
payloadlen_in, payload_in);
}
printf("publishing reading\n");
len = MQTTSerialize_publish(buf, buflen,
0, 0, 0, 0, topicString, (unsigned char*)payload, payloadlen);
rc = transport_sendPacketBuffer(mysock,
buf, len);
}
printf("disconnecting\n");
len = MQTTSerialize_disconnect(buf,
buflen);
rc = transport_sendPacketBuffer(mysock,
buf, len);
exit:
transport_close(mysock);
return 0;
}
Now, the results are:

I solved taking into account the ACK
Messages from the broker.
Again, thanks a lot.
See you son.
2016-09-27 13:45 GMT-05:00 Michell Castaño <mcastano@xxxxxxxxxxxx>:
Hi, Mike
I have another client to subscribe to the topic "LaHermosa/#".
This topic is listening with the broker "broker.hivemq.com"
in the port 1883, so:

The client qos0pub shows a "succesfully published"
but in the broker subscriber do not appear nothing.
Now, I use another client, this time a websocket client
at the same broker, and this are the results:


Thanks, again for your kind attention.
2016-09-27 12:04 GMT-05:00 Michell Castaño <mcastano@xxxxxxxxxxxx>:
Hi, Mike
For the Paho Embedded C Client I am using the next library:
https://github.com/eclipse/paho.mqtt.embedded-c/tree/master/MQTTPacket/samples
I work in C and I obtained this results:

Perhaps, do you know, why don't running?
Thanks, again for your kind attention.
2016-09-27 10:53 GMT-05:00 Mike Tran <miketran@xxxxxxxxxx>:
Hello Michell,
There are some example code that may help you get started with the Paho
Embedded C client.
If you are using the C++ library: https://github.com/eclipse/paho.mqtt.embedded-c/tree/master/MQTTClient/samples/linux
If you are using the C libray: https://github.com/eclipse/paho.mqtt.embedded-c/tree/master/MQTTClient/samples/linux
I have used the Paho Embedded C client on a few devices. I have not
seen any publish issues.
--
Regards,
Mike Tran
From: Michell
Castaño <mcastano@xxxxxxxxxxxx>
To: paho-dev@xxxxxxxxxxx
Cc: Michell
Castaño <mcastano@xxxxxxxxxxxx>
Date: 09/27/2016
09:50 AM
Subject: [paho-dev]
Paho MQTT Embedded C Client Support
Sent by: paho-dev-bounces@xxxxxxxxxxx
Good Morning
Members of Paho-devBest Regard
I'm Michell from Colombiaand
I have been testing the Embedded MQTT Client C library (https://eclipse.org/paho/clients/c/embedded/)
but although I obtained a successful test with the pub0sub1 sample, I can
not tell the same with qos0pub sample,because this do not publish the payload
required by me, into the broker of testing.
Please, do you can support me with
this?
Beforehand, thanks a lot for your kind
attention.
See you son._______________________________________________
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