你好,
我想在ble\u app\u peripheral示例中添加一个定制服务(Light Bulb-128位)和它的单个特征(ON-128位)。
我已删除应用程序中现有的服务/特征。
如果没有错,我需要在user\u prf\u funcs[]中添加一个条目,然后编写两个函数:
void应用程序\u lb\u db\u创建(void)
void app_lb_db_enable(uint16_t)
Also, I need to add those under which task_id? TASK_CUSTS1 or anything else?
I am trying to create service and characteristic in app_lb_db_create() using attmdb_add_service() and attmdb_add_attribute(). But, when I execute the code, I think watchdog expires.
另外,app\u lb\u db\u enable(uint16\u t)的内容应该是什么。
是否有一些文件或示例可以帮助我在这方面。
注意:在我的例子中,GATT数据库将通过UART从主机发送。因此,我不能使用任何已在示例应用程序中使用的const结构。亚博国际官网平台网址
I need to add the GATT database dynamically by parsing the data on the UART.
Thanks,
Hrishikesh
Device:
嗨,德里希,
您可以留下自定义任务,并仅修改特性,只需删除您不需要的那些,还有一个关于您可以使用的自定义服务的教程修改示例(教程3:构建自定义配置文件)。您还可以查看使用自定义配置文件和重命名作为DSP专用配置文件的DSP示例,并且还使用自定义启用和创建数据库函数。
谢谢你的对话
谢谢你的回复。我为CUST1编辑了关贸总协定外围数据库,添加了我的服务和特点,效果很好。这是针对已知的服务和特征(2个服务,每个服务有1个特征)
现在,我想通过UART发送相同的服务/特性,并动态分配GATT数据库。这可能吗?
With what I see, the att_db pointer in struct cust_prf_func_callbacks is of const struct cust_prf_func_callbacks * type.
那么,我该怎么做?
当我通过UART接收GATT数据库时,有没有其他方法可以动态添加GATT数据库?
Thanks,
Hrishikesh
嗨,德里希,
If the above answer was helpfull, please mark it as accepted.
关于您的第二个问题,我不确定我是否理解(我假设您使用的是完全托管的设计,您的应用程序也位于580中),因此,由于SDK的结构是正常的,所以数据库是在配置设备之后创建的,这不是强制性的(根据设备配置创建数据库),但是您可以在通过UART发送命令时触发数据库的创建。或者,如果您不希望数据库在设备中固定,而是希望通过外部设备对其进行配置,则可以使用RW-BLE-GATT-IS \u 1.pdf中记录的内核消息。
谢谢你的对话
你好,
Thanks for the reply. The first answer was helpful in a way. But, I don't have static services/characteristics as I mentioned and need to add them dynamically.
我浏览了RW-BLE-GATT-IS.pdf,在里面我找到了我认为需要发送的事件GATTM\u ADD\u SVC\u REQ,GATTM\u ADD\u ATTRIBUTE\u REQ。
是否有一个示例应用程序,它展示了相同的。我无法找到样品应用程序或SDK中的任何位置的Gattm_add_svc_req。我需要知道如何以及在哪里发送这些消息并处理他们的答复?
一个合适的起点可能有助于我遵循正确的方法将是有益的。
Thanks,
Hrishikesh
嗨,德里希,
不幸的是,没有使用这些消息来创建数据库的示例,但是逻辑与内核中交换的所有其他消息相同,从应用程序任务向ATTMèu任务发送消息,并得到相应的响应。您可以捕获user\catch\u rest\hndl处理程序中的消息并触发下一个操作,添加服务,然后在获得创建服务的响应后添加属性等。用于创建服务的消息如下所示:
void create_service_database(void)
{
struct gattm_add_svc_req * req = KE_MSG_ALLOC(GATTM_ADD_SVC_REQ, TASK_ATTM, TASK_APP, gattm_add_svc_req);
请求->启动\u hdl=0;
请求->任务id=56;
req->total_size = 3;
请求->nb\u att\u uuid\u 16=2;
req->nb_att_uuid_128 = 1;
ke_msg_send(req);
}
In the user_catch_rest_hndl you can catch your responses
case GATTM_ADD_SVC_RSP:
{
struct gattm_add_svc_rsp const *msg_param = (struct gattm_add_svc_rsp const *)(param);
//catch the message that the service database has been allocated and start adding attributes
}break;
谢谢你的对话
谢谢!我就是这么想的was looking for. Using the above I am trying to add 1 service (128 bit) and 1 char (128 bit). When connected to the peripheral, I can see the service but not the characteristic (empty service) in the nrf app. Do you have a clue about what could be going wrong here?
Starting from adding service, I have added all the attributes in the appropriate response of each.
Details about service and the attributes in the same sequence in which I have called them are as below. Could you please check what could be missing:
**************************************** SVC **************************************************
//添加服务(GATTM\ U Add\ U SVC\ U REQ)
请求->启动\u hdl=0;
req->task_id = TASK_APP;
需求->总大小=36;//16 + 19 + 1
请求->nb\u att\u uuid\u 16=2;
req->nb\ U att\ U uuid\ U 32=0;
req->nb_att_uuid_128 = 1;
*******************************属性*****************************************************************
// Add svc decl attribute (GATTM_ADD_ATTRIBUTE_REQ)
申请- > start_hdl = svc_handle;/ /从svc填充success rsp for above
req->perm=perm(RD,启用);
req->uuid_len = ATT_UUID_16_LEN;
req->max_data_size = ATT_UUID_128_LEN;
memcpy(请求->uuid,&att\u decl\u svc,sizeof(att\u decl\u svc));
//Set svc uuid value (GATTM_ATT_SET_VALUE_REQ)
req->handle=svc\U句柄;
需求->长度=ATT\u UUID\u 128\u LEN;
memcpy(req->value, svc_uuid, sizeof(svc_uuid)); //uint8_t svc_uuid[16];
//Add char decl attribute (GATTM_ADD_ATTRIBUTE_REQ)
申请- > start_hdl = svc_handle;/ /从svc填充success rsp
req->perm=perm(RD,启用);
req->uuid_len = ATT_UUID_16_LEN;
请求->最大数据大小=ATT\u UUID\u 128\u LEN+3;
memcpy(req->uuid, &att_decl_char, sizeof(att_decl_char));
//添加字符值属性(GATTM\u Add\u attribute\u REQ)
申请- > start_hdl = svc_handle;
req->perm = PERM(RD, ENABLE) | PERM(WR, ENABLE);
req->uuid_len = ATT_UUID_128_LEN;
请求->最大数据大小=sizeof(uint8\t);
memcpy(req->uuid, char_uuid, sizeof(char_uuid)); //uint8_t char_uuid[16];
//设置初始值(GATTM\ U ATT\ U Set\ U value\ U REQ)
req->handle=char\u decl\u handle//从char decl rsp填充
req->length = sizeof(on_char);
memcpy(req->value, &on_char, sizeof(on_char)); // on_char - struct att_char128_desc on_char = {ATT_CHAR_PROP_RD | ATT_CHAR_PROP_WR, {0,0}, {16 byte char UUID}};
Thanks,
Hrishikesh
嗨,德里希,
I dont see anything that could possibly is wrong, your implementation seems proper. This functionallity is a bit hidden at the latest SDK, but you are going to be able to check how the database is created in the SDK 3. There is the AN-B-029 document that comes along with some examples regarding the creation of the custom profile (both of the document and the example file can be found in the Documents tab in the Discontinued application notes). In that .zip file there are examples of the custom profiles in SDK3 in the sample128_task.c file at the sample128_create_db_req_handler() function you will be able to find an example on how to create a 128 custom profile (the commands used are essentially the same commands that the stack executes when it receives the commands that you are using).
谢谢你的对话
你好,
我引用了同样的方法来编写上述代码。另外,在大多数地方,我还看到一个将服务权限设置为PERM(SVC,DISABLE)的调用。为什么需要这样做?我尝试使用启用和禁用,但仍然没有运气。另外,在我的代码中,total size和nb\u att\u uuid的值是合适的,对吗?
Also, access to AN-B-029 seems to be restricted. Could you please send that over email.
Thanks,
Hrishikesh
嗨,德里希,
PERM(SVC,xxx)用于设置创建后服务的权限(DISABLE it只是在您未连接时禁用服务),当您连接时,应使用PERM(SVC,启用),以便从中心访问它或设置安全级别(例如,服务需要安全才能访问)。是的,服务的总大小是正确的1服务(+16)+1特征(+19)+1特征值(+1),属性的数目是正确的2个16位UUID值和1个128位UUID值。
关于AN-B-029的限制,我提到的文档没有限制,但是我可以看到您没有访问任何文档或SDK本身的权限,因此请转到产品DA14580并导航到软件和工具。在那里你会看到一个挂锁图标-点击它,接受协议,几天后你将被授予SDK访问权限。
谢谢你的对话
你好,
Ok. I will do that to get access to the documents.
Finally, I was able to make it work. I had missed populating the characteristic value handle in att_char128_desc on_char and hence saw the service as empty. With this change I can now see my service and characteristic. Thanks for your help. :-)
- Hrishikesh