Commit ae347f12 authored by 黄振令's avatar 黄振令

【修改内容】1. 增加nanomsg 测试通道是否建立成功;2. 添加topo接口和列表发现接口;3. 添加接口 topic获取mac地址接口

【提交人】黄振令
parent 01a7f4bb
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
#define APP2MID "ipc:///tmp/app2mid.ipc" #define APP2MID "ipc:///tmp/app2mid.ipc"
#define PLAT2MID "ipc:///tmp/plat2mid.ipc" #define PLAT2MID "ipc:///tmp/plat2mid.ipc"
#define MAGIC "magic12"
typedef struct { typedef struct {
int n;//nanomsg socket int n;//nanomsg socket
...@@ -14,6 +16,7 @@ typedef struct { ...@@ -14,6 +16,7 @@ typedef struct {
struct ev_io watcher; struct ev_io watcher;
ipc_cb* cb; ipc_cb* cb;
ipc_type type; ipc_type type;
int isconnect;
}Bloop_ctrl_t; }Bloop_ctrl_t;
Bloop_ctrl_t Bloop_ctrl; Bloop_ctrl_t Bloop_ctrl;
...@@ -37,6 +40,16 @@ static void watcher_cb (struct ev_loop *loop ,struct ev_io *w, int revents) ...@@ -37,6 +40,16 @@ static void watcher_cb (struct ev_loop *loop ,struct ev_io *w, int revents)
return; return;
} }
printf("watcher_cb:%s recived\r\n\r\n", (char *)dat); printf("watcher_cb:%s recived\r\n\r\n", (char *)dat);
//for test ipc connect or not
if (loop_ctrl->isconnect == 0 ){
loop_ctrl->isconnect =1;
if (strncmp(dat,MAGIC, strlen(MAGIC)) == 0){
kk_ipc_send(loop_ctrl->type, dat, bytes);
nn_freemsg(dat);
return;
}
}
if (loop_ctrl->cb != NULL){ if (loop_ctrl->cb != NULL){
loop_ctrl->cb((void *)dat, bytes); loop_ctrl->cb((void *)dat, bytes);
} }
...@@ -202,3 +215,28 @@ int kk_ipc_send(ipc_type type, void* data, int len) ...@@ -202,3 +215,28 @@ int kk_ipc_send(ipc_type type, void* data, int len)
return 0; return 0;
} }
int kk_ipc_isconnect(ipc_type type){
Bloop_ctrl_t* loop_ctrl;
if (IPC_MID2PLAT == type){
loop_ctrl = &Mloop_ctrl;
}else {
loop_ctrl = &Bloop_ctrl;
}
if (loop_ctrl->isconnect == 1){
return 1;
}else{
for(int i =0; i<20;i++){
kk_ipc_send(type, MAGIC, strlen(MAGIC)+1);
usleep(500000);
if (loop_ctrl->isconnect == 1){
break;
}
}
return loop_ctrl->isconnect;
}
}
...@@ -262,6 +262,56 @@ int dm_mgr_search_device_by_pkdn(_IN_ char product_key[PRODUCT_KEY_MAXLEN], _IN_ ...@@ -262,6 +262,56 @@ int dm_mgr_search_device_by_pkdn(_IN_ char product_key[PRODUCT_KEY_MAXLEN], _IN_
return SUCCESS_RETURN; return SUCCESS_RETURN;
} }
int dm_mgr_search_mac_by_topic(_IN_ char* topic, _OU_ char mac[DEVICE_MAC_MAXLEN])
{
int res = 0;
dm_mgr_dev_node_t *node = NULL;
char product_key[PRODUCT_KEY_MAXLEN];
char device_name[DEVICE_NAME_MAXLEN];
if (topic == NULL) {
return INVALID_PARAMETER;
}
res =kk_msg_uri_parse_pkdn((char *)topic, strlen(topic), 2 + KK_URI_OFFSET, 4 + KK_URI_OFFSET, product_key,
device_name);
if (res != SUCCESS_RETURN) {
return FAIL_RETURN;
}
res = _dm_mgr_search_dev_by_pkdn(product_key, device_name, &node);
if (res != SUCCESS_RETURN) {
return FAIL_RETURN;
}
memcpy(mac, node->device_mac, DEVICE_MAC_MAXLEN);
return SUCCESS_RETURN;
}
int dm_mgr_search_mac_by_pkdn(_IN_ char product_key[PRODUCT_KEY_MAXLEN], _IN_ char device_name[DEVICE_NAME_MAXLEN],
_OU_ char mac[DEVICE_MAC_MAXLEN])
{
int res = 0;
dm_mgr_dev_node_t *node = NULL;
if (product_key == NULL || device_name == NULL) {
return INVALID_PARAMETER;
}
res = _dm_mgr_search_dev_by_pkdn(product_key, device_name, &node);
if (res != SUCCESS_RETURN) {
return FAIL_RETURN;
}
memcpy(mac, node->device_mac, DEVICE_MAC_MAXLEN);
return SUCCESS_RETURN;
}
int dm_mgr_get_device_by_mac(_IN_ char device_mac[DEVICE_MAC_MAXLEN], _OU_ dm_mgr_dev_node_t **node) int dm_mgr_get_device_by_mac(_IN_ char device_mac[DEVICE_MAC_MAXLEN], _OU_ dm_mgr_dev_node_t **node)
{ {
dm_mgr_ctx *ctx = _dm_mgr_get_ctx(); dm_mgr_ctx *ctx = _dm_mgr_get_ctx();
...@@ -281,6 +331,7 @@ int dm_mgr_get_device_by_mac(_IN_ char device_mac[DEVICE_MAC_MAXLEN], _OU_ dm_mg ...@@ -281,6 +331,7 @@ int dm_mgr_get_device_by_mac(_IN_ char device_mac[DEVICE_MAC_MAXLEN], _OU_ dm_mg
printf("Device Not Found, device_mac: %s\n", device_mac); printf("Device Not Found, device_mac: %s\n", device_mac);
return FAIL_RETURN; return FAIL_RETURN;
} }
int dm_mgr_get_devId_by_mac(_IN_ char device_mac[DEVICE_MAC_MAXLEN],_OU_ int *devid) int dm_mgr_get_devId_by_mac(_IN_ char device_mac[DEVICE_MAC_MAXLEN],_OU_ int *devid)
{ {
int res = 0; int res = 0;
...@@ -331,7 +382,7 @@ int dm_mgr_init(void) ...@@ -331,7 +382,7 @@ int dm_mgr_init(void)
//memcpy(device_name,"aIqEbWno8yDdsjCX15iq",strlen("aIqEbWno8yDdsjCX15iq")); //memcpy(device_name,"aIqEbWno8yDdsjCX15iq",strlen("aIqEbWno8yDdsjCX15iq"));
//_dm_mgr_legacy_thing_created(IOTX_DM_LOCAL_NODE_DEVID); //_dm_mgr_legacy_thing_created(IOTX_DM_LOCAL_NODE_DEVID);
res = dm_mgr_device_create(KK_DM_DEVICE_GATEWAY,product_key,device_name,device_secret,NULL,&devId); res = dm_mgr_device_create(KK_DM_DEVICE_GATEWAY,product_key,device_name,device_secret,"aabbccddeeff1120",&devId);
if (res != SUCCESS_RETURN) { if (res != SUCCESS_RETURN) {
goto ERROR; goto ERROR;
} }
...@@ -668,15 +719,14 @@ int dm_mgr_upstream_thing_topo_add(_IN_ int devid) ...@@ -668,15 +719,14 @@ int dm_mgr_upstream_thing_topo_add(_IN_ int devid)
return res; return res;
} }
int dm_mgr_upstream_thing_topo_delete(_IN_ int devid)
int dm_mgr_upstream_combine_login(_IN_ int devid)
{ {
int res = 0; int res = 0;
dm_mgr_dev_node_t *node = NULL; dm_mgr_dev_node_t *node = NULL;
dm_msg_request_t request; dm_msg_request_t request;
if (devid < 0) { if (devid < 0) {
return INVALID_PARAMETER; return DM_INVALID_PARAMETER;
} }
res = dm_mgr_search_dev_by_devid(devid, &node); res = dm_mgr_search_dev_by_devid(devid, &node);
...@@ -685,13 +735,13 @@ int dm_mgr_upstream_combine_login(_IN_ int devid) ...@@ -685,13 +735,13 @@ int dm_mgr_upstream_combine_login(_IN_ int devid)
} }
memset(&request, 0, sizeof(dm_msg_request_t)); memset(&request, 0, sizeof(dm_msg_request_t));
request.service_prefix = DM_URI_EXT_SESSION_PREFIX; request.service_prefix = DM_URI_SYS_PREFIX;
request.service_name = DM_URI_COMBINE_LOGIN; request.service_name = DM_URI_THING_TOPO_DELETE;
HAL_GetProduct_Type(request.product_key); HAL_GetProduct_Type(request.product_key);
HAL_GetProduct_Code(request.device_name); HAL_GetProduct_Code(request.device_name);
/* Get Params And Method */ /* Get Params And Method */
res = dm_msg_combine_login(node->product_key, node->device_name, node->device_secret, &request); res = dm_msg_thing_topo_delete(node->product_key, node->device_name, &request);
if (res != SUCCESS_RETURN) { if (res != SUCCESS_RETURN) {
return FAIL_RETURN; return FAIL_RETURN;
} }
...@@ -703,7 +753,7 @@ int dm_mgr_upstream_combine_login(_IN_ int devid) ...@@ -703,7 +753,7 @@ int dm_mgr_upstream_combine_login(_IN_ int devid)
request.devid = devid; request.devid = devid;
/* Callback */ /* Callback */
//request.callback = dm_client_combine_login_reply; //request.callback = dm_client_thing_topo_delete_reply;
/* Send Message To Cloud */ /* Send Message To Cloud */
...@@ -717,7 +767,49 @@ int dm_mgr_upstream_combine_login(_IN_ int devid) ...@@ -717,7 +767,49 @@ int dm_mgr_upstream_combine_login(_IN_ int devid)
return res; return res;
} }
int dm_mgr_upstream_combine_logout(_IN_ int devid) int dm_mgr_upstream_thing_topo_get(void)
{
int res = 0;
dm_mgr_dev_node_t *node = NULL;
dm_msg_request_t request;
memset(&request, 0, sizeof(dm_msg_request_t));
request.service_prefix = DM_URI_SYS_PREFIX;
request.service_name = DM_URI_THING_TOPO_GET;
HAL_GetProduct_Type(request.product_key);
HAL_GetProduct_Code(request.device_name);
res = _dm_mgr_search_dev_by_pkdn(request.product_key, request.device_name, &node);
if (res != SUCCESS_RETURN) {
return FAIL_RETURN;
}
/* Get Params And Method */
res = dm_msg_thing_topo_get(&request);
if (res != SUCCESS_RETURN) {
return FAIL_RETURN;
}
/* Get Msg ID */
request.msgid = iotx_report_id();
/* Get Dev ID */
request.devid = node->devid;
/* Callback */
//request.callback = dm_client_thing_topo_get_reply;
/* Send Message To Cloud */
res = dm_msg_request(&request);
if (res == SUCCESS_RETURN) {
res = request.msgid;
}
free(request.params);
return res;
}
int dm_mgr_upstream_thing_list_found(_IN_ int devid)
{ {
int res = 0; int res = 0;
dm_mgr_dev_node_t *node = NULL; dm_mgr_dev_node_t *node = NULL;
...@@ -733,13 +825,13 @@ int dm_mgr_upstream_combine_logout(_IN_ int devid) ...@@ -733,13 +825,13 @@ int dm_mgr_upstream_combine_logout(_IN_ int devid)
} }
memset(&request, 0, sizeof(dm_msg_request_t)); memset(&request, 0, sizeof(dm_msg_request_t));
request.service_prefix = DM_URI_EXT_SESSION_PREFIX; request.service_prefix = DM_URI_SYS_PREFIX;
request.service_name = DM_URI_COMBINE_LOGOUT; request.service_name = DM_URI_THING_LIST_FOUND;
HAL_GetProduct_Type(request.product_key); HAL_GetProduct_Type(request.product_key);
HAL_GetProduct_Code(request.device_name); HAL_GetProduct_Code(request.device_name);
/* Get Params And Method */ /* Get Params And Method */
res = dm_msg_combine_logout(node->product_key, node->device_name, &request); res = dm_msg_thing_list_found(node->product_key, node->device_name, &request);
if (res != SUCCESS_RETURN) { if (res != SUCCESS_RETURN) {
return FAIL_RETURN; return FAIL_RETURN;
} }
...@@ -751,9 +843,55 @@ int dm_mgr_upstream_combine_logout(_IN_ int devid) ...@@ -751,9 +843,55 @@ int dm_mgr_upstream_combine_logout(_IN_ int devid)
request.devid = devid; request.devid = devid;
/* Callback */ /* Callback */
//request.callback = dm_client_combine_logout_reply; //request.callback = dm_client_thing_list_found_reply;
/* Send Message To Cloud */ /* Send Message To Cloud */
res = dm_msg_request(&request);
if (res == SUCCESS_RETURN) {
res = request.msgid;
}
free(request.params);
return res;
}
int dm_mgr_upstream_combine_login(_IN_ int devid)
{
int res = 0;
dm_mgr_dev_node_t *node = NULL;
dm_msg_request_t request;
if (devid < 0) {
return INVALID_PARAMETER;
}
res = dm_mgr_search_dev_by_devid(devid, &node);
if (res != SUCCESS_RETURN) {
return FAIL_RETURN;
}
memset(&request, 0, sizeof(dm_msg_request_t));
request.service_prefix = DM_URI_EXT_SESSION_PREFIX;
request.service_name = DM_URI_COMBINE_LOGIN;
HAL_GetProduct_Type(request.product_key);
HAL_GetProduct_Code(request.device_name);
/* Get Params And Method */
res = dm_msg_combine_login(node->product_key, node->device_name, node->device_secret, &request);
if (res != SUCCESS_RETURN) {
return FAIL_RETURN;
}
/* Get Msg ID */
request.msgid = iotx_report_id();
/* Get Dev ID */
request.devid = devid;
/* Callback */
//request.callback = dm_client_combine_login_reply;
/* Send Message To Cloud */ /* Send Message To Cloud */
res = dm_msg_request(&request); res = dm_msg_request(&request);
...@@ -766,7 +904,7 @@ int dm_mgr_upstream_combine_logout(_IN_ int devid) ...@@ -766,7 +904,7 @@ int dm_mgr_upstream_combine_logout(_IN_ int devid)
return res; return res;
} }
int dm_mgr_upstream_thing_topo_delete(_IN_ int devid) int dm_mgr_upstream_combine_logout(_IN_ int devid)
{ {
int res = 0; int res = 0;
dm_mgr_dev_node_t *node = NULL; dm_mgr_dev_node_t *node = NULL;
...@@ -782,13 +920,13 @@ int dm_mgr_upstream_thing_topo_delete(_IN_ int devid) ...@@ -782,13 +920,13 @@ int dm_mgr_upstream_thing_topo_delete(_IN_ int devid)
} }
memset(&request, 0, sizeof(dm_msg_request_t)); memset(&request, 0, sizeof(dm_msg_request_t));
request.service_prefix = DM_URI_SYS_PREFIX; request.service_prefix = DM_URI_EXT_SESSION_PREFIX;
request.service_name = DM_URI_THING_TOPO_DELETE; request.service_name = DM_URI_COMBINE_LOGOUT;
HAL_GetProduct_Type(request.product_key); HAL_GetProduct_Type(request.product_key);
HAL_GetProduct_Code(request.device_name); HAL_GetProduct_Code(request.device_name);
/* Get Params And Method */ /* Get Params And Method */
res = dm_msg_thing_topo_delete(node->product_key, node->device_name, &request); res = dm_msg_combine_logout(node->product_key, node->device_name, &request);
if (res != SUCCESS_RETURN) { if (res != SUCCESS_RETURN) {
return FAIL_RETURN; return FAIL_RETURN;
} }
...@@ -800,8 +938,9 @@ int dm_mgr_upstream_thing_topo_delete(_IN_ int devid) ...@@ -800,8 +938,9 @@ int dm_mgr_upstream_thing_topo_delete(_IN_ int devid)
request.devid = devid; request.devid = devid;
/* Callback */ /* Callback */
//request.callback = dm_client_thing_topo_delete_reply; //request.callback = dm_client_combine_logout_reply;
/* Send Message To Cloud */
/* Send Message To Cloud */ /* Send Message To Cloud */
res = dm_msg_request(&request); res = dm_msg_request(&request);
......
...@@ -183,6 +183,96 @@ int dm_msg_thing_topo_add(_IN_ char product_key[PRODUCT_KEY_MAXLEN], ...@@ -183,6 +183,96 @@ int dm_msg_thing_topo_add(_IN_ char product_key[PRODUCT_KEY_MAXLEN],
return SUCCESS_RETURN; return SUCCESS_RETURN;
} }
const char DM_MSG_THING_TOPO_DELETE_METHOD[] DM_READ_ONLY = "thing.topo.delete";
const char DM_MSG_THING_TOPO_DELETE_PARAMS[] DM_READ_ONLY = "[{\"productKey\":\"%s\",\"deviceName\":\"%s\"}]";
int dm_msg_thing_topo_delete(_IN_ char product_key[PRODUCT_KEY_MAXLEN],
_IN_ char device_name[DEVICE_NAME_MAXLEN],
_OU_ dm_msg_request_t *request)
{
char *params = NULL;
int params_len = 0;
if (request == NULL || product_key == NULL ||
device_name == NULL ||
(strlen(product_key) >= PRODUCT_KEY_MAXLEN) ||
(strlen(device_name) >= DEVICE_NAME_MAXLEN) ||
(strlen(request->product_key) >= PRODUCT_KEY_MAXLEN) ||
(strlen(request->device_name) >= DEVICE_NAME_MAXLEN)) {
return INVALID_PARAMETER;
}
/* Params */
request->method = (char *)DM_MSG_THING_TOPO_DELETE_METHOD;
params_len = strlen(DM_MSG_THING_TOPO_DELETE_PARAMS) + strlen(product_key) + strlen(device_name) + 1;
params = malloc(params_len);
if (params == NULL) {
return MEMORY_NOT_ENOUGH;
}
memset(params, 0, params_len);
HAL_Snprintf(params, params_len, DM_MSG_THING_TOPO_DELETE_PARAMS, product_key, device_name);
request->params = params;
request->params_len = strlen(request->params);
return SUCCESS_RETURN;
}
const char DM_MSG_THING_TOPO_GET_METHOD[] DM_READ_ONLY = "thing.topo.get";
const char DM_MSG_THING_TOPO_GET_PARAMS[] DM_READ_ONLY = "{}";
int dm_msg_thing_topo_get(_OU_ dm_msg_request_t *request)
{
char *params = NULL;
int params_len = 0;
/* Params */
request->method = (char *)DM_MSG_THING_TOPO_GET_METHOD;
params_len = strlen(DM_MSG_THING_TOPO_GET_PARAMS) + 1;
params = malloc(params_len);
if (params == NULL) {
return MEMORY_NOT_ENOUGH;
}
memset(params, 0, params_len);
memcpy(params, DM_MSG_THING_TOPO_GET_PARAMS, strlen(DM_MSG_THING_TOPO_GET_PARAMS));
request->params = params;
request->params_len = strlen(request->params);
return SUCCESS_RETURN;
}
const char DM_MSG_THING_LIST_FOUND_METHOD[] DM_READ_ONLY = "thing.list.found";
const char DM_MSG_THING_LIST_FOUND_PARAMS[] DM_READ_ONLY = "[{\"productKey\":\"%s\",\"deviceName\":\"%s\"}]";
int dm_msg_thing_list_found(_IN_ char product_key[PRODUCT_KEY_MAXLEN],
_IN_ char device_name[DEVICE_NAME_MAXLEN],
_OU_ dm_msg_request_t *request)
{
char *params = NULL;
int params_len = 0;
if (product_key == NULL || device_name == NULL ||
(strlen(product_key) >= PRODUCT_KEY_MAXLEN) ||
(strlen(device_name) >= DEVICE_NAME_MAXLEN) ||
request == NULL) {
return INVALID_PARAMETER;
}
/* Params */
request->method = (char *)DM_MSG_THING_LIST_FOUND_METHOD;
params_len = strlen(DM_MSG_THING_LIST_FOUND_PARAMS) + strlen(product_key) + strlen(device_name) + 1;
params = malloc(params_len);
if (params == NULL) {
return MEMORY_NOT_ENOUGH;
}
memset(params, 0, params_len);
HAL_Snprintf(params, params_len, DM_MSG_THING_LIST_FOUND_PARAMS, product_key, device_name);
request->params = params;
request->params_len = strlen(request->params);
return SUCCESS_RETURN;
}
const char DM_MSG_COMBINE_LOGIN_SIGN_SOURCE[] DM_READ_ONLY = "clientId%sdeviceName%sproductKey%stimestamp%s"; const char DM_MSG_COMBINE_LOGIN_SIGN_SOURCE[] DM_READ_ONLY = "clientId%sdeviceName%sproductKey%stimestamp%s";
const char DM_MSG_COMBINE_LOGIN_METHOD[] DM_READ_ONLY = "combine.login"; const char DM_MSG_COMBINE_LOGIN_METHOD[] DM_READ_ONLY = "combine.login";
const char DM_MSG_COMBINE_LOGIN_PARAMS[] DM_READ_ONLY = const char DM_MSG_COMBINE_LOGIN_PARAMS[] DM_READ_ONLY =
...@@ -302,41 +392,6 @@ int dm_msg_combine_logout(_IN_ char product_key[PRODUCT_KEY_MAXLEN], ...@@ -302,41 +392,6 @@ int dm_msg_combine_logout(_IN_ char product_key[PRODUCT_KEY_MAXLEN],
} }
const char DM_MSG_THING_TOPO_DELETE_METHOD[] DM_READ_ONLY = "thing.topo.delete";
const char DM_MSG_THING_TOPO_DELETE_PARAMS[] DM_READ_ONLY = "[{\"productKey\":\"%s\",\"deviceName\":\"%s\"}]";
int dm_msg_thing_topo_delete(_IN_ char product_key[PRODUCT_KEY_MAXLEN],
_IN_ char device_name[DEVICE_NAME_MAXLEN],
_OU_ dm_msg_request_t *request)
{
char *params = NULL;
int params_len = 0;
if (request == NULL || product_key == NULL ||
device_name == NULL ||
(strlen(product_key) >= PRODUCT_KEY_MAXLEN) ||
(strlen(device_name) >= DEVICE_NAME_MAXLEN) ||
(strlen(request->product_key) >= PRODUCT_KEY_MAXLEN) ||
(strlen(request->device_name) >= DEVICE_NAME_MAXLEN)) {
return INVALID_PARAMETER;
}
/* Params */
request->method = (char *)DM_MSG_THING_TOPO_DELETE_METHOD;
params_len = strlen(DM_MSG_THING_TOPO_DELETE_PARAMS) + strlen(product_key) + strlen(device_name) + 1;
params = malloc(params_len);
if (params == NULL) {
return MEMORY_NOT_ENOUGH;
}
memset(params, 0, params_len);
HAL_Snprintf(params, params_len, DM_MSG_THING_TOPO_DELETE_PARAMS, product_key, device_name);
request->params = params;
request->params_len = strlen(request->params);
return SUCCESS_RETURN;
}
int dm_msg_request (_IN_ dm_msg_request_t *request) int dm_msg_request (_IN_ dm_msg_request_t *request)
{ {
......
...@@ -22,6 +22,7 @@ void mid_cb(void* data, int len){ ...@@ -22,6 +22,7 @@ void mid_cb(void* data, int len){
if (data != NULL){ if (data != NULL){
printf("app2mid_cb: %s RECEIVED \r\n", data); printf("app2mid_cb: %s RECEIVED \r\n", data);
char *out;cJSON *json, *topic, *payload; char *out;cJSON *json, *topic, *payload;
int res;
json=cJSON_Parse(data); json=cJSON_Parse(data);
if (!json) { if (!json) {
...@@ -40,13 +41,20 @@ void mid_cb(void* data, int len){ ...@@ -40,13 +41,20 @@ void mid_cb(void* data, int len){
int res = dm_queue_msg_insert((void *)buf); int res = dm_queue_msg_insert((void *)buf);
if (res != SUCCESS_RETURN) { if (res != SUCCESS_RETURN) {
free(buf); free(buf);
return FAIL_RETURN; //return FAIL_RETURN;
} }
//kk_tsl_service_property_set(topic->valuestring, payload->valuestring, strlen(payload->valuestring), NULL); //kk_tsl_service_property_set(topic->valuestring, payload->valuestring, strlen(payload->valuestring), NULL);
} }
char mac[DEVICE_MAC_MAXLEN];
res =dm_mgr_search_mac_by_topic(topic->valuestring, mac);
if (res != SUCCESS_RETURN) {
return;
}
printf("dm_mgr_search_mac_by_topic mac: %s \r\n", mac);
cJSON * jsonplay=cJSON_Parse(payload->valuestring); cJSON * jsonplay=cJSON_Parse(payload->valuestring);
cJSON_AddStringToObject(jsonplay, "mac", "aabbccddee11"); cJSON_AddStringToObject(jsonplay, "mac", mac);
void* out = cJSON_Print(jsonplay); void* out = cJSON_Print(jsonplay);
kk_ipc_send(IPC_MID2PLAT, out, strlen(out)); kk_ipc_send(IPC_MID2PLAT, out, strlen(out));
free(out); free(out);
...@@ -104,6 +112,10 @@ void kk_platMsg_handle(void* data){ ...@@ -104,6 +112,10 @@ void kk_platMsg_handle(void* data){
} }
}else if (method != NULL && strcmp(method->valuestring, "thing.event.property.post")==0){ }else if (method != NULL && strcmp(method->valuestring, "thing.event.property.post")==0){
cJSON *mac;
mac = cJSON_GetObjectItem(json, "mac");
//kk_tsl_service_property_set(topic->valuestring, data, strlen(data), NULL); //kk_tsl_service_property_set(topic->valuestring, data, strlen(data), NULL);
}else{ }else{
...@@ -245,7 +257,6 @@ int main(const int argc, const char **argv) ...@@ -245,7 +257,6 @@ int main(const int argc, const char **argv)
kk_ipc_init(IPC_MID2PLAT, mid2p_cb); kk_ipc_init(IPC_MID2PLAT, mid2p_cb);
dm_mgr_init(); dm_mgr_init();
//DB_Init(); //DB_Init();
//test_tcp(); //test_tcp();
/* when Connect to app and platfrom */ /* when Connect to app and platfrom */
......
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