关于GATT读写GATE外围设备的GATT DB

8 posts / 0 new
最后一篇
dhrishi
离线
最后一次露面:3 years 3 months ago
加入:2017-02-10 09:56
关于GATT读写GATE外围设备的GATT DB

你好,

In my application, GATT DB is created using commands sent over UART from a controller. I, in no way, use the standard profiles or even the custom services/characteristics provided by the Dialog SDK. I am now done with populating the GATT database and starting the advertisement. I can see the accessory in nRF application and am able to connect to it.
Now, I want to catch read, write and all other events/requests (mtu info, connection, disconnection, indication) so that I can act on them. Can I do that in user_catch_rest_hndl()
如果是,我需要处理的确切事件是什么?我尝试使用gattc_write_cmd_ind,gattc_read_ind,gattc_read_cmd_ind,但控制没有到达那里(增加了检查要检查的断点)
If not, then what is the right way of doing this?

Thanks,
Hrishikesh

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

嗨Dhrishi,

您指的指示要引用GATTC_WRITE_CMD_IND等,是从BLE堆栈发送的命令,然后传达给应用程序以达到CATCH_REST_HANDLER函数。亚博国际官网平台网址由于您正在实现完全自定义的内容,因此您不会使用SDK提供自定义配置文件的Fina菊库。我不确定您究竟是如何创建数据库,或者在哪些任务上,您已分配了所创建的配置文件。所以我只能承担你没有迹象的原因。如果您有BLE_CUSTOM1_SERVER定义,则为要创建的自定义任务,但您仍然使用SDK提供的CUSTS_PROFILE的基本实现,那么您可以通过自定义配置文件的现有实现和处理邮件,并且为什么没有在catch_rest函数中获取任何内容。尝试设置为1 exclude_dlg_custs1定义并检查catch_function是否已执行。

谢谢mt_dialog.

dhrishi
离线
最后一次露面:3 years 3 months ago
加入:2017-02-10 09:56
I will try to set EXCLUDE_DLG

I will try to set EXCLUDE_DLG_CUSTS1 to 1 and execute.
我已将配置文件分配给task_app,我没有ble_custom1_server。
Commands used for GATT database creation:
struct gattm_add_svc_req *req = KE_MSG_ALLOC(GATTM_ADD_SVC_REQ, TASK_ATTM, TASK_APP,
gattm_add_svc_req);

struct gattm_add_attribute_req * req = ke_msg_alloc(gattm_add_attribute_req,
task_attm,task_app,gattm_add_attribute_req);

struct gattm_att_set_value_req *req = KE_MSG_ALLOC(GATTM_ATT_SET_VALUE_REQ, TASK_ATTM, TASK_APP,
gattm_att_set_value_req);

In this case, what are the events that the stack will provide to the application for read/write/indicate/MTU negotiation?
它们是否可以在user_catch_rest_hndl()中捕获,或者是否有其他方法。

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

嗨Dhrishi,

All the messages that the kernel doesn't handle are conveyed to the TASK_APP (if that is the destination of the message), so if, when you have created the service with the GATTM_ADD_SVC_REQ the task_id member of the structure its been populated with the TASK_APP task then all the messages regarding this database can be handled by the user_catch_rest_hndl() function. Regarding which messages you can handle, messages from the GATTC that have as the destination the TASK_APP and also GAPC, GAPM, messages can be handled, including the GATTC_WRITE_CMD_IND for the writing and the MTU_EXCHANGE, regarding the reading, i dont think that you will be able to get that message since its supported currently only by the RW profiles.

谢谢mt_dialog.

dhrishi
离线
最后一次露面:3 years 3 months ago
加入:2017-02-10 09:56
所以,如果我创造了一个

所以,如果我创造了一个custom database sending kernel messages using TASK_APP and not using any of the standard profiles, then how do I handle the read message.
Also, after populating the database and starting the advertisement, when the central (nRF app on a smartphone) connects what I see is:
我收到msgid 0x11中的ysgid 0x11中的邮件,在user_catch_rest_hndl()中。当我检查SDK时,它映射到Gattm_Destroy_DB_RSP。这里有什么不对吗?我们什么时候收到这条消息?
Also, for same value 0x11 I see that it maps to GATTC_WRITE_CMD_CFM. So, which one is to be considered.
简而言之,我看到一个值的多条消息。通过我用于我的GATT数据库配置的任务,可以让我知道我需要考虑哪些消息(从哪些文件中的文件)

我没有得到mtu的信息。如何获得当前MTU的沟通价值?

Is the below call mandatory? Or can this have an effect?
attmdb_svc_set_permission(svc_hdl,perm(svc,启用));
我没有在beginni残疾人服务ng nor enabled it. Is it required even in case of a custom database population? Can not using the above call lead to the problem above?

当我从中央设备写入时,我得到消息0x0e,它是gattc_write_cmd_ind(我想)。这是正确的吗?
When I read from the central device, I get no mesage in user_catch_rest_hndl(). How do I handle read then?

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

嗨Dhrishi,

