Commit 577f192d authored by 黄振令's avatar 黄振令

【修改内容】代码优化,已经设备查找不到问题

【提交人】huangzhenling
parent a63ba7bd
......@@ -274,13 +274,13 @@ int main(const int argc, const char **argv)
for (;;) {
usleep(200000);
kk_platMsg_dispatch();
if (ct == 0){
/*if (ct == 0){
ct =1;
void* buf = "{ \"msgId\": \"7\", \"version\": \"1.0\", \"mac\": \"588E81FFFED3834A\", \"method\": \"thing.topo.add\", \"params\": { \"AppVersion\": \"10\", \"deviceType\": \"1\", \"deviceCode\": \"2\", \"productType\": \"3\", \"productCode\": \"4\" }}";
kk_platMsg_handle(buf);
//kk_set_tsl_by_productKey("a1OYuSallan","model.json");
//kk_mid_subdev_add("a1OYuSallan","allanWno8yDdsjCX15iq","","aabbccddeeff1122");
}
}*/
}
}
......
......@@ -121,7 +121,7 @@ int kk_sub_tsl_add(const char *device_mac,const char *product_type)
}
_sub_dev_mutex_lock();
memset(node->product_type,0x0,sizeof(node->product_type));
memset(node,0,sizeof(sub_dev_node_t) );
memcpy(node->device_mac, device_mac, strlen(device_mac));
memcpy(node->product_type, product_type, strlen(product_type));
node->devid = _sub_tsl_next_devid();
......@@ -140,7 +140,6 @@ int kk_sub_tsl_get_device_by_mac(_IN_ char device_mac[DEVICE_MAC_MAXLEN], _OU_ s
list_for_each_entry(search_node, &ctx->dev_list, linked_list, sub_dev_node_t) {
if ((strlen(search_node->device_mac) == strlen(device_mac)) &&
(memcmp(search_node->device_mac, device_mac, strlen(device_mac)) == 0)) {
/* dm_log_debug("Device Found, Product Key: %s, Device Name: %s", product_key, device_name); */
if (node) {
*node = search_node;
}
......
......@@ -53,9 +53,9 @@ void kk_rpc_reportDevices(kk_report_device_s device)
rpc_cJSON_AddAppVersionToObject(devicesJson,device.AppVersion);
rpc_cJSON_AddStringToObject(devicesJson, "deviceType","1");
rpc_cJSON_AddStringToObject(devicesJson, "deviceCode","2");
rpc_cJSON_AddStringToObject(devicesJson, "productType","3");
rpc_cJSON_AddStringToObject(devicesJson, "productType",PRODUCT_TYPE);
rpc_cJSON_AddStringToObject(devicesJson, "productCode","4");
kk_sub_tsl_add(devicesJson,device.mac,"3");
kk_sub_tsl_add(device.mac,PRODUCT_TYPE);
kk_rpc_report_devices(devicesJson,device.mac);
}
bool kk_rpc_report_LightStatus(EmberEUI64 mac,bool LightStatus)
......@@ -228,7 +228,7 @@ cJSON *rpc_Control(jrpc_context * ctx, cJSON *params, cJSON *id,cJSON *mac)
set_json_error_type(ctx,JRPC_INVALID_PARAMS,MSG_INVALID_PARAMS);
goto error_return;
}else{
res = kk_sub_tsl_get_device_by_mac(mac->string, &node);
res = kk_sub_tsl_get_device_by_mac(mac->valuestring, &node);
if (res != SUCCESS_RETURN) {
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
set_json_error_type(ctx,JRPC_INVALID_PARAMS,MSG_INVALID_PARAMS);
......@@ -246,7 +246,7 @@ cJSON *rpc_Control(jrpc_context * ctx, cJSON *params, cJSON *id,cJSON *mac)
if(propertyItem != NULL)
{
int value = rpc_get_u8(propertyItem->valuestring);
res = g_tsl_zigbee_map[pCtrlIdx].zigbee_ctrl[index].zigbee_cb(ctx,mac,&value);
res = g_tsl_zigbee_map[pCtrlIdx].zigbee_ctrl[index].zigbee_cb(ctx,mac->valuestring,&value);
if(res < 0){
set_json_error_type(ctx,JRPC_INVALID_PARAMS,MSG_INVALID_PARAMS);
goto error_return;
......
......@@ -11,6 +11,9 @@
#define KK_REPORT_ATTRIBUTE_METHOD "thing.service.property.report"
#define KK_READ_ATTRIBUTE_METHOD "thing.service.property.get"
#define PRODUCT_TYPE "3"
cJSON *rpc_Control(jrpc_context * ctx, cJSON * params, cJSON *id,cJSON *mac);
cJSON *rpc_read_attribue(jrpc_context * ctx, cJSON * params, cJSON *id,cJSON *mac);
int lightStatusSet(jrpc_context * ctx,const char *mac,void* data);
......
......@@ -3,7 +3,7 @@
kk_tsl_zigbee_map_t g_tsl_zigbee_map [] = {
{
"a1h88DsZIaY",
PRODUCT_TYPE,
3,
{
{KK_TSL_DATA_TYPE_TEXT,"LightStatus",lightStatusSet},
......
......@@ -484,6 +484,13 @@ void emAfDeviceTableLoad(void)
deviceTable[i].clusterOutStartPosition = (uint16_t) data;
deviceTable[i].state = EMBER_AF_PLUGIN_DEVICE_TABLE_STATE_JOINED;
char mac[17] = {0};
sprintf(mac,"%02X%02X%02X%02X%02X%02X%02X%02X",deviceTable[i].eui64[7],deviceTable[i].eui64[6],
deviceTable[i].eui64[5],deviceTable[i].eui64[4],deviceTable[i].eui64[3],deviceTable[i].eui64[2],
deviceTable[i].eui64[1],deviceTable[i].eui64[0]);
kk_sub_tsl_add(mac,"3");
}
deviceTable[i].lastMsgTimestamp = halCommonGetInt32uMillisecondTick();
......
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