Hi, I use the following.
- Raspberry Pi 3 (RPi3 with Raspbian Jessie 4.4) as a router,
RPi3 is connected to a Wi-Fi router to access the Internet by using the built-in Wi-Fi BLE BCM43438 chip.
-
IoT SDK 0.9 (nrf5_iot_sdk_3288530)
-
MQTT Publisher Example, configured as the non-secure port
-
PCA10040 v1.1.0 (2016.23)
-
Keil MDK-ARM uVision 5.20 (in Windows 10 64bit)
-
Amazon EC2 (which uses Ubuntu 14.0) for Mosquitto Broker (v 1.4.9)
-
Amazon RDS which uses MySQL 5.6 for ACL (Access Control Lists)
Thanks to Stian's answer,I tested the example and published the LED state.
Now I added Access Control Lists (ACL) by referring this blog.
I inserted username "user1" with password "1234" for testing. This user had read/write control.
I tested with Android Paho MQTT client Example; the client who has the username and password above can only publish or subscribe.
Other users who had different username was disconnected when they tried to publish something.
/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/
I entered the username and password. I modified the code like this;
#define APP_MQTT_BROKER_PORT 1883 /*8883*/
static void button_event_handler(uint8_t pin_no, uint8_t button_action){ // omitted some parts
case BSP_BUTTON_0:{ if (m_connection_state == false){
mqtt_client_init(&m_app_mqtt_client);
mqtt_utf8_t pw = {"1234", 0};
mqtt_utf8_t user = {"user1", 0};
pw.utf_strlen = strlen(pw.p_utf_str);
user.utf_strlen = strlen(user.p_utf_str);
memcpy(m_app_mqtt_client.broker_addr.u8, m_broker_addr.u8, IPV6_ADDR_SIZE);
m_app_mqtt_client.broker_port = APP_MQTT_BROKER_PORT;
m_app_mqtt_client.evt_cb = app_mqtt_evt_handler;
m_app_mqtt_client.client_id.p_utf_str = (uint8_t *)m_client_id;
m_app_mqtt_client.client_id.utf_strlen = strlen(m_client_id);
m_app_mqtt_client.p_password = &pw /*NULL*/;
m_app_mqtt_client.p_user_name = &user /*NULL*/;
m_app_mqtt_client.transport_type = MQTT_TRANSPORT_NON_SECURE /* MQTT_TRANSPORT_SECURE*/;
m_app_mqtt_client.p_security_settings = NULL /*&m_tls_keys*/;
uint32_t err_code = mqtt_connect(&m_app_mqtt_client);
if(err_code || &(m_app_mqtt_client.p_password) == NULL) // breakpoint location
APP_ERROR_CHECK(err_code);
I placed a breakpoint at if(err_code)
statement.
Although it returns no error, the PCA10040 cannot connect to the broker; the LED doesn't change to LED 2 on mode.
I sniffed the bt0 interface. You can see the packets in detail; wire-wPWCap.pcapng
Don't have a clue why destination port 0 is captured.
Did anybody test the MQTT example with ACL?
What seems to be the reason for failing connection after using ACL?
-Best Regards, Mango