GL-MT300N-V2 MQTT function

I like to get information from the Mango over mqtt to my broker. The broker is running on a raspberry PI3

When i found and enable the mqtt feature of the Mango i could not found any informationen whre i can setup it. Also not a hwotodo decription or samples.
Have anyone use mqtt as a slave and could me help to understand how it works?

This is the tutorial about send message to AWS IoT over MQTT, hope it will help you.

1 Like

Hi Leo, my GL-150AR already connected to my cloud on AWS IOT. I can subscribe and publish successfully, base on /etc/config/glconfig, /etc/init.d/gl_mqtt and /etc/aws

Would you share how to send mqtt - JSON with my own content. I saw that the gl_mqtt send message to cloud every 30 secs, how to change the timing?

Thanks

  1. you can publish a string from GL-AR150 to AWS IoT, you should can publish a JSON. JSON is a string too, it just with a special format, like { "msg": "online" }.

  2. I don’t know how to change the 30 seconds, please ask @luochongjun

Already tried this, but no luck. Nothing send to AWS on /iot/topic .

/etc/confic/glcofig:

config service ‘cloud’
option enable ‘1’
option sub_topic ‘/a1rLNyG2VK5/mqtt_demo/user/get’
option pub_topic ‘/iot/topic’
option service_pride ‘2’
option address ‘ssl://???9gk0-ats.iot.us-east-2.amazonaws.com:888
3’
option clientid ‘iotconsole-???9gk0’
option log ‘1’

$ /etc/init.d/gl_mqtt start
$ more test_json_aws
$ !/usr/bin/sh
. /usr/share/libubox/jshn.sh
while true
do
sleep 5
date=date +"%Y%m%d%H%M%S"
json_init
json_add_string “MAC” “1234567890”
json_add_string “light” “0”
json_add_string “vibration” “1”
json_close_object
json_close_object
data=json_dump
ubus call gl_mqtt_cli pub “$data”
echo $data
done

$
$ sh test_json_aws
Command failed: Not found
{ “MAC”: “1234567890”, “light”: “0”, “vibration”: “1” }
^C
$
$ logread
Tue Aug 4 03:31:27 2020 daemon.notice gl_mqtt_cli: host:ssl://???9gk0-ats.iot.us-east-2.amazonaws.com:8883 clientid:iotconsole-a3bibq8pkj9gk0 user: pwd:.
Tue Aug 4 03:31:27 2020 daemon.notice gl_mqtt_cli: aws.
Tue Aug 4 03:31:29 2020 daemon.err gl_mqtt_cli[2740]: cat: can’t open ‘/etc/glproduct’: No such file or directory
Tue Aug 4 03:31:30 2020 daemon.notice gl_mqtt_cli: Line:152 router_msg:{“model”:“ar150”,“ddns”:“wya0aa5”,“sn”:“ea407456c9f604aa”,“mac”:“e4:95:6e:4a:0a:a5”,“version”:“3.024”,“type”:“router”,“ip”:“192.168.8.1”,“ssid”:“GL-AR150-aa5”,“owner”:"",“system”:“OpenWrt 18.06.1, r7258-5eb055306f”,“kernel”:“Linux version 4.9.120 (lancer@gl-inet) (gcc version 7.3.0 (OpenWrt GCC 7.3.0 r7258-5eb055306f) ) #0”,“reboot_flag”:"",“code”:0}.
Tue Aug 4 03:31:30 2020 daemon.notice gl_mqtt_cli: Line:155 len:352 router_msg:{“model”:“ar150”,“ddns”:“wya0aa5”,“sn”:“ea407456c9f604aa”,“mac”:“e4:95:6e:4a:0a:a5”,“version”:“3.024”,“type”:“router”,“ip”:“192.168.8.1”,“ssid”:“GL-AR150-aa5”,“owner”:"",“system”:“OpenWrt 18.06.1, r7258-5eb055306f”,“kernel”:“Linux version 4.9.120 (lancer@gl-inet) (gcc version 7.3.0 (OpenWrt GCC 7.3.0 r7258-5eb055306f) ) #0”,“reboot_flag”:"",“code”:0}.

Also already tried this, it keeps sending every 30secs until stop, but nothing received at aws side:

$ /etc/init.d/gl_mqtt stop
$ /usr/bin/gl_mqtt_cli pub -t “test”
Failed to add object: Invalid argument
^C

Would you explain how to use it and the arguments, any manual would be great for “gl_mqtt_cli”

Thanks for your help and support

@adres.manik already succeeded in sending messages to AWS IOT?

I followed the manual as well but nothing so far, it doesn’t receive or transmit any package.

my glconfig:

config service 'cloud'
        option enable '1'
        option sub_topic '/my/user/fromaws'
        option pub_topic '/my/user/fromthing'
        option service_pride '2'
        option address 'ssl://xxxxxxx9i7pzbn-ats.iot.eu-central-1.amazonaws.com:8883'
        option clientid 'myfirstthing'
        option log '1'

having the client.crt, client.key and root_CA.crt in /etc/aws

logread output:
Mon Sep 19 21:44:50 2022 daemon.err gl_mqtt_service[2735]: url = https:///gslb/getbucket?deviceType=1&mac=xxxxxxxx&sn=xxxxxxxx&ddns=xxxxxxxx&timestamp=1663623889&sign=052cb1de27263fe14d6bbaf354fe548a
Mon Sep 19 21:44:50 2022 daemon.err gl_mqtt_service[2735]: utils_NLB failed!

btw, connecting to goodcloud works ok.