Hi,
在我的应用程序中,使用从控制器上发送的命令创建GATT DB。我绝不使用标准配置文件或甚至是对话框SDK提供的自定义服务/特征。我现在已经完成了填充GATT数据库并开始广告。我可以在NRF应用程序中看到附件,并能够连接到它。
现在,我想抓住阅读,写和所有其他事件/请求(MTU信息,连接,断开,指示),以便我可以执行它们。我可以在user_catch_rest_hndl()中这样做吗?
If yes, what are the exact events I need to handle? I tried with GATTC_WRITE_CMD_IND, GATTC_READ_IND, GATTC_READ_CMD_IND but the control doesn't reach there (added breakpoints to check)
如果没有,那么这样做的正确方法是什么?
谢谢,
hrishikesh.
设备:
Hi dhrishi,
The indications that you are refering to the GATTC_WRITE_CMD_IND, etc are commands that are send from the BLE stack and then conveyed to the applications in order to reach the catch_rest_handler function. Since you are implementing something completely custom you wont be able to use the infastructure that the SDK provides for the custom profiles. I am not sure how exactly you are creating the database or on which tasks you have assigned the profile that you have created. So i can only assume the reasons that you dont get the indications. If you have the BLE_CUSTOM1_SERVER definition in order for the custom task to be created but you are still using the basic implementation of the custs_profile that the SDK provides then perhaps the messages are served and handled by the existing implementation of custom profile and thats why you dont get anything in the catch_rest function. Try to set to 1 the EXCLUDE_DLG_CUSTS1 definition and check if the catch_function is executed.
Thanks MT_dialog
我会尝试将complude_dlg_custs1设置为1并执行。
I have assigned the profile to TASK_APP and I do not have BLE_CUSTOM1_SERVER.
用于GATT数据库创建的命令:
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);
在这种情况下,堆栈将提供给读/写/指示/ mtu协商的应用程序的事件是什么?
Can they be caught in user_catch_rest_hndl() or is there any other method for the same.
Hi dhrishi,
内核未处理的所有消息都将传达给Task_App(如果是消息的目标),因此如果您使用Gattm_add_svc_req创建服务时,它已将其填充与task_app的结构的task_id成员任务然后可以由user_catch_rest_hndl()函数处理关于该数据库的所有消息。关于您可以处理哪些消息,从TAFT_APP和GAPC,GAPM,邮件中的GATTC中的消息可以被处理,包括GATTC_WRITE_CMD_IND以及关于阅读的MTU_EXCHANGE,我不认为您将是能够获得该消息,自目前仅由RW配置文件支持。
Thanks MT_dialog
因此,如果我创建了使用task_app发送内核邮件的自定义数据库,而不是使用任何标准配置文件,那么我如何处理读取消息。
此外,在填充数据库并启动广告后,当中央(智能手机上的NRF应用程序)连接我所看到的是:
I get a message with msgid 0x11 in user_catch_rest_hndl(). When I checked the SDK it maps to GATTM_DESTROY_DB_RSP. Is anything wrong in here? When do we get this message?
此外,对于相同的值0x11,我看到它映射到gattc_write_cmd_cfm。那么,将被考虑哪一个。
In short I see multiple messages for one value. With the tasks that I have used for my GATT database configuration, could you please let me know which messages (from which files in SDK) I need to consider
I did not get the MTU info message. How do I get the value of current MTU for the communication?
是下面的呼叫强制性吗?或者这可以有效果吗?
attmdb_svc_set_permission(svc_hdl, PERM(SVC, ENABLE));
我既没有禁用一开始也不启用它。甚至在自定义数据库人口的情况下是必要的吗?不能使用上面的呼叫导致上面的问题?
When I write from the central device, I get message 0x0e which is GATTC_WRITE_CMD_IND (I suppose). Is it correct?
当我从中央设备读取时,我在user_catch_rest_hndl()中没有Mesage。我如何处理阅读?
Hi dhrishi,
Regarding the reading as i ve mentioned above, is not possible, you wont be able to get the GATTC_READ_IND in the user_catch_rest_hndl() function, the message is not conveyed to the application. What is done in SDK5.0.4 in order to get the read commands is that a new message is added (ATTS_READ_REQ_IND). So what you can do is to register the TASK_APP for that message by using the dg_register_task_for_read_request(TASK_APP);, by doing that you will be able to catch the ATTS_READ_REQ_IND in the user_catch_rest_hndl() and check the handle that is read. Also you will have to respond to that message using the dg_atts_read_cfm() function (if you dont respond this will result in a disconnection).
The message that you get 0x11 corresponds to the GATTM_DESTROY_DB_RSP that means that at some point possibly when you connect you invoke the GATTM_DESTROY_DB_REQ since this is the response that you get, but its not only the message that counts you will have to check also the task that the message comes from. If you dont invoke the destroy database i dont think that the database destruction confirmation is what you see.
关于您没有在Task_App(MTU_EXCHANGE,GATTC_WRITE_CMD_IND)中获取任何消息的事实,在发送GATTM_ADD_SVC_REQ时是否将TASK_ID声明为TASK_APP?除此之外,我无法猜测任何其他原因都让人创造了数据库的创作(你得到了对数据库的响应的事实,如果这是你得到的话,那就太好了。关于它的一个gattc_write_cmd_cfm,这不是你在执行写的时候得到的指示,也是一个gattc_的确认,这意味着在收到gattc_cmp_evt时应发生这种情况(如果您发出的命令,则应完成您应该完成完成的命令),所以你首先要抓住gattc_cmp_evt的情况,然后可以检查req_type参数以确定完成的事件。这对您获得的大多数消息有效。
如果您在创建时未禁用服务(作为AN-B-029 DO的示例),则设置的权限调用不是强制性的,然后它不义务调用权限的启用。另一方面,如果您已禁用该服务并且在连接时启用它,则无法读取或写入该特性。
If you write from the central device the proper message that you should get is the GATTC_WRITE_CMD_IND, and you should be able to catch it outside a GATTC_CMP_EVT.
Regarding the reading of the characteristic please check at the beggining of your question.
Thanks MT_dialog
Hi,
在每个服务的DG_REGISTER_TASK_FOR_READ_REQUEST(TASS_APP)的帮助下,当我从某些中央设备写入时,我在user_catch_rest_hndl()中获取ATTS_READ_REQ_IND。通过上面的说明,我看到DG_atts_Read_cfm()需要与适当的状态代码一起使用,并且在内部发送实际的读取响应。如果我想从应用程序本身发送数据,是否可能?
我的意思是,我不会将特征值存储在DA14580 GATT数据库中。当我转发收到的读取请求时,我将实际值作为来自控制器的响应。是否有一个机制/ api,我可以用来完全通过自己发送读取响应(以及数据)。
关于写请求,如果我有uint8_t类型的特征,如果中央设备在它上写入2个字节(uint16_t),那么sdk会做什么?
我所看到的是,在这种情况下,我没有得到gattc_write_cmd_ind事件。在生成事件之前是否有关于数据类型和/或大小的检查?
About the GATT database, all the services, characteristics and descriptors are added with dest_id as TASK_ATTM and src_id as TASK_APP.
大约0x11事件,我看到,当任何中央连接到我的设备时,我得到0x11事件差不多2-3次。那可以是什么?我不是从我的代码中调用gattm_destroy_db_req。
此外,为MTU交换收到的明确事件是什么。我无法在活动中找到它。我基本上希望协商的MTU值为要发送到控制器的当前连接。
我无法理解你的以下声明:
If you write from the central device the proper message that you should get is the GATTC_WRITE_CMD_IND, and you should be able to catch it outside a GATTC_CMP_EVT.
您能否在user_catch_rest_hndl()中使用上面的gattc_cmp_evt和gattc_write_cmd_ind给我一个样本示例。简而言之,在函数中使用gattc_cmp_evt。
Hi dhrishi,
dg_register_task_for_read_request,它是它使用的函数,以便在中央读取特征时对应用程序指示,而不是在写它时。关于你的第二个问题,如果可以在设备读取数据库时可以向确认发送数据,这是不可能的,因为我提到的那样,这是一个修补程序和数据发送到中心的数据库而不是申请提供。
If you send value of an invalid length for the characteristic the stack will return an error directly at the central, it wont get to application level for you to handle this kind of case, it will just inform the central that he has send an invalid attribute value length message.
关于0x11检查命令作为源的任务,以检查此命令实际的是什么。关于MTU,请检查RW-BLE-GATT-IS.PDF MTU请求由GATT_EXC_MTU_REQ启动,并使用相应的操作使用GATTC_CMP_EVT发出完成。
Regarding the GATTC_WRITE_CMD_IND what i mean is that you just have to catch it in the catch_rest_handler you dont have to catch the GATTC_CMP_EVT first and then check the operation, in case you were doing something like that, just use the switch() with a case of GATTC_WRITE_CMD_IND.
Thanks MT_dialog