未验证 提交 7536e5a3 编写于 作者: D David Lin 提交者: GitHub

Update HAL_Device_tencentos_tiny.c

上级 061afcb9
......@@ -57,104 +57,104 @@ static char sg_sub_device_name[MAX_SIZE_OF_DEVICE_NAME + 1] = "YOUR_SUB_DEV_NAM
static int device_info_copy(void *pdst, void *psrc, uint8_t max_len)
{
if(strlen(psrc) > max_len){
return QCLOUD_ERR_FAILURE;
}
memset(pdst, '\0', max_len);
strncpy(pdst, psrc, max_len);
return QCLOUD_RET_SUCCESS;
if(strlen(psrc) > max_len){
return QCLOUD_ERR_FAILURE;
}
memset(pdst, '\0', max_len);
strncpy(pdst, psrc, max_len);
return QCLOUD_RET_SUCCESS;
}
#endif
int HAL_SetDevInfo(void *pdevInfo)
{
POINTER_SANITY_CHECK(pdevInfo, QCLOUD_ERR_DEV_INFO);
int ret;
DeviceInfo *devInfo = (DeviceInfo *)pdevInfo;
POINTER_SANITY_CHECK(pdevInfo, QCLOUD_ERR_DEV_INFO);
int ret;
DeviceInfo *devInfo = (DeviceInfo *)pdevInfo;
#ifdef DEBUG_DEV_INFO_USED
ret = device_info_copy(sg_product_id, devInfo->product_id, MAX_SIZE_OF_PRODUCT_ID);//set product ID
ret |= device_info_copy(sg_device_name, devInfo->device_name, MAX_SIZE_OF_DEVICE_NAME);//set dev name
ret = device_info_copy(sg_product_id, devInfo->product_id, MAX_SIZE_OF_PRODUCT_ID);//set product ID
ret |= device_info_copy(sg_device_name, devInfo->device_name, MAX_SIZE_OF_DEVICE_NAME);//set dev name
#ifdef AUTH_MODE_CERT
ret |= device_info_copy(sg_device_cert_file_name, devInfo->dev_cert_file_name, MAX_SIZE_OF_DEVICE_CERT_FILE_NAME);//set dev cert file name
ret |= device_info_copy(sg_device_privatekey_file_name, devInfo->dev_key_file_name, MAX_SIZE_OF_DEVICE_SECRET_FILE_NAME);//set dev key file name
ret |= device_info_copy(sg_device_cert_file_name, devInfo->dev_cert_file_name, MAX_SIZE_OF_DEVICE_CERT_FILE_NAME);//set dev cert file name
ret |= device_info_copy(sg_device_privatekey_file_name, devInfo->dev_key_file_name, MAX_SIZE_OF_DEVICE_SECRET_FILE_NAME);//set dev key file name
#else
ret |= device_info_copy(sg_device_secret, devInfo->device_secret, MAX_SIZE_OF_DEVICE_SECRET);//set dev secret
ret |= device_info_copy(sg_device_secret, devInfo->device_secret, MAX_SIZE_OF_DEVICE_SECRET);//set dev secret
#endif
#else
Log_e("HAL_SetDevInfo not implement yet");
ret = QCLOUD_ERR_DEV_INFO;
Log_e("HAL_SetDevInfo not implement yet");
ret = QCLOUD_ERR_DEV_INFO;
#endif
if(QCLOUD_RET_SUCCESS != ret) {
Log_e("Set device info err");
ret = QCLOUD_ERR_DEV_INFO;
}
return ret;
if(QCLOUD_RET_SUCCESS != ret) {
Log_e("Set device info err");
ret = QCLOUD_ERR_DEV_INFO;
}
return ret;
}
int HAL_GetDevInfo(void *pdevInfo)
{
POINTER_SANITY_CHECK(pdevInfo, QCLOUD_ERR_DEV_INFO);
int ret;
DeviceInfo *devInfo = (DeviceInfo *)pdevInfo;
memset((char *)devInfo, '\0', sizeof(DeviceInfo));
POINTER_SANITY_CHECK(pdevInfo, QCLOUD_ERR_DEV_INFO);
int ret;
DeviceInfo *devInfo = (DeviceInfo *)pdevInfo;
memset((char *)devInfo, '\0', sizeof(DeviceInfo));
#ifdef DEBUG_DEV_INFO_USED
ret = device_info_copy(devInfo->product_id, sg_product_id, MAX_SIZE_OF_PRODUCT_ID);//get product ID
ret |= device_info_copy(devInfo->device_name, sg_device_name, MAX_SIZE_OF_DEVICE_NAME);//get dev name
ret = device_info_copy(devInfo->product_id, sg_product_id, MAX_SIZE_OF_PRODUCT_ID);//get product ID
ret |= device_info_copy(devInfo->device_name, sg_device_name, MAX_SIZE_OF_DEVICE_NAME);//get dev name
#ifdef DEV_DYN_REG_ENABLED
ret |= device_info_copy(devInfo->product_secret, sg_product_secret, MAX_SIZE_OF_PRODUCT_SECRET );//get product ID
ret |= device_info_copy(devInfo->product_secret, sg_product_secret, MAX_SIZE_OF_PRODUCT_SECRET );//get product ID
#endif
#ifdef AUTH_MODE_CERT
ret |= device_info_copy(devInfo->dev_cert_file_name, sg_device_cert_file_name, MAX_SIZE_OF_DEVICE_CERT_FILE_NAME);//get dev cert file name
ret |= device_info_copy(devInfo->dev_key_file_name, sg_device_privatekey_file_name, MAX_SIZE_OF_DEVICE_SECRET_FILE_NAME);//get dev key file name
ret |= device_info_copy(devInfo->dev_cert_file_name, sg_device_cert_file_name, MAX_SIZE_OF_DEVICE_CERT_FILE_NAME);//get dev cert file name
ret |= device_info_copy(devInfo->dev_key_file_name, sg_device_privatekey_file_name, MAX_SIZE_OF_DEVICE_SECRET_FILE_NAME);//get dev key file name
#else
ret |= device_info_copy(devInfo->device_secret, sg_device_secret, MAX_SIZE_OF_DEVICE_SECRET);//get dev secret
ret |= device_info_copy(devInfo->device_secret, sg_device_secret, MAX_SIZE_OF_DEVICE_SECRET);//get dev secret
#endif
#else
Log_e("HAL_GetDevInfo not implement yet");
ret = QCLOUD_ERR_DEV_INFO;
Log_e("HAL_GetDevInfo not implement yet");
ret = QCLOUD_ERR_DEV_INFO;
#endif
if(QCLOUD_RET_SUCCESS != ret){
Log_e("Get device info err");
ret = QCLOUD_ERR_DEV_INFO;
}
return ret;
if(QCLOUD_RET_SUCCESS != ret){
Log_e("Get device info err");
ret = QCLOUD_ERR_DEV_INFO;
}
return ret;
}
#ifdef GATEWAY_ENABLED
int HAL_GetGwDevInfo(void *pgwDeviceInfo)
{
POINTER_SANITY_CHECK(pgwDeviceInfo, QCLOUD_ERR_DEV_INFO);
int ret;
GatewayDeviceInfo *gwDevInfo = (GatewayDeviceInfo *)pgwDeviceInfo;
memset((char *)gwDevInfo, 0, sizeof(GatewayDeviceInfo));
POINTER_SANITY_CHECK(pgwDeviceInfo, QCLOUD_ERR_DEV_INFO);
int ret;
GatewayDeviceInfo *gwDevInfo = (GatewayDeviceInfo *)pgwDeviceInfo;
memset((char *)gwDevInfo, 0, sizeof(GatewayDeviceInfo));
#ifdef DEBUG_DEV_INFO_USED
ret = HAL_GetDevInfo(&(gwDevInfo->gw_info));//get gw dev info
//only one sub-device is supported now
gwDevInfo->sub_dev_num = 1;
//copy sub dev info
ret = device_info_copy(gwDevInfo->sub_dev_info[0].product_id, sg_sub_device_product_id, MAX_SIZE_OF_PRODUCT_ID);
ret |= device_info_copy(gwDevInfo->sub_dev_info[0].device_name, sg_sub_device_name, MAX_SIZE_OF_DEVICE_NAME);
ret = HAL_GetDevInfo(&(gwDevInfo->gw_info));//get gw dev info
//only one sub-device is supported now
gwDevInfo->sub_dev_num = 1;
//copy sub dev info
ret = device_info_copy(gwDevInfo->sub_dev_info[0].product_id, sg_sub_device_product_id, MAX_SIZE_OF_PRODUCT_ID);
ret |= device_info_copy(gwDevInfo->sub_dev_info[0].device_name, sg_sub_device_name, MAX_SIZE_OF_DEVICE_NAME);
#else
Log_e("HAL_GetGwDevInfo from json not implement yet");
ret = QCLOUD_ERR_DEV_INFO;
Log_e("HAL_GetGwDevInfo from json not implement yet");
ret = QCLOUD_ERR_DEV_INFO;
#endif
if(QCLOUD_RET_SUCCESS != ret) {
Log_e("Get gateway device info err");
ret = QCLOUD_ERR_DEV_INFO;
}
return ret;
if(QCLOUD_RET_SUCCESS != ret) {
Log_e("Get gateway device info err");
ret = QCLOUD_ERR_DEV_INFO;
}
return ret;
}
#endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册