-
Notifications
You must be signed in to change notification settings - Fork 46
Thinq2CloudProtocol
Once connected to the user's Wi-Fi network ThinQ2 devices communicate with LG's cloud service using HTTPs and MQTTs. No incoming connections are accepted.
The first steps after connecting to the Wi-Fi network are called "provisioning". During this process, the modem creates a key/certificate pair that it will use to authenticate itself with the cloud service.
Steps:
TODO: find out if this step is skipped when mqttServer & apiServer are provided using the setup protocol.
The device sends a https request to https://comon.lgthinq.com/route (this URL is stored in the firmware and not modified in normal operation). any HTTPS certificate is accepted.
Response: JSON
{"resultCode": "0000", "result": {"apiServer": "https://eic-common.lgthinq.com:443", "mqttServer": "ssl://a3phael99lf879.iot.eu-west-1.amazonaws.com:8883"}}
-
Request:
https://common.lgthinq.com/route/certificateResponse:
{"resultCode": "0000", "result": ["common-server", "aws-iot"]} -
Request:
https://common.lgthinq.com/route/certificate?name=common-serverResponse:
{"resultCode": "0000", "result": {"certificatePem": "pem-formatted certificate"}}-
certificatePemwill be used as a trusted certificate when connecting to the apiServer
-
-
Request:
https://common.lgthinq.com/route/certificate?name=aws-iotResponse:
{"resultCode": "0000", "result": {"certificatePem": "pem-formatted certificate"}}-
certificatePemwill be used as a trusted certificate when connecting to the mqttServer
-
Request: POST https://apiServer/device/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/certificate
- the request body contains the pem-formatted CSR
Response: {"resultCode":"0000", "result":{"certificatePem":"pem-formatted certificate"}}
-
certificatePemmust be used by the device, along with its private key to authenticate with the mqttServer
-
Connect to
mqttServer- Validate the server certificate against the certificate received from
/route/certificate?name=aws-iot - Use the client certificate obtained in the previous step
- Use the device uuid as the MQTT clientId
- Validate the server certificate against the certificate received from
-
Subscribe to
lime/devices/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx(device topic) -
Publish a message on
topic_prov(default:clip/provisioning/devices/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx){"mid":945658,"did":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx","kind":"RAC_056905_WW","cmd":"preDeploy","rssi":-56,"fs":"idle","data": {"appInfo":"modelName":"RAC_056905_WW","modelLanguage":"PL","softVer":"690409","ruleVer":"2.0.11","countryCode":"PL", "subCountryCode":"PL","appVersion":"clip_hna_v1.9.183","modemType":"RTK_RTL8711am","regionalCode":"eic","timezone":"+0100", "svcCode":"SVC202","HomeApSsid":"thisismyssid","DeviceType":"","ruleEngine":"y","protocolVer":"1","oneshot":"y","size":1572864, "fwUpgradeInfo":{"upgSched":{"cmd":"none","upgUtc":"0"}}},"platformInfo":{"provisioningKey":"RAC_056905_WW","version": "clip_v2.00.15.05-RTK_RTL8711am-SDK-8-RELEASE"}},"type":0} -
MQTT server responds with a message on the device topic:
{"did":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx","mid":1700263891876,"cmd":"completeProvisioning","type":0,"data": {"result":0,"host":"message","appInfo":{"host":"message","publication":{ "message":"$aws/rules/clip_http_action_rule/clip/devices/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/message", "provisioning":"$aws/rules/clip_provisioning_rule/clip/provisioning/devices/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}}, "provisioningType":"preDeploy","deployInterval":600}}-
messagespecifies the MQTT topic that the device will use to send its regular messages (topic_message) -
provisioningspecifies the MQTT topic that the device will use to send its provisioning messages (topic_prov)This topic will replace
topic_provin the module's flash. On subsequent setup attempts, the new topic will be used. When implementing a substitute for the cloud service, be aware that supplying a non-defaulttopic_provmay make the device persistently incompatible with the official cloud until the correcttopic_provis configured again via this process or using the debug UART shell.
-
-
Publish a message on
topic_message{"mid":1899923,"did":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx","kind":"RAC_056905_WW","cmd":"completeProvisioning_ack","rssi":-46,"fs":"idle","data":null,"type":1}When this point is reached the provisioning is considered complete. The device stores a
registeredflag in flash and will remember the Wi-Fi & cloud configuration until manually reset.
When the device connects to the MQTT server but the provisioning step has already been completed, the last three steps are repeated, with a slight difference:
-
Publish a message on
topic_provThe contents are the same as during provisioning, but the
cmdattribute is set todeploy. -
MQTT server responds with a message on the device topic:
The contents are the same as during provisioning, but the
provisioningTypeis set todeploy. -
Publish a message on
topic_messageThe contents are the same as during provisioning.
All messages at this stage are published to topic_message
Request: {"mid":75383,"did":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx","kind":"RAC_056905_WW","cmd":"req_timesync","rssi":-48,"fs":"idle","data":null,"type":1}
Response: unknown
{"mid":109239,"did":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx","kind":"RAC_056905_WW","cmd":"device_packet","rssi":-48,"fs":"idle","data":"000004000000870204690B8CA036458CD059ACE001DE6AC9","type":1}
-
datais a hex-encoded byte sequence.See TLV protocol and AABB Protocol for details.
All messages are published to the lime/devices/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx topic
{"did":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx","mid":1700432732556,"cmd":"packet","type":1,"data":"00010400000065020201027D416A0D"}
-
datais a hex-encoded byte sequence.See [TLVProtocol] and [AABBProtocol] for details.