Hi,
一世want to add a custom service, not present in the sdk, (Light Bulb - 128 bit) and its single characteristic (ON - 128 bit) in the ble_app_peripheral example.
一世have removed the existing service/characteristic present in the app.
一世f I am not wrong, I need to add an entry in user_prf_funcs[] and then write two functions:
void app_lb_db_create(void)
void app_lb_db_enable(uint16_t)
此外,我需要添加那些task_id的那些?task_custs1或其他什么?
我正在尝试使用attmdb_add_service()和attmdb_add_attribute()在app_lb_db_create()中创建服务和特性。但是,当我执行代码时,我认为看门狗过期。
Also, what should be the contents of app_lb_db_enable(uint16_t).
一世s there some documentation or a sample example which can help me in this regard.
Note: The GATT database in my case would be sent from a host over UART. So, I cannot use any of the const structures that have been used in the sample applications.
我需要通过解析UART上的数据来动态添加GATT数据库。
谢谢,
hrishikesh.
Hi dhrishi,
您可以留下自定义任务,并仅修改特性,只需删除您不需要的那些,还有一个关于您可以使用的自定义服务的教程修改示例(教程3:构建自定义配置文件)。您还可以查看使用自定义配置文件和重命名作为DSP专用配置文件的DSP示例,并且还使用自定义启用和创建数据库函数。
Thanks MT_dialog
感谢您的回复。一世edited the peripheral gatt database for CUST1 and added my services and characteristics and it worked fine. This was for known services and characteristics (2 services with 1 characteristic each)
现在,我想向UART发送相同的服务/特征,并动态分配GATT数据库。这可能吗?
使用我所看到的,struct cust_prf_func_callbacks中的att_db指针是const struct cust_prf_func_callbacks *类型。
那么,我该怎么做?
一世s there any other way in which I can add the GATT database dynamically when I receive it over UART?
谢谢,
hrishikesh.
Hi dhrishi,
如果上述答案是帮助,请将其标记为已接受。
Regarding your second question, i am not sure i understand (i am assuming that you are using a fully hosted design, your application is located in the 580 as well), so, as the SDK is structured normaly the database is created right after configuring the device, that is not mandatory (the creation of the database upon device configuration), but you can trigger the creation of the database upon a command send via UART. Or, if you would like your database not to be fixed in the device but to configure it via an external device you could use the kernel messages documented by the RW-BLE-GATT-IS_1.pdf.
Thanks MT_dialog
Hi,
谢谢回复。第一个答案在某种程度上是有用的。但是,我提到的静态服务/特征,并且需要动态添加它们。
一世was going through RW-BLE-GATT-IS.pdf and in that I found events GATTM_ADD_SVC_REQ, GATTM_ADD_ATTRIBUTE_REQ that I think I need to send.
是否有一个示例应用程序,它展示了相同的。我无法找到样品应用程序或SDK中的任何位置的Gattm_add_svc_req。我需要知道如何以及在哪里发送这些消息并处理他们的答复?
An appropriate starting point which might help me in following the correct way would be helpful.
谢谢,
hrishikesh.
Hi dhrishi,
Unfortunatelly there is no example that uses those messages in order to create the database but the logic is the same like all the other messages exchanged in the kernel, from your application task you send a message to the ATTM_TASK and you get the corresponding response. You can catch the messages in the user_catch_rest_hndl handler and trigger your next operation, add the service, then after getting the response that the service is created add the attributes etc. A message for creating the service would be like the following example:
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);
req->start_hdl = 0;
req->task_id = 56;
req-> total_size = 3;
申请- > nb_att_uuid_16 = 2;
req-> nb_att_uuid_128 = 1;
KE_MSG_SEND(REQ);
}
在user_catch_rest_hndl中,您可以捕获您的回复
案例gattm_add_svc_rsp:
{
struct gattm_add_svc_rsp const * msg_param =(struct gattm_add_svc_rsp const *)(param);
//捕获服务数据库已分配并开始添加属性的消息
}休息;
Thanks MT_dialog
谢谢!这正是我所寻找的。使用上面的我正在尝试添加1服务(128位)和1个字符(128位)。连接到外围设备时,我可以看到该服务但不是NRF应用程序中的特征(空服务)。你有关于在这里出现问题的线索吗?
从添加服务开始,我在每个属性中添加了所有属性。
有关服务的详细信息以及我所谓的序列中的属性如下所示。请你检查可能缺少的内容:
**************************************** svc ****************************************************
// Add service (GATTM_ADD_SVC_REQ)
req->start_hdl = 0;
req-> task_id = task_app;
req->total_size = 36; // 16 + 19 + 1
申请- > nb_att_uuid_16 = 2;
req->nb_att_uuid_32 = 0;
req-> nb_att_uuid_128 = 1;
******************************* ATTRIBUTES *****************************************************************
// add svc delp属性(gattm_add_attribute_req)
req-> start_hdl = svc_handle;//从SVC成功填充以上的RSP
req->perm = PERM(RD, ENABLE);
req-> uuid_len = att_uuid_16_len;
req-> max_data_size = att_uuid_128_len;
memcpy(req->uuid, &att_decl_svc, sizeof(att_decl_svc));
//设置svc uuid值(gattm_att_set_value_req)
req->handle = svc_handle;
req->length = ATT_UUID_128_LEN;
memcpy(req->值,svc_uuid,sizeof(svc_uuid));// uint8_t svc_uuid [16];
//添加char delp属性(gattm_add_attribute_req)
req-> start_hdl = svc_handle;//填充SVC成功RSP
req->perm = PERM(RD, ENABLE);
req-> uuid_len = att_uuid_16_len;
req->max_data_size = ATT_UUID_128_LEN + 3;
memcpy(req-> uuid,&att_decl_char,sizeof(att_decl_char));
/ /添加字符值attribute (GATTM_ADD_ATTRIBUTE_REQ)
req-> start_hdl = svc_handle;
req-> perm = perm(rd,启用)|perm(wr,启用);
req-> uuid_len = att_uuid_128_len;
req->max_data_size = sizeof(uint8_t);
memcpy(req-> uuid,char_uuid,sizeof(char_uuid));// uint8_t char_uuuid [16];
// Set initial value (GATTM_ATT_SET_VALUE_REQ)
req->handle = char_decl_handle //populated from char decl rsp
req-> length = sizeof(on_char);
memcpy(req->值,&on_char,sizeof(on_char));// on_char - struct att_char128_desc on_char = {att_char_prop_rd |ATT_CHAR_PROP_WR,{0,0},{16字节CHAR UUID}};
谢谢,
hrishikesh.
Hi dhrishi,
我没有看到任何可能是错误的,你的实现似乎是正确的。此功能存在于最新的SDK中有点隐藏,但您将能够检查如何在SDK 3中创建数据库3.有关创建的一些示例,还有一个AN-B-029文档自定义配置文件(Document and示例文件中的两个文件和示例文件)可以在“已停止的应用程序笔记”中的“文档”选项卡中找到。在那个.zip文件中,sample128_create_db_req_handler()函数中的SDK3中的SDK3中的自定义配置文件示例您将能够找到有关如何创建128自定义配置文件的示例(所用命令基本相同命令堆栈收到您使用的命令时执行)。
Thanks MT_dialog
Hi,
一世had referred the same to write above code. Also, at most of the places I see one more call of setting service permissions to PERM(SVC,DISABLE). Why is this required? I tried using ENABLE as well as DISABLE but still no luck. Also, in my code the values for total size and nb_att_uuid_* values are appropriate, right?
此外,访问AN-B-029似乎受到限制。你能通过电子邮件发送。
谢谢,
hrishikesh.
Hi dhrishi,
The PERM(SVC,xxx) is used in order to set the service's right's after creation ( the DISABLE it just disables the service while you are unconnected) when you connect you should enable this service with the PERM(SVC,ENABLE) in order to access it from a central or set a security level (for example that the service requires security in order to be accessed). Yes the total size of your sevice is proper 1 service (+16) + 1 characteristic (+19) + 1 characteristic value (+1) and the numbers of the attributes are proper 2 16bit UUID values and 1 128bit UUID value.
Regarding the restriction of the AN-B-029 there is no restriction on the document that i ve mentioned, but i can see that you dont have permission to access any documents or the SDK itself, so please go to product DA14580 and navigate to software and tools. There you 'll see a padlock icon - click that, accept the agreement, and you will be granted will SDK access in a couple of days.
Thanks MT_dialog
Hi,
好的。我会这样做,可以访问文件。
最后,我能够做到它的工作。我错过了填充ATT_CHAR128_DESC ON_CHAR中的特征值句柄,因此将服务视为空。通过这种变化,我现在可以看到我的服务和特征。谢谢你的帮助。:-)
- hrishikesh.