aws_iot : able to connect with mqtt but msg isn't sent

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hardware : bcm9wcd5eval1_3

SDK : started with 3.3.1 and then aded 3.4.0-aws

Followed AWS_IOT getting started guide to create a sample thing and test topic.

Using the command line on my Mac, I am able to subscribe to and publish messages.

On the bcm9wcd5eval1_3 board I am able to connect to my mqtt broker, but I am unable to send messages.

I don't get any obvious errors, but I don't see anything either on my AWSIOTLogs in CloudWatch, or in the subscriber terminal

I am using the demo.aws_iot.pub_sub.publisher as my code base.

I have copied rootCa.pem, cert.perm and private_key.pm to resources/app/secure_mqtt

and made the following changes described in the publisher.c file :

#define MQTT_BROKER_ADDRESS                 "A23UXEXXOFKGVR.iot.us-east-1.amazonaws.com"

#define WICED_TOPIC                         "topic/test"

#define CLIENT_ID                           "clientid1"

conninfo.port_number = 8883;  <-- I tried with default value of 0 as always, but got the same behavior

Using aws cli on Mac:

terminal 1 : subscriber

$ mosquitto_sub --cafile ./rootCA.pem --cert ./cert.pem --key privateKey.pem -h A23UXEXXOFKGVR.iot.us-east-1.amazonaws.com -p 8883 -q 1 -d -t "topic/test" -i "clientid1"

Client clientid1 sending CONNECT

Client clientid1 received CONNACK

Client clientid1 sending SUBSCRIBE (Mid: 1, Topic: topic/test, QoS: 1)

Client clientid1 received SUBACK

Subscribed (mid: 1): 1

terminal 2 : publisher

$ mosquitto_pub --cafile rootCA.pem --cert cert.pem --key privateKey.pem -h A23UXEXXOFKGVR.iot.us-east-1.amazonaws.com -p 8883 -t topic/test -i clientid1 -m "Hello, Dalvi"

terminal 1 : subscriber sees published message

Client clientid1 received PUBLISH (d0, q0, r0, m0, 'topic/test', ... (12 bytes))

Hello, Dalvi

Logs from CoolTerm

Starting WICED v3.4.0-AWS

Platform BCM943341WCD1 initialised

Started ThreadX v5.6

Initialising NetX_Duo v5.7_sp2

Creating Packet pools

WWD SDIO interface initialised

WLAN MAC Address : 6C:AD:F8:F0:EC:43

WLAN Firmware    : wl0: Oct 13 2014 15:25:13 version 6.10.190.51 (r507746) FWID 01-60cadeb3

Joining : mySSID

Successfully joined : mySSID

Obtaining IPv4 address via DHCP

DHCP CLIENT hostname WICED IP

IPv4 network ready IP: 10.xx.xx.xx

Setting IPv6 link-local address

IPv6 network ready IP: FE80:0000:0000:0000:6EAD:F8FF:FEF0:EC43

Resolving IP address of MQTT broker

[MQTT] Connecting to broker 54.85.255.214 ...

[MQTT] Opening connection...Success

publish_callback

[MQTT] Publishing...

mqtt_app_publish test

mqtt_app_publish success 

Success

No errors while publishing the message, but on terminal 1 I don't see the message being received.

Also I don't see any logs should up on AWS CloudWatch Logs

0 Likes
1 Solution
Anonymous
Not applicable

I am now getting messages to show up on aws (dynamodb).

The main change I made was adding my cert.pem and private_key.pem to

resources/apps/aws_iot

instead of

resources/apps/secure_mqtt folder, as is described in the header of publisher.c

I am assuming without this change I was talking to a different endpoint used by the demo app.

However there are still 2 strange behaviors I am seeing :

1. can't get the push button to work anymore : doesn't call the  publish_callback when button is pressed.

    So to work around this I sent the message right after connection was successful.

2. I get the following events in mqtt_connection_event_cb  in this sequence

    a. WICED_MQTT_EVENT_TYPE_CONNECT_REQ_STATUS (as a result of the connection request)

    b. WICED_MQTT_EVENT_TYPE_PUBLISHED (as a result of the published message)

    c. WICED_MQTT_EVENT_TYPE_DISCONNECTED  .. not sure why this is being called.

View solution in original post

2 Replies
Anonymous
Not applicable

I am now getting messages to show up on aws (dynamodb).

The main change I made was adding my cert.pem and private_key.pem to

resources/apps/aws_iot

instead of

resources/apps/secure_mqtt folder, as is described in the header of publisher.c

I am assuming without this change I was talking to a different endpoint used by the demo app.

However there are still 2 strange behaviors I am seeing :

1. can't get the push button to work anymore : doesn't call the  publish_callback when button is pressed.

    So to work around this I sent the message right after connection was successful.

2. I get the following events in mqtt_connection_event_cb  in this sequence

    a. WICED_MQTT_EVENT_TYPE_CONNECT_REQ_STATUS (as a result of the connection request)

    b. WICED_MQTT_EVENT_TYPE_PUBLISHED (as a result of the published message)

    c. WICED_MQTT_EVENT_TYPE_DISCONNECTED  .. not sure why this is being called.

I believe you are using BCM943341 hardware, the application was developed for BCM94343W and AVN4343W hardware, kindly change the mapping of  GPIO's accordingly and button press should work.