-
Notifications
You must be signed in to change notification settings - Fork 3
MQTT
note: currently unknown if the Luba actually supports local MQTT, it does not expose port 1883/8883 at least
The Luba connects to the Alibaba Cloud IoT platform, and most documentation (though there is not a lot) for the platform applies to the Luba.
See for example: https://static-aliyun-doc.oss-cn-hangzhou.aliyuncs.com/download%2Fpdf%2F145493%2FDevice_Access_intl_en-US.pdf
To connect, you must retrieve your product key
, device name
, and device secret
. You can do so by starting the app on Android while viewing logs with logcat
and looking for the line containing getSaveMobileTriple()
. The line will contain a JSON array of objects, one of which has "host": "eu-central-1.api-iot.aliyuncs.com"
. Use the values of pk
, dn
, and ds
of that object.
Next, choose a client ID. It is currently unknown if there are any restrictions, but to be safe it's likely best to just use alphanumeric characters and no more than 64.
Construct the full client ID by appending |securemode=2,signmethod=hmacsha1|
to the client ID you chose, and use that to connect.
For the username, use device_name + "&" + product_key
. For the password, create the string "clientId" + client_id + "deviceName" + device_name + "productKey" + product_key
, create a HMAC+SHA1 hash and use the hexadecimal representation for the password.
Code example:
product_key = ...
device_name = ...
device_secret = ...
client_id = "asdf"
mqtt_client_id = f"{client_id}|securemode=2,signmethod=hmacsha1|"
mqtt_username = f"{device_name}&{product_key}"
sign_content = f"clientId{client_id}deviceName{device_name}productKey{product_key}"
mqtt_password = hmac.new(
device_secret.encode("utf-8"), sign_content.encode("utf-8"),
hashlib.sha1
).hexdigest()
Note: While the app is open then "your" client, and presumable the app as well, gets continually disconnected. Likely because the app and your client are fighting over the connection. Currently unknown if it is possible to work around this.
TODO
All pages in this wiki are licensed under the Apache License 2.0