Hi,
在我的应用程序中,GATT DB是使用从控制器通过UART发送的命令创建的。一、 决不能使用标准配置文件,甚至使用对话框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
我将尝试将EXCLUDE\DLG\u 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,
内核不处理的所有消息都会传递到任务\u应用程序(如果这是消息的目的地),因此如果,当您使用GATM\u ADD\uSVC_UREQ task id成员创建服务时,它的结构中已填充了task_UApp任务,那么有关此数据库的所有消息都可以由用户“catch”rest\uhndl()函数处理。关于您可以处理哪些消息、来自GATC的消息(作为任务应用程序的目的地)以及GAPC、GAPM的消息,可以处理消息,包括用于写入的GATC\u WRITE\u CMD_Uind和MTU交换,有关读取,我认为您将无法获得该消息,因为它目前只支持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_uwrite\ucmd\u 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?
当我从中央设备读取时,在用户_ucatch_urest_uhndl()中没有台面。那我该怎么处理阅读呢?
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.
关于您在发送GATM\u ADD\uSVC\u REQ时,在任务应用程序(MTU_UExchange、GATC_UWrite\u CMD\IND)中没有得到任何消息,您是否将任务id声明为任务应用程序?除此之外,我无法猜测任何其他原因都可以解释,创建数据库时出现了问题(如果您得到了这个结果,那么您对数据库销毁命令的响应看起来不太好)。关于它是否为GATC U WRITE\u CMD\u CFM,这不是执行写入时得到的指示,也不是因为它是GATC\uU确认,这意味着当您收到GATC\u CMP\u EVT(如果发出命令,您应该获得完成操作),因此,您首先必须捕获GATTC_ump_uuevt的情况,然后检查req\u类型参数,以确定完成的事件。这对于您获得的大多数邮件都有效。
如果您在创建时未禁用服务(如AN-B-029中的示例),则不必调用权限的启用。另一方面,如果您禁用了服务,并且在连接时未启用它,则您将无法读取或写入这些特性。
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 U register_task_U read_request(task_APP)的帮助下,当我从某个中央设备写入时,我会在用户捕获\u rest_uHNDL()中获得ATTS\u read_UREQUE\u IND。根据您的上述解释,我看到dg_Uatts_Uread_uCFM()需要与适当的状态代码一起使用,实际读取响应将在内部发送。如果我想从应用程序本身发送数据,是否可能?
我的意思是,我没有在DA14580 GATT数据库中存储特征值。当我转发接收到的这个读取请求时,我从控制器获得UART上的实际值作为响应。是否有一个机制/API,我可以完全自己发送读取响应(以及数据)。
关于写请求,如果我有uint8u t类型的特性,并且如果一个中央设备在它上写入2字节(uint16\u t),那么SDK会做什么?
我看到的是,在这种情况下,我没有得到GATC_Uwrite\uCmd\u 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 exchange接收的显式事件是什么。我在事件中找不到。我基本上希望将当前连接的协商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.
您能给我一个示例,说明使用GATC UCMP_UEVT和GATCC_UWrite\u CMD_IND in user_ucatch_rest_uHNDL(),外围设备的读写请求示例?总之,在函数中使用GATC_UCMP_UEVT。
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\U EXC\U MTU U炣REQ发起,并用GATC_UCMP_UEVT与相应操作一起发出完成信号。
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