Commit b6d1208b authored by chen.weican's avatar chen.weican

【修改内容】调整OTA的publish topic的处理,调整到APP层处理

【提交人】陈伟灿
parent 329075f9
...@@ -21,6 +21,7 @@ const char DM_URI_THING_EVENT_POST[] = "thing/event/%.*s/post"; ...@@ -21,6 +21,7 @@ const char DM_URI_THING_EVENT_POST[] = "thing/event/%.*s/post";
const char DM_URI_THING_SERVICE_RESPONSE[] = "thing/service/%.*s_reply"; const char DM_URI_THING_SERVICE_RESPONSE[] = "thing/service/%.*s_reply";
const char DM_URI_THING_SERVICE_PROPERTY_SET_REPLY[] = "thing/service/property/set_reply"; const char DM_URI_THING_SERVICE_PROPERTY_SET_REPLY[] = "thing/service/property/set_reply";
const char KK_URI_OTA_PREFIX[] = "/ota/device/upgrade/%s/%s/#"; const char KK_URI_OTA_PREFIX[] = "/ota/device/upgrade/%s/%s/#";
const char KK_URI_OTA_PROCESS[] = "/ota/device/progress/%s/%s";
int KK_Subdev_Subscribe(const cJSON *root) int KK_Subdev_Subscribe(const cJSON *root)
...@@ -218,7 +219,10 @@ char* KK_Make_Topic(cJSON *info) ...@@ -218,7 +219,10 @@ char* KK_Make_Topic(cJSON *info)
break; break;
case MSG_SETREPLY: case MSG_SETREPLY:
_kk_utils_topic(DM_URI_THING_SERVICE_PROPERTY_SET_REPLY,product_type->valuestring,device_name->valuestring,&topic); _kk_utils_topic(DM_URI_THING_SERVICE_PROPERTY_SET_REPLY,product_type->valuestring,device_name->valuestring,&topic);
break; break;
case MSG_OTA:
_kk_utils_topic(KK_URI_OTA_PROCESS,product_type->valuestring,device_name->valuestring,&topic);
break;
} }
printf("[%s][%d] TOPIC:%s\n",__FUNCTION__,__LINE__,topic); printf("[%s][%d] TOPIC:%s\n",__FUNCTION__,__LINE__,topic);
......
...@@ -40,6 +40,7 @@ typedef enum{ ...@@ -40,6 +40,7 @@ typedef enum{
MSG_EVENTPOST, MSG_EVENTPOST,
MSG_SERVICERESPONSE, MSG_SERVICERESPONSE,
MSG_SETREPLY, MSG_SETREPLY,
MSG_OTA,
}kk_msg_type_t; }kk_msg_type_t;
typedef void ipc_cb(void* data, int len); typedef void ipc_cb(void* data, int len);
......
...@@ -15,6 +15,7 @@ const char DM_URI_EXT_NTP_PREFIX[] DM_READ_ONLY = "/ext/ntp/% ...@@ -15,6 +15,7 @@ const char DM_URI_EXT_NTP_PREFIX[] DM_READ_ONLY = "/ext/ntp/%
const char DM_URI_EXT_ERROR_PREFIX[] DM_READ_ONLY = "/ext/error/%s/%s"; const char DM_URI_EXT_ERROR_PREFIX[] DM_READ_ONLY = "/ext/error/%s/%s";
const char DM_URI_REPLY_SUFFIX[] DM_READ_ONLY = "_reply"; const char DM_URI_REPLY_SUFFIX[] DM_READ_ONLY = "_reply";
const char DM_URI_OTA_DEVICE_INFORM[] DM_READ_ONLY = "/ota/device/inform/%s/%s"; const char DM_URI_OTA_DEVICE_INFORM[] DM_READ_ONLY = "/ota/device/inform/%s/%s";
const char DM_URI_THING_EVENT_PROPERTY_POST_METHOD[] DM_READ_ONLY = "thing.event.property.post";
static dm_mgr_ctx g_dm_mgr = {0}; static dm_mgr_ctx g_dm_mgr = {0};
......
...@@ -7,14 +7,6 @@ ...@@ -7,14 +7,6 @@
#include "com_api.h" #include "com_api.h"
const char DM_URI_SYS_PREFIX[] DM_READ_ONLY = "/sys/%s/%s/";
const char DM_URI_THING_EVENT_PROPERTY_POST[] DM_READ_ONLY = "thing/event/property/post";
const char DM_URI_THING_SERVICE_PROPERTY_SET_REPLY[] DM_READ_ONLY = "thing/service/property/set_reply";
const char DM_URI_THING_EVENT_POST[] DM_READ_ONLY = "thing/event/%.*s/post";
const char DM_URI_THING_SERVICE_RESPONSE[] DM_READ_ONLY = "thing/service/%.*s_reply";
const char DM_URI_THING_EVENT_PROPERTY_POST_METHOD[] DM_READ_ONLY = "thing.event.property.post";
const char DM_MSG_REQUEST[] DM_READ_ONLY = "{\"msgId\":\"%d\",\"version\":\"%s\",\"params\":%.*s,\"method\":\"%s\"}"; const char DM_MSG_REQUEST[] DM_READ_ONLY = "{\"msgId\":\"%d\",\"version\":\"%s\",\"params\":%.*s,\"method\":\"%s\"}";
const char DM_MSG_INFO[] DM_READ_ONLY = "{\"msgtype\":\"%d\",\"product_type\":\"%s\",\"device_name\":\"%s\",\"identifier\":\"%s\"}"; const char DM_MSG_INFO[] DM_READ_ONLY = "{\"msgtype\":\"%d\",\"product_type\":\"%s\",\"device_name\":\"%s\",\"identifier\":\"%s\"}";
......
...@@ -39,13 +39,8 @@ typedef struct { ...@@ -39,13 +39,8 @@ typedef struct {
#define DM_READ_ONLY #define DM_READ_ONLY
#endif #endif
#define DM_MSG_VERSION "1.0" #define DM_MSG_VERSION "1.0"
const char DM_MSG_INFO[] DM_READ_ONLY;
extern const char DM_URI_SYS_PREFIX[] DM_READ_ONLY;
extern const char DM_URI_THING_EVENT_PROPERTY_POST[] DM_READ_ONLY;
const char DM_URI_THING_SERVICE_PROPERTY_SET_REPLY[] DM_READ_ONLY;
const char DM_URI_THING_EVENT_POST[] DM_READ_ONLY;
const char DM_URI_THING_SERVICE_RESPONSE[] DM_READ_ONLY;
const char DM_URI_THING_EVENT_PROPERTY_POST_METHOD[] DM_READ_ONLY;
//const char DM_URI_SYS_PREFIX[] DM_READ_ONLY = "/sys/%s/%s/"; //const char DM_URI_SYS_PREFIX[] DM_READ_ONLY = "/sys/%s/%s/";
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "iotx_ota_internal.h" #include "iotx_ota_internal.h"
#include "com_api.h" #include "com_api.h"
#include "cJSON.h" #include "cJSON.h"
#include "kk_dm_msg.h"
/*#if (OTA_SIGNAL_CHANNEL) == 1 /*#if (OTA_SIGNAL_CHANNEL) == 1
...@@ -514,23 +515,29 @@ do_exit: ...@@ -514,23 +515,29 @@ do_exit:
int OTA_publishProgress(void *handle, char* payload){ int OTA_publishProgress(void *handle, char* payload){
OTA_Struct_pt h_ota = (OTA_Struct_pt) handle; OTA_Struct_pt h_ota = (OTA_Struct_pt) handle;
if (NULL == handle) { if (NULL == handle) {
OTA_LOG_ERROR("handle is NULL"); OTA_LOG_ERROR("handle is NULL\n");
return IOT_OTAE_INVALID_PARAM; return IOT_OTAE_INVALID_PARAM;
} }
if (NULL == payload) { if (NULL == payload) {
OTA_LOG_ERROR("payload is NULL"); OTA_LOG_ERROR("payload is NULL\n");
return IOT_OTAE_INVALID_PARAM; return IOT_OTAE_INVALID_PARAM;
} }
/* inform OTA to topic: "/ota/device/progress/$(product_key)/$(device_name)" */ /* inform OTA to topic: "/ota/device/progress/$(product_key)/$(device_name)" */
char topictmf[] = "/ota/device/progress/%s/%s"; // int topicLen = strlen(DM_MSG_INFO) + strlen(h_ota->product_key) + strlen(h_ota->device_name) + 1;
int topicLen = strlen(topictmf) + strlen(h_ota->product_key) + strlen(h_ota->device_name) + 1; int topicLen = strlen(DM_MSG_INFO)+10+strlen(h_ota->product_key)+strlen(h_ota->device_name)+1;
char *topicBuf = malloc(topicLen); char *topicBuf = malloc(topicLen);
HAL_Snprintf(topicBuf, topicLen, topictmf,h_ota->product_key, h_ota->device_name); if(topicBuf == NULL){
OTA_LOG_ERROR("MALLOC is NULL\n");
return IOT_OTAE_INVALID_PARAM;
}
HAL_Snprintf(topicBuf, topicLen, DM_MSG_INFO,MSG_OTA,h_ota->product_key, h_ota->device_name,"");
cJSON *root=cJSON_CreateObject(); cJSON *root=cJSON_CreateObject();
cJSON_AddStringToObject(root, "topic", topicBuf); cJSON_AddStringToObject(root, "info", topicBuf);
cJSON_AddStringToObject(root, "payload", payload); cJSON_AddStringToObject(root, "payload", payload);
void *buf = cJSON_Print(root); void *buf = cJSON_Print(root);
kk_ipc_send(IPC_MID2APP, buf, strlen(buf) + 1); kk_ipc_send(IPC_MID2APP, buf, strlen(buf) + 1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment