无法在运行时更改属性uuid

⚠️
大家好. .感谢来到论坛。令人兴奋的消息!我们现在正在转移到新的论坛平台的过程中,它将提供更好的功能,并包含在主对话网站。所有的帖子和账号已经迁移。我们现在只接受新论坛的流量-请发布任何新的帖子在//www.xmece.com/support.我们会在接下来的几天修复bug /优化搜索和标记。
7个职位/ 0个新职位
最后发表
chenpenglai
离线
最后看到:5个月2个星期前
加入:2018-12-24 02:24
无法在运行时更改属性uuid

我工作在sdk 5.0.4

我想在运行时修改现有的服务uuid和属性uuid,因为属性uuid是客户在运行时通过串口配置的

我正在开发一个AT指令蓝牙模块

我在做下面的事情

uint8_t new_uuid_arr [16] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};//一个新的uuid struct att_char128_desc *p1 = (struct att_char128_desc *)cust_prf_funcs->att_db[CUST1_IDX_SERVER_TX_CHAR].value;memcpy (p1 - > attr_type new_uuid_arr 16);

我的期望是,在上述代码执行后,uuid会发生变化

但这行不通

请告诉我运行后如何通过哪个函数更改现有的服务uuid和属性uuid

还有其他方法可以改变uuid属性吗?

设备:
PM_Dialog
离线
最后看到:3天14小时前
工作人员
加入:2018-02-08 11:03
嗨chenpenglai,

嗨chenpenglai,

在app_custs1_create_db()函数中尝试了以下步骤吗??如果是,在哪个示例的SDK?你想如何改变UUI?

Uint8_t array_test_svc[] = {0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03};Uint8_t array_test_long_char[] = {0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04};memcpy (cust_prf_funcs[我].att_db [CUST1_IDX_SVC]。价值array_test_svc 16);//这将在服务上进行更改

要改变特征值,你必须在两个地方进行改变:

memcpy (cust_prf_funcs[我].att_db [CUST1_IDX_SVC]。Value + (16*7), array_test_long_char, 16);//将更改应用到包含服务特征的数组中

现在将改变应用到特性本身:

memcpy (cust_prf_funcs[我].att_db [CUST1_IDX_LONG_VALUE_CHAR]。Value + 3, array_test_long_char, 16);

谢谢,PM_Dialog

chenpenglai
离线
最后看到:5个月2个星期前
加入:2018-12-24 02:24
我试着执行上面的内容

我尝试在app_custs1_create_db()函数中执行上面的代码,如下所示

void app_custs1_create_db(void) {struct custs1_create_db_req *req = KE_MSG_ALLOC(custs1_create_db_req, TASK_CUSTS1, TASK_APP, custs1_create_db_req);Uint8_t I = 0;/****************** 添加  *********************/ uint8_t array_test_svc [] = {0 x03 0 x03 0 x03, 0 x03, 0 x03, 0 x03, 0 x03, 0 x03, 0 x03, 0 x03, 0 x03, 0 x03, 0 x03, 0 x03, 0 x03, 0 x03};Uint8_t array_test_long_char[] = {0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04};memcpy (cust_prf_funcs [0] .att_db CUST1_IDX_SVC value, array_test_svc, 16);memcpy (cust_prf_funcs [0] .att_db [CUST1_IDX_SVC]。Value + (16*7), array_test_long_char, 16);memcpy (cust_prf_funcs [0] .att_db [CUST1_IDX_SERVER_TX_CHAR]。Value + 3, array_test_long_char, 16);/****************** 添加  *********************/ 而(cust_prf_funcs[我]。task_id != TASK_NONE) {if(cust_prf_funcs[i]. task_id !task_id == task_cust1) {req->max_nb_att = cust_prf_funcs[i].max_nb_att;打破; } else i++; } // Attribute table. In case the handle offset needs to be saved req->att_tbl = NULL; req->cfg_flag = 0; req->features = 0; // Send the message ke_msg_send(req); }

但是app_custs1_create_db()函数只能在设备启动时更改服务uuid

我想在运行时更改它,而不是重新启动

我尝试更改array_test_svc[]值,并在设备启动后调用app_custs1_create_db()函数,但无法更改服务uuid

chenpenglai
离线
最后看到:5个月2个星期前
加入:2018-12-24 02:24
你好PM_Dialog

你好PM_Dialog

我需要你的帮助

PM_Dialog
离线
最后看到:3天14小时前
工作人员
加入:2018-02-08 11:03
嗨chenpenglai,

嗨chenpenglai,

我为耽搁道歉。我正在处理这个问题,我会尽快给你回电话。您正在使用哪个SDK示例?

谢谢,PM_Dialog

chenpenglai
离线
最后看到:5个月2个星期前
加入:2018-12-24 02:24
我在ble_app工作

我在ble_app_peripheral工作

PM_Dialog
离线
最后看到:3天14小时前
工作人员
加入:2018-02-08 11:03
嗨chenpenglai,

嗨chenpenglai,

我使用了以下代码片段,我不能复制你的问题。我使用了SDK5.0.4的ble_app_peripheral示例。唯一的变化是CUST1_IDX_LONG_VALUE_CHAR而不是CUST1_IDX_SERVER_TX_CHAR。我假设你已经创建了一个“服务器Tx”特征。

# include“user_custs1_def.h”
void app_custs1_create_db(void) {struct custs1_create_db_req *req = KE_MSG_ALLOC(custs1_create_db_req, TASK_CUSTS1, TASK_APP, custs1_create_db_req);Uint8_t I = 0;/****************** 添加  *********************/ uint8_t array_test_svc [] = {0 x03 0 x03 0 x03, 0 x03, 0 x03, 0 x03, 0 x03, 0 x03, 0 x03, 0 x03, 0 x03, 0 x03, 0 x03, 0 x03, 0 x03, 0 x03};Uint8_t array_test_long_char[] = {0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04};memcpy (cust_prf_funcs [0] .att_db CUST1_IDX_SVC value, array_test_svc, 16);memcpy (cust_prf_funcs [0] .att_db [CUST1_IDX_SVC]。Value + (16*7), array_test_long_char, 16);memcpy (cust_prf_funcs [0] .att_db [CUST1_IDX_LONG_VALUE_CHAR]。Value + 3, array_test_long_char, 16);/****************** 添加  *********************/ 而(cust_prf_funcs[我]。task_id != TASK_NONE) {if(cust_prf_funcs[i]. task_id !task_id == task_cust1) {req->max_nb_att = cust_prf_funcs[i].max_nb_att;打破; } else i++; } // Attribute table. In case the handle offset needs to be saved req->att_tbl = NULL; req->cfg_flag = 0; req->features = 0; // Send the message ke_msg_send(req); }

因为,我不能复制这个问题,请尝试调试您的代码。另外,不工作是什么意思?这个设备在做广告吗?你能接通吗?你在调试模式下运行它了吗?

谢谢,PM_Dialog