Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] Paho MQTT Embedded C Client Support

Hi
Mr Mike
How I do the pull request for upgrade the code that I built?. Do you can explain me the process?

2016-09-27 15:52 GMT-05:00 Michell Castaño <mcastano@xxxxxxxxxxxx>:
Hi, Mike

That's great that you say me. I need permissions to do a commit in  the code on github?



2016-09-27 15:21 GMT-05:00 Michell Castaño <mcastano@xxxxxxxxxxxx>:
Hi, Mike
Best Regard

Thanks a lot for your kind attention and your excellent support. I  found the failure in the code, and I solved with the nesting of qos0pub and pub0sub1 codes, so:

qos0pub.c:

/*******************************************************************************
 * Copyright (c) 2014 IBM Corp.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * and Eclipse Distribution License v1.0 which accompany this distribution.
 *
 * The Eclipse Public License is available at
 * and the Eclipse Distribution License is available at
 *
 * Contributors:
 *    Ian Craggs - initial API and implementation and/or initial documentation
 *    Sergio R. Caprile - clarifications and/or documentation extension
 *******************************************************************************/

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include "MQTTPacket.h"
#include "transport.h"

#include <signal.h>

int toStop = 0;

void cfinish(int sig)
{
signal(SIGINT, NULL);
toStop = 1;
}

void stop_init(void)
{
signal(SIGINT, cfinish);
signal(SIGTERM, cfinish);
}
/* */

int main(int argc, char *argv[])
{
MQTTPacket_connectData data = "">izer;
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:

Imágenes integradas 1

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:

Imágenes integradas 1

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:


Imágenes integradas 3


Imágenes integradas 2
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:


I work in C and I obtained this results:

Imágenes integradas 1
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-dev

Best 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








Back to the top