diff --git a/mkrtos_knl/knl/scheduler.c b/mkrtos_knl/knl/scheduler.c index 5c5c9d45d..39487948d 100755 --- a/mkrtos_knl/knl/scheduler.c +++ b/mkrtos_knl/knl/scheduler.c @@ -53,7 +53,7 @@ void scheduler_add(sched_t *node) sched->cur_sche = NULL; } - MK_SET_BIT(sched->bitmap[node->prio / PRIO_MAX], node->prio); + MK_SET_BIT(sched->bitmap[node->prio / PRIO_MAX], node->prio % PRIO_MAX); slist_add(&(sched->prio_list[node->prio]), &node->node); } diff --git a/mkrtos_user/server/app/drv/e180-zg120.c b/mkrtos_user/server/app/drv/e180-zg120.c index a0add293e..fe97ed775 100644 --- a/mkrtos_user/server/app/drv/e180-zg120.c +++ b/mkrtos_user/server/app/drv/e180-zg120.c @@ -811,6 +811,131 @@ int mod_send_data(uint16_t short_addr, uint8_t port, uint8_t dir, return ret_op; } +#pragma pack(1) +typedef struct local_send_0x11 +{ + uint8_t port_inx; + uint16_t par_id; + uint8_t data[4]; +} local_send_0x11_t; +/** + * @brief 设置短地址 + * + * @param short_addr + * @return int + */ +int mod_set_local_attr_short_addr(uint16_t short_addr) +{ + int len; + int ret_op = -1; + uint8_t data_cache[64] = {0}; + local_send_0x11_t pack = { + .port_inx = 0, + .par_id = 0x0001, // short addr, + }; + memcpy(pack.data, &short_addr, sizeof(short_addr)); + + len = zigbee_gen_pack(data_cache, TYPE_CFG, 0x11, (uint8_t *)(&pack), 5); + zigbee_send_bytes(data_cache, len); + + wait_pack(50); + queue_t *q = uart4_queue_get(); + + int ret; + while ((ret = zigbee_pack_get(q, data_cache)) > 0) + { + base_pack_t *pack = (base_pack_t *)data_cache; + + if (pack->cmd_type == TYPE_CFG && pack->cmd_code == 0x11) + { + if (pack->data[0] == 0) + { + ret_op = 0; + } + } + print_hex(data_cache, ret); + } + return ret_op; +} +/** + * @brief 设置端口 + * + * @param short_addr + * @return int + */ +int mod_set_local_attr_port(uint8_t port) +{ + int len; + int ret_op = -1; + uint8_t data_cache[64] = {0}; + local_send_0x11_t pack = { + .port_inx = 0, + .par_id = 0x0002, // short addr, + }; + memcpy(pack.data, &port, sizeof(port)); + + len = zigbee_gen_pack(data_cache, TYPE_CFG, 0x11, (uint8_t *)(&pack), 4); + zigbee_send_bytes(data_cache, len); + + wait_pack(50); + queue_t *q = uart4_queue_get(); + + int ret; + while ((ret = zigbee_pack_get(q, data_cache)) > 0) + { + base_pack_t *pack = (base_pack_t *)data_cache; + + if (pack->cmd_type == TYPE_CFG && pack->cmd_code == 0x11) + { + if (pack->data[0] == 0) + { + ret_op = 0; + } + } + print_hex(data_cache, ret); + } + return ret_op; +} +/** + * @brief 设置透传 + * + * @param short_addr + * @return int + */ +int mod_set_local_attr_pass_through(bool_t is_pass_through) +{ + int len; + int ret_op = -1; + uint8_t data_cache[64] = {0}; + local_send_0x11_t pack = { + .port_inx = 0, + .par_id = 0x0003, // short addr + }; + memcpy(pack.data, &is_pass_through, sizeof(is_pass_through)); + + len = zigbee_gen_pack(data_cache, TYPE_CFG, 0x11, (uint8_t *)(&pack), 4); + zigbee_send_bytes(data_cache, len); + + wait_pack(50); + queue_t *q = uart4_queue_get(); + + int ret; + while ((ret = zigbee_pack_get(q, data_cache)) > 0) + { + base_pack_t *pack = (base_pack_t *)data_cache; + + if (pack->cmd_type == TYPE_CFG && pack->cmd_code == 0x11) + { + if (pack->data[0] == 0) + { + ret_op = 0; + } + } + print_hex(data_cache, ret); + } + return ret_op; +} + void e180_loop(void) { { diff --git a/mkrtos_user/server/app/drv/e180-zg120.h b/mkrtos_user/server/app/drv/e180-zg120.h index 7c6ee80b0..e610c2f54 100644 --- a/mkrtos_user/server/app/drv/e180-zg120.h +++ b/mkrtos_user/server/app/drv/e180-zg120.h @@ -17,7 +17,9 @@ enum cluster int mod_start_cfg_net(uint8_t mode); int mod_send_data(uint16_t short_addr, uint8_t port, uint8_t dir, uint8_t cmd_id, uint8_t *data, uint8_t len); - +int mod_set_local_attr_short_addr(uint16_t short_addr); +int mod_set_local_attr_port(uint8_t port); +int mod_set_local_attr_pass_through(bool_t is_pass_through); int mod_set_node_type(enum point_type p_type); int mod_reset(int reset_mode, uint16_t panid, uint8_t channel); void mod_query_status(void);