|
|
@@ -56,7 +56,7 @@ static void InitClientId(void)
|
|
|
{
|
|
|
// 设置clientid
|
|
|
memset(ClientID, 0, sizeof(ClientID));
|
|
|
- strcat(ClientID, regist_response.productId);
|
|
|
+ strcat(ClientID, regist_response.productKey);
|
|
|
strcat(ClientID, "&");
|
|
|
strcat(ClientID, regist_response.deviceId);
|
|
|
}
|
|
|
@@ -113,6 +113,15 @@ uint8_t TUORENIOT_AnalysisRegistData(uint8_t * regist_data, uint16_t regist_data
|
|
|
strcpy(regist_response.remoteAddress, cJSON_GetObjectItem(json, "remoteAddress")->valuestring);
|
|
|
regist_response.remotePort = cJSON_GetObjectItem(json, "remotePort")->valueint;
|
|
|
|
|
|
+ if(regist_response.platform == 1)
|
|
|
+ {
|
|
|
+ strcpy(regist_response.productKey, cJSON_GetObjectItem(json, "productKey")->valuestring);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ strcpy(regist_response.productKey, regist_response.productId);
|
|
|
+ }
|
|
|
+
|
|
|
// 判断是否解析WiFi信息
|
|
|
if(regist_response.networkType == 3)
|
|
|
{
|
|
|
@@ -217,7 +226,7 @@ void TUORENIOT_PackAuthMessage(uint8_t * coap_message, uint16_t * coap_message_l
|
|
|
// 待签名数据
|
|
|
// 签名相关
|
|
|
memset(StrForSignature, 0, sizeof(StrForSignature));
|
|
|
- sprintf(StrForSignature, "clientId%sdeviceName%sproductKey%sseq%d", ClientID, regist_response.deviceId,regist_response.productId, SeqOffset);
|
|
|
+ sprintf(StrForSignature, "clientId%sdeviceName%sproductKey%sseq%d", ClientID, regist_response.deviceId,regist_response.productKey, SeqOffset);
|
|
|
// Log_Printf_Debug("认证报文StrForSignature:\r\n%s\r\n", StrForSignature);
|
|
|
// 签名
|
|
|
memset(sign, 0, sizeof(sign));
|
|
|
@@ -227,7 +236,7 @@ void TUORENIOT_PackAuthMessage(uint8_t * coap_message, uint16_t * coap_message_l
|
|
|
|
|
|
// payload
|
|
|
memset(payload, 0, sizeof(payload));
|
|
|
- sprintf((char * )payload, "{\"clientId\":\"%s\",\"signmethod\":\"hmacsha1\",\"sign\":\"%s\",\"productKey\":\"%s\",\"deviceName\":\"%s\",\"seq\":\"%d\"}", ClientID, sign, regist_response.productId, regist_response.deviceId, SeqOffset);
|
|
|
+ sprintf((char * )payload, "{\"clientId\":\"%s\",\"signmethod\":\"hmacsha1\",\"sign\":\"%s\",\"productKey\":\"%s\",\"deviceName\":\"%s\",\"seq\":\"%d\"}", ClientID, sign, regist_response.productKey, regist_response.deviceId, SeqOffset);
|
|
|
// 设置payload
|
|
|
CoAP_Set_Payload_Str((char *)payload);
|
|
|
|
|
|
@@ -289,7 +298,7 @@ void TUORENIOT_PackDataMessage(uint8_t * data, uint8_t data_length, uint8_t * co
|
|
|
// path
|
|
|
CoAP_Set_Option_Str(11, "topic");
|
|
|
CoAP_Set_Option_Str(11, "sys");
|
|
|
- CoAP_Set_Option_Str(11, regist_response.productId);
|
|
|
+ CoAP_Set_Option_Str(11, regist_response.productKey);
|
|
|
CoAP_Set_Option_Str(11, regist_response.deviceId);
|
|
|
CoAP_Set_Option_Str(11, "thing");
|
|
|
CoAP_Set_Option_Str(11, "model");
|
|
|
@@ -425,6 +434,7 @@ void TUORENIOT_PrintfRegistResponseStruct(void)
|
|
|
Log_Printf("networkType=%d\r\n", regist_response.networkType);
|
|
|
Log_Printf("networkProtocol=%d\r\n", regist_response.networkProtocol);
|
|
|
Log_Printf("productId=%s\r\n", regist_response.productId);
|
|
|
+ Log_Printf("productKey=%s\r\n", regist_response.productKey);
|
|
|
Log_Printf("deviceId=%s\r\n", regist_response.deviceId);
|
|
|
Log_Printf("userId=%s\r\n", regist_response.userId);
|
|
|
Log_Printf("deviceSecret=%s\r\n", regist_response.deviceSecret);
|