Adding a custom service/characteristic database in ble_app_peripheral

11个帖子/ 0新
最后一篇
dhrishi
离线
最后一次露面:3 years 4 months ago
加入:2017-02-10 09:56
Adding a custom service/characteristic database in ble_app_peripheral

你好,

我想在BLE_APP_PERITIELAL示例中添加一个自定义服务,不存在于SDK中,(灯泡 - 128位)及其单个特征(ON-128位)。
我已删除了应用程序中存在的现有服务/特征。
如果我没有错,我需要在user_prf_funcs []中添加一个条目,然后写两个函数:
void app_lb_db_create(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_lb_db_enable(uint16_t)的内容。
是否有一些文档或示例示例,可以帮助我参考这方面。

注意:我的案例中的GATT数据库将从UART发送到主机。因此,我不能使用样本应用程序中使用的任何Const结构。亚博国际官网平台网址
I need to add the GATT database dynamically by parsing the data on the UART.

Thanks,
Hrishikesh

Device:
mt_dialog.
离线
最后一次露面:3 months 3 days ago
职员
加入:2015-06-08 11:34
嗨Dhrishi,

嗨Dhrishi,

你可以把自定义任务和修改辊筒y the characteristics, just remove the ones that you dont need, there is also a tutorial about the custom service that you could use in order modify the example (Tutorial 3 : Building Custom Profiles). You can also have a look at the DSPS example which uses a custom profile and renames as a DSPS dedicated profile and also uses custom enabling and create database functions.

谢谢mt_dialog.

dhrishi
离线
最后一次露面:3 years 4 months ago
加入:2017-02-10 09:56
感谢您的回复。I

感谢您的回复。我编辑了CUST1的外围GATT数据库,并添加了我的服务和特征,并效果正常。这是为了知名的服务和特征(每次有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.
So, how do I do this?
是否有任何其他方式可以动态地添加GATT数据库,当我收到UART时?

Thanks,
Hrishikesh

mt_dialog.
离线
最后一次露面:3 months 3 days ago
职员
加入:2015-06-08 11:34
嗨Dhrishi,

嗨Dhrishi,

If the above answer was helpfull, please mark it as accepted.

关于你的第二个问题,我不确定我理解(我假设你使用完全托管的设计,你的应用程序也位于580中),因此,随着SDK的结构,数据库在配置后创建了数据库该设备不是强制性的(在设备配置时创建数据库),但您可以在命令发送通过UART时触发数据库的创建。或者,如果您希望在设备中修复数据库,而且通过外部设备配置它,您可以使用由RW-BLE-GATT-IS_1.PDF记录的内核消息。

谢谢mt_dialog.

dhrishi
离线
最后一次露面:3 years 4 months ago
加入:2017-02-10 09:56
你好,

你好,

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_add_svc_req,gattm_add_attribute_req,我认为我需要发送。
Is there a sample application that demonstrates the same. I could not find GATTM_ADD_SVC_REQ being used anywhere in the sample apps or the sdk. I need to know how and where do I send those messages and handle their responses?

适当的起点可能以跟随正确的方式帮助我会有所帮助。

Thanks,
Hrishikesh

mt_dialog.
离线
最后一次露面:3 months 3 days ago
职员
加入:2015-06-08 11:34
嗨Dhrishi,

嗨Dhrishi,

不幸的是,没有使用这些消息来创建数据库的示例,但逻辑与内核中交换的所有其他消息相同,从您的应用程序任务中向ATTM_TASK发送消息,您可以获得相应的响应。您可以在user_catch_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);
req-> start_hdl = 0;
req-> task_id = 56;
req->total_size = 3;
req-> nb_att_uuid_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;

谢谢mt_dialog.

dhrishi
离线
最后一次露面:3 years 4 months ago
加入:2017-02-10 09:56
谢谢!这正是我的

谢谢!这正是我的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_add_svc_req)
req-> start_hdl = 0;
req->task_id = TASK_APP;
req-> total_size = 36;// 16 + 19 + 1
req-> nb_att_uuid_16 = 2;
req-> nb_att_uuuid_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(req-> uuid,&att_decl_svc,sizeof(att_decl_svc));

//Set svc uuid value (GATTM_ATT_SET_VALUE_REQ)
req-> handle = svc_handle;
req-> length = att_uuid_128_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;
req-> max_data_size = att_uuid_128_len + 3;
memcpy(req->uuid, &att_decl_char, sizeof(att_decl_char));

//添加char值属性(gattm_add_attribute_req)
申请- > start_hdl = svc_handle;
req->perm = PERM(RD, ENABLE) | PERM(WR, ENABLE);
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_uuid[16];

//设置初始值(gattm_att_set_value_req)
req-> handle = char_decl_handle //从char derv填充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

mt_dialog.
离线
最后一次露面:3 months 3 days ago
职员
加入:2015-06-08 11:34
嗨Dhrishi,

嗨Dhrishi,

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).

谢谢mt_dialog.

dhrishi
离线
最后一次露面:3 years 4 months ago
加入:2017-02-10 09:56
你好,

你好,

我已经提到了相同的写上面的代码。此外,在大多数地点,我看到一个呼叫将服务权限设置为perm(svc,disable)。为什么这需要?我尝试使用Enable,但仍然没有运气。此外,在我的代码中,总大小和nb_att_uuuid_ *值的值是合适的,对吧?

Also, access to AN-B-029 seems to be restricted. Could you please send that over email.

Thanks,
Hrishikesh

mt_dialog.
离线
最后一次露面:3 months 3 days ago
职员
加入:2015-06-08 11:34
嗨Dhrishi,

嗨Dhrishi,

使用权限(SVC,XXX)以便在创建后设置服务的右侧(禁用它只禁用您在未连接时禁用服务),当您连接时,您应该使用PERM(SVC,ENABLE)启用此服务以便从中央访问它或设置安全级别(例如,服务需要访问安全性以便访问)。是的总体大小为合适的1服务(+16)+ 1特征(+19)+ 1特征值(+1),属性的数量是适当的2 16bit uuid值和1 128bit uuid值。

关于AN-B-029的限制,我提到的文档没有限制,但我可以看到您没有权限访问任何文档或SDK本身,所以请转到产品DA14580并导航到软件和工具。在那里,你会看到挂锁图标 - 点击即可接受协议,您将被授予将在几天内进行SDK访问。

谢谢mt_dialog.

dhrishi
离线
最后一次露面:3 years 4 months ago
加入:2017-02-10 09:56
你好,

你好,

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