Commit 5a794539 authored by 黄振令's avatar 黄振令

【修改内容】1. 根据topic过滤, get 不会把命令传到platform ;2.set 属性midware 做反馈给云端

【提交人】黄振令
parent 01a7f4bb
......@@ -3,6 +3,8 @@
#define APP2MID "ipc:///tmp/app2mid.ipc"
#define PLAT2MID "ipc:///tmp/plat2mid.ipc"
#define MAGIC "magic12"
typedef struct {
int n;//nanomsg socket
......@@ -14,6 +16,7 @@ typedef struct {
struct ev_io watcher;
ipc_cb* cb;
ipc_type type;
int isconnect;
}Bloop_ctrl_t;
Bloop_ctrl_t Bloop_ctrl;
......@@ -37,6 +40,16 @@ static void watcher_cb (struct ev_loop *loop ,struct ev_io *w, int revents)
return;
}
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){
loop_ctrl->cb((void *)dat, bytes);
}
......@@ -202,3 +215,28 @@ int kk_ipc_send(ipc_type type, void* data, int len)
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_
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)
{
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
printf("Device Not Found, device_mac: %s\n", device_mac);
return FAIL_RETURN;
}
int dm_mgr_get_devId_by_mac(_IN_ char device_mac[DEVICE_MAC_MAXLEN],_OU_ int *devid)
{
int res = 0;
......@@ -331,7 +382,7 @@ int dm_mgr_init(void)
//memcpy(device_name,"aIqEbWno8yDdsjCX15iq",strlen("aIqEbWno8yDdsjCX15iq"));
//_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) {
goto ERROR;
}
......@@ -668,15 +719,14 @@ int dm_mgr_upstream_thing_topo_add(_IN_ int devid)
return res;
}
int dm_mgr_upstream_combine_login(_IN_ int devid)
int dm_mgr_upstream_thing_topo_delete(_IN_ int devid)
{
int res = 0;
dm_mgr_dev_node_t *node = NULL;
dm_msg_request_t request;
if (devid < 0) {
return INVALID_PARAMETER;
return DM_INVALID_PARAMETER;
}
res = dm_mgr_search_dev_by_devid(devid, &node);
......@@ -685,13 +735,13 @@ int dm_mgr_upstream_combine_login(_IN_ int devid)
}
memset(&request, 0, sizeof(dm_msg_request_t));
request.service_prefix = DM_URI_EXT_SESSION_PREFIX;
request.service_name = DM_URI_COMBINE_LOGIN;
request.service_prefix = DM_URI_SYS_PREFIX;
request.service_name = DM_URI_THING_TOPO_DELETE;
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);
res = dm_msg_thing_topo_delete(node->product_key, node->device_name, &request);
if (res != SUCCESS_RETURN) {
return FAIL_RETURN;
}
......@@ -703,7 +753,7 @@ int dm_mgr_upstream_combine_login(_IN_ int devid)
request.devid = devid;
/* Callback */
//request.callback = dm_client_combine_login_reply;
//request.callback = dm_client_thing_topo_delete_reply;
/* Send Message To Cloud */
......@@ -717,7 +767,49 @@ int dm_mgr_upstream_combine_login(_IN_ int devid)
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;
dm_mgr_dev_node_t *node = NULL;
......@@ -733,13 +825,13 @@ int dm_mgr_upstream_combine_logout(_IN_ int devid)
}
memset(&request, 0, sizeof(dm_msg_request_t));
request.service_prefix = DM_URI_EXT_SESSION_PREFIX;
request.service_name = DM_URI_COMBINE_LOGOUT;
request.service_prefix = DM_URI_SYS_PREFIX;
request.service_name = DM_URI_THING_LIST_FOUND;
HAL_GetProduct_Type(request.product_key);
HAL_GetProduct_Code(request.device_name);
/* 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) {
return FAIL_RETURN;
}
......@@ -751,9 +843,55 @@ int dm_mgr_upstream_combine_logout(_IN_ int devid)
request.devid = devid;
/* Callback */
//request.callback = dm_client_combine_logout_reply;
//request.callback = dm_client_thing_list_found_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_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 */
res = dm_msg_request(&request);
......@@ -766,7 +904,7 @@ int dm_mgr_upstream_combine_logout(_IN_ int devid)
return res;
}
int dm_mgr_upstream_thing_topo_delete(_IN_ int devid)
int dm_mgr_upstream_combine_logout(_IN_ int devid)
{
int res = 0;
dm_mgr_dev_node_t *node = NULL;
......@@ -782,13 +920,13 @@ int dm_mgr_upstream_thing_topo_delete(_IN_ int devid)
}
memset(&request, 0, sizeof(dm_msg_request_t));
request.service_prefix = DM_URI_SYS_PREFIX;
request.service_name = DM_URI_THING_TOPO_DELETE;
request.service_prefix = DM_URI_EXT_SESSION_PREFIX;
request.service_name = DM_URI_COMBINE_LOGOUT;
HAL_GetProduct_Type(request.product_key);
HAL_GetProduct_Code(request.device_name);
/* 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) {
return FAIL_RETURN;
}
......@@ -800,8 +938,9 @@ int dm_mgr_upstream_thing_topo_delete(_IN_ int devid)
request.devid = devid;
/* Callback */
//request.callback = dm_client_thing_topo_delete_reply;
//request.callback = dm_client_combine_logout_reply;
/* Send Message To Cloud */
/* Send Message To Cloud */
res = dm_msg_request(&request);
......
......@@ -183,6 +183,96 @@ int dm_msg_thing_topo_add(_IN_ char product_key[PRODUCT_KEY_MAXLEN],
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_METHOD[] DM_READ_ONLY = "combine.login";
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],
}
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)
{
......@@ -468,4 +523,74 @@ int dm_msg_response_parse(_IN_ char *payload, _IN_ int payload_len, _OU_ dm_msg_
return SUCCESS_RETURN;
}
static int dm_msg_request_parse(_IN_ char *payload, _IN_ int payload_len, _OU_ kk_msg_request_payload_t *request)
{
lite_cjson_t lite;
if (payload == NULL || payload_len <= 0 || request == NULL) {
return INVALID_PARAMETER;
}
if (lite_cjson_parse(payload, payload_len, &lite) != SUCCESS_RETURN ||
lite_cjson_object_item(&lite, KK_MSG_KEY_ID, strlen(KK_MSG_KEY_ID), &request->id) != SUCCESS_RETURN ||
lite_cjson_object_item(&lite, KK_MSG_KEY_VERSION, strlen(KK_MSG_KEY_VERSION),
&request->version) != SUCCESS_RETURN ||
lite_cjson_object_item(&lite, KK_MSG_KEY_METHOD, strlen(KK_MSG_KEY_METHOD),
&request->method) != SUCCESS_RETURN ||
lite_cjson_object_item(&lite, KK_MSG_KEY_PARAMS, strlen(KK_MSG_KEY_PARAMS),
&request->params) != SUCCESS_RETURN) {
return FAIL_RETURN;
}
printf("Current Request Message ID: %.*s", request->id.value_length, request->id.value);
printf("Current Request Message Version: %.*s", request->version.value_length, request->version.value);
printf("Current Request Message Method: %.*s", request->method.value_length, request->method.value);
printf("Current Request Message Params: %.*s", request->params.value_length, request->params.value);
return SUCCESS_RETURN;
}
int dm_msg_thing_property_set_reply(const char *topic, const char *payload, unsigned int payload_len,
void *context){
kk_msg_request_payload_t request;
kk_msg_response_t response;
int res = 0, devid = 0;
char product_key[PRODUCT_KEY_MAXLEN] = {0};
char device_name[DEVICE_NAME_MAXLEN] = {0};
memset(&request, 0, sizeof(kk_msg_request_payload_t));
memset(&response, 0, sizeof(kk_msg_response_t));
/**************to do*******************/
//dm_log_info(DM_URI_THING_SERVICE_PROPERTY_SET);
/* Request */
/* Request */
res =kk_msg_uri_parse_pkdn((char *)topic, strlen(topic), 2 + KK_URI_OFFSET, 4 + KK_URI_OFFSET, product_key,
device_name);
res = dm_mgr_search_device_by_pkdn(product_key, device_name, &devid);
if (res < SUCCESS_RETURN) {
return res;
}
res = dm_msg_request_parse((char *)payload, payload_len, &request);
if (res < SUCCESS_RETURN) {
return res ;
}
/* Response */
response.service_prefix = DM_URI_SYS_PREFIX;
response.service_name = DM_URI_THING_SERVICE_PROPERTY_SET_REPLY;
memcpy(response.product_key, product_key, strlen(product_key));
memcpy(response.device_name, device_name, strlen(device_name));
response.code = (res == SUCCESS_RETURN) ? (IOTX_DM_ERR_CODE_SUCCESS) : (IOTX_DM_ERR_CODE_REQUEST_ERROR);
dm_msg_response(&request, &response, "{}", strlen("{}"), NULL);
}
......@@ -238,13 +238,7 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
topic = cJSON_GetObjectItem(json, "topic");
payload = cJSON_GetObjectItem(json, "payload");
printf("_iotx_linkkit_event_callback topic: [%s] ,payload= %s \n",topic->valuestring,payload->valuestring );
if (strcmp(payload->valuestring, "addsub")==0){
kk_mid_subdev_add("a1OYuSallan","allanWno8yDdsjCX15iq","","");
}else{
printf("rrr topic: [%s] ,payload= %s \n",topic->valuestring,payload->valuestring );
printf("topic: [%s] ,payload= %s \n",topic->valuestring,payload->valuestring );
if (strstr(topic->valuestring, "register_reply") != NULL){
//====todo======
//get devicececret and save it
......@@ -287,15 +281,14 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
_iotx_linkkit_upstream_callback_remove(atoi(response.id.value), response.code.value_int);
_iotx_linkkit_upstream_mutex_unlock();
}else if (strstr(topic->valuestring, "thing/service/property/set") != NULL){
printf("set property 222222222222222 \n");
kk_tsl_service_property_set(topic->valuestring, payload->valuestring, strlen(payload->valuestring), NULL);
printf("property set reply \n");
dm_msg_thing_property_set_reply(topic->valuestring, payload->valuestring, strlen(payload->valuestring), NULL);
//kk_tsl_service_property_set(topic->valuestring, payload->valuestring, strlen(payload->valuestring), NULL);
}else{
printf("Error 222222222222222 \n");
}
}
cJSON_Delete(json);
}
......
......@@ -21,7 +21,18 @@
void mid_cb(void* data, int len){
if (data != NULL){
printf("app2mid_cb: %s RECEIVED \r\n", data);
char *out;cJSON *json, *topic, *payload;
char *out;
cJSON *json;
cJSON *topic;
cJSON *payload;
int res;
void* buf = malloc(len);
memcpy(buf, data, len);
res = dm_queue_msg_insert((void *)buf);
if (res != SUCCESS_RETURN) {
free(buf);
}
json=cJSON_Parse(data);
if (!json) {
......@@ -32,25 +43,24 @@ void mid_cb(void* data, int len){
topic = cJSON_GetObjectItem(json, "topic");
payload = cJSON_GetObjectItem(json, "payload");
printf("mid_cb topic: [%s] ,payload= %s \n",topic->valuestring,payload->valuestring );
if (strcmp(payload->valuestring, "addsub")==0){
//kk_mid_subdev_add("a1OYuSallan","allanWno8yDdsjCX15iq","");
}else{
void* buf = malloc(len);
memcpy(buf, data, len);
int res = dm_queue_msg_insert((void *)buf);
if (res != SUCCESS_RETURN) {
free(buf);
return FAIL_RETURN;
}
if (strstr(topic->valuestring, "thing/service") != NULL && strstr(topic->valuestring, "service/property/get") == NULL){
//set to platform
char mac[DEVICE_MAC_MAXLEN];
res =dm_mgr_search_mac_by_topic(topic->valuestring, mac);
if (res == SUCCESS_RETURN) {
printf("mid_cb dm_mgr_search_mac_by_topic mac: %s \r\n", mac);
//kk_tsl_service_property_set(topic->valuestring, payload->valuestring, strlen(payload->valuestring), NULL);
}
cJSON * jsonplay=cJSON_Parse(payload->valuestring);
cJSON_AddStringToObject(jsonplay, "mac", "aabbccddee11");
cJSON_AddStringToObject(jsonplay, "mac", mac);
void* out = cJSON_Print(jsonplay);
kk_ipc_send(IPC_MID2PLAT, out, strlen(out));
free(out);
cJSON_Delete(jsonplay);
}
}
cJSON_Delete(json);
}
......@@ -104,6 +114,10 @@ void kk_platMsg_handle(void* data){
}
}else if (method != NULL && strcmp(method->valuestring, "thing.event.property.post")==0){
cJSON *mac;
mac = cJSON_GetObjectItem(json, "mac");
kk_tsl_property_set_byMac(mac->valuestring, data, strlen(mac)+1, NULL);
//kk_tsl_service_property_set(topic->valuestring, data, strlen(data), NULL);
}else{
......@@ -245,7 +259,6 @@ int main(const int argc, const char **argv)
kk_ipc_init(IPC_MID2PLAT, mid2p_cb);
dm_mgr_init();
//DB_Init();
//test_tcp();
/* 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