I have been experimenting with the example of the MQTT Client Subscriber/Publisher from de nRF SDK. I use:
- SDK v15.3.0 (also nRF5 SDK v15.2.0).
- Raspberry Pi 3 (as a border router - stretch).
- Mosquitto as (MQTT broker).
- PCA10040 (nRF52832) as a MQTT subscriber or publisher.
Well, I tried the application example successfully, and I could establish a correct communication between device using the protocols of the application (MQTT Client: BLE/6LoWPAN/MQTT). But, it works for me only if I use non secure transport (1883 port).
I want to establish the communication using a simple TLS-PSK connection between the PCA10040 and Raspberry PI. Then, I followed TLS-PSK configuration from the Nordic Semiconductor Infocenter.
For the MQTT Broker side, I made my own "mosquitto.conf" file and add:
psk_hint randomhint psk_file /home/desktop/Pass.txt
Also I used "mosquitto -p 8883 -v -c mymosquitto.conf" command to execute MQTT broker. And lastly, just for a test client, i used the next commands (and it works fine):
mosquitto_sub --psk-identity Client_identity1 --psk 73656372657450534b -p 8883 -t "led/state" mosquitto_pub --psk-identity Client_identity2 --psk 73656372657450534a -p 8883 -t "led/state" -m "1"
For the MQTT Client's side, I adjusted in de code application the broker port as 8883 and the connection parameters for the mqtt_connect as below:
... m_app_mqtt_id.transport_type = MQTT_TRANSPORT_SECURE; m_app_mqtt_id.p_security_settings = &m_tls_keys; uint32_t err_code = mqtt_connect(&m_app_mqtt_id); APP_ERROR_CHECK(err_code); ...
To the point, it doesn't work. MQTT connection is not happening when pressing button 1. For example in the Publisher example, after de the BLE link established and IPv6 interface up (LED 1 ON), if I press button 1 the LED 2 doesn't turn ON. In other words I can't establish a MQTT connection when I use TLS-PSK.
The broker says:
1558107557: New connection from 2001:db8::fe:44ff:feda:19ee on port 8883. 1558107559: New client connected from 2001:db8::fe:44ff:feda:19ee as nrfPublisher (c1, k60). 1558107559: Sending CONNACK to nrfPublisher (0, 0) 1558107648: Client nrfPublisher has exceeded timeout, disconnecting. 1558107648: Socket error on client nrfPublisher, disconnecting.
I must say that I'm new in this subject, so maybe, theres is an additional configuration that I should do in the code of the application example (MQTT publisher) to establish a TLS-PSK connection? Perhaps a memory problem? Something more advanced?
Please, give me a hand with this issue. Thanks in advance.
Best regards,
Cisco
Cisco