关于阅读作为上面提到的读数是不可能的,您不会在user_catch_rest_hndl()函数中获取gattc_read_ind,消息未传达给应用程序。在SDK5.0.4中在SDK5.0.4中完成了什么,以获取读取命令是添加了新消息(ATTS_READ_REQ_IND)。所以你可以做的是通过使用dg_register_task_for_read_request(task_app)来注册该消息的task_app;,通过这样做,您可以在user_catch_rest_hndl()中捕获atts_read_req_ind并检查读取的句柄。此外,您还必须使用DG_Atts_Read_cfm()函数响应该消息(如果您不响应这将导致断开连接)。

您获得0x11的消息对应于gattm_destroy_db_rsp,这意味着在您连接时的某些时候可能会调用gattm_destroy_db_req,因为这是您得到的响应,但它不仅是您必须要检查的消息,但它也必须检查的消息消息来自。如果您不调用Destroy数据库,我不认为数据库销毁确认就是您所看到的。

Regarding the fact that you dont get any of the messages in the TASK_APP (MTU_EXCHANGE, GATTC_WRITE_CMD_IND), when sending the GATTM_ADD_SVC_REQ have you declared the task_id as the TASK_APP ? Other than that i can not guess any other reason exept that there something wrong with the creation of the database (the fact that you get a response to the database destroy command doens't look good, if this is what you get). Regarding if its a GATTC_WRITE_CMD_CFM, this is not the indication that you get when you perform a write, also since its a GATTC_ confirmation that means that this should occur when you receive a GATTC_CMP_EVT (if you issue a command you should get the completetion), so you first have to catch the case of the GATTC_CMP_EVT and then you can check the req_type parameters in order to determine the event that completed. This is valid for most the messages that you get.

The set permissions invocation is not mandatory, if you have not disabled the service upon creation (as the examples in the AN-B-029 do), then its not obligatory to invoke the enabling of the permissions. On the other hand if you have disable the service and not enable it upon connection, then you will not be able to read or write the characteristics.

如果从中央设备编写,则应获得的正确消息是Gattc_Write_cmd_ind,您应该能够在GattC_cmp_evt之外捕获它。

关于阅读特色,请在提出您的问题上检查。

谢谢mt_dialog.

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

你好,

的帮助下dg_register_task_for_read_request(TASK_APP) for each service, when I write from some central device I get ATTS_READ_REQ_IND in the user_catch_rest_hndl(). With your explanation above, I see that dg_atts_read_cfm() needs to be used with appropriate status code and the actual read response is sent internally. If I want to send data from the application itself, is it possible?
I mean, I do not store the characteristic value in DA14580 GATT database. I get the actual value over UART as a response from a controller when I forward this read request which was received. Is there a mechanism/API I can use to send the read response (along with the data) entirely on my own.

About the write request, if I have a characteristic of type uint8_t and if a central device writes 2 bytes (uint16_t) on it then what does the SDK do?
What I see is, in that case I do not get the GATTC_WRITE_CMD_IND event. Is there a check about the data type and/or size before the event is generated?

关于GATT数据库,所有服务,特征和描述符都以DEST_ID添加为TASK_ATTM和SRC_ID作为TASK_APP。

About 0x11 event, I see that when any central connects to my device which is a peripheral, I get 0x11 event almost 2-3 times. What can this be then? I am not invoking GATTM_DESTROY_DB_REQ from my code.
Also, what is the explicit event that is received for MTU exchange. I could not find it in the events. I basically want the negotiated MTU value for the current connection to be sent to the controller.

I am unable to understand your below statement:
如果从中央设备编写,则应获得的正确消息是Gattc_Write_cmd_ind,您应该能够在GattC_cmp_evt之外捕获它。

Can you please give me a sample example of a read or write request of a peripheral device using above GATTC_CMP_EVT and GATTC_WRITE_CMD_IND in user_catch_rest_hndl()? In short the use of GATTC_CMP_EVT in the function.

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

嗨Dhrishi,

The dg_register_task_for_read_request, is function that it is used in order to have an indication to your application when a central reads the characteristic and not when it writes it. Regarding your second question, if it is possible to send data along with the confirmation when the device reads the database, this is not possible, as i ve mentioned this is a patch and data send to the central are taken from the database of the device and not provided from the application.

如果您向特性发送无效长度的值,则堆栈将直接在中央返回错误,它不会到达应用程序级别,以便您处理这种情况,它只通知中央发送无效属性值长度消息。

Regarding the 0x11 check the task that the command has as a source in order to check what this command actually is. Regarding the MTU, please check the RW-BLE-GATT-IS.pdf the MTU request is initiated by a GATT_EXC_MTU_REQ and the completion is signaled with a GATTC_CMP_EVT with the corresponding operation.

关于gattc_write_cmd_ind我的意思是你只需要在catch_rest_handler中捕获它,你不必先捕捉gattc_cmp_evt然后检查操作,万一你正在做的东西,只需使用switch()gattc_write_cmd_ind。

谢谢mt_dialog.