-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. fix function _mqtt_yield_thread local variable redefine bug. 2. add dynamic register doc
- Loading branch information
yougaliu
committed
Mar 10, 2021
1 parent
74b8325
commit 810ac68
Showing
6 changed files
with
68 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
### 动态注册使用说明 | ||
- 对于一机一密的场景,需要在生产环节将为每一个设备烧录由平台生成的唯一设备信息。 | ||
- 对于一型一密场景,同一产品类型的设备只要预置产品级密钥,可省去工厂的设备信息烧录。设备出厂后,在第一次开机且成功联网的情况下,可发起动态注册,通过产品密钥鉴权,从平台获取设备信息,然后存在本地,达成和工厂烧录一样的效果。 | ||
|
||
|
||
### 使用步骤 | ||
- 1、在[控制台使能](https://cloud.tencent.com/document/product/1081/47494)产品的动态注册功能。 | ||
>! 使能动态注册后才有产品密钥。 | ||
 | ||
|
||
- 2 、选择是否使能自动设备创建。这个选项决定动态注册的时候的设备名,是设备自定义的(需要保证统一产品下设备名唯一),还是使用平台预定义的设备名。 | ||
|
||
- 3、将产品密钥预置在设备侧。设备信息获取接口`HAL_GetDevInfo` 获取设备信息时会获取产品密钥,可通过设备信息设置接口`HAL_SetDevInfo`设置产品密钥。 | ||
|
||
- 4、判断是否触发动态注册。一般的方法是,设备启动,在动态注册使能的情况下,通过设备信息获取接口`HAL_GetDevInfo` 获取设备信息,判断设备密钥是否是默认值,如果是,则调用SDK的动态注册接口`IOT_DynReg_Device`发起动态注册,若动态注册成功,则通过设备信息设置接口`HAL_SetDevInfo`保存返回设备信息。后续设备即可按一机一密启动流程正常使用。 | ||
|
||
- 5、SDK设备动态注册示例`dynreg_dev_sample.c`说明: | ||
- 判断设备密钥是否为空,是否触发动态注册 | ||
``` | ||
memset((char *)&sDevInfo, 0, sizeof(DeviceInfo)); | ||
ret = HAL_GetDevInfo(&sDevInfo); | ||
/* just demo the PSK is empty */ | ||
if (!strcmp(sDevInfo.device_secret, QCLOUD_IOT_NULL_DEVICE_SECRET)) { | ||
Log_d("dev psk not exist!"); | ||
infoNullFlag = true; | ||
} else { | ||
Log_d("dev psk exist"); | ||
} | ||
``` | ||
|
||
- 发起动态注册,并保存动态注册的设备信息 | ||
``` | ||
/* device cert/key files or PSK is empty, do dynamic register to fetch */ | ||
if (infoNullFlag) { | ||
if (QCLOUD_RET_SUCCESS == IOT_DynReg_Device(&sDevInfo)) { | ||
ret = HAL_SetDevInfo(&sDevInfo); | ||
if (QCLOUD_RET_SUCCESS != ret) { | ||
Log_e("devices info save fail"); | ||
} else { | ||
Log_d( | ||
"dynamic register success,productID: %s, devName: %s, " | ||
"device_secret: %s", | ||
sDevInfo.product_id, sDevInfo.device_name, sDevInfo.device_secret); | ||
} | ||
} else { | ||
Log_e("%s dynamic register fail", sDevInfo.device_name); | ||
} | ||
} | ||
``` | ||
|
||
- 6、重复注册说明。一般情况动态注册只要执行一次,后续使用保存的设备信息即可。如果设备动态注册成功,但未激活(和平台成功建立过连接),则可重复注册。若已激活,则需要在控制台删除设备,才可以再次注册。不建议通过更换设备名的方式多次动态注册,相当于一个设备消耗多个设备的资源,对于运营管理也会带来麻烦。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters