阻止DA14580的机制接收来自控制器的GATT读/写响应

⚠️
嗨,...感谢您来论坛。令人兴奋的消息!我们现在正在迁至我们的新论坛平台,将提供更好的功能,并包含在主对话框网站中。所有帖子和帐户都已迁移。我们现在只接受新论坛上的流量 - 请发布任何新线程https://www.dialog-seminile.com/support.。我们将在未来几天修复错误/优化搜索和标记。
6个帖子/ 0新
最后一篇
Dhrishi.
离线
最后一次露面:3年3个月前
加入:2017-02-10 09:56
阻止DA14580的机制接收来自控制器的GATT读/写响应

你好,

我们有一个外设解决方案,其中DA14580通过UART连接到我们的微控制器。DA14580查询控制器以获取来自中心的GATT读/写请求的特征值。
我们捕获read(atts_read_req_ind)和write(gattc_write_cmd_nind)事件在user_catch_rest_hndl()中
是否有一种机制可以阻止我们可以阻止,直到我们从控制器上从UART获取读取或写入请求的响应,然后从user_catch_rest_hndl()发送响应

简而言之,我们需要从user_catch_rest_hndl()中发送读/写请求并等待接收响应(UART中断),然后从user_catch_rest_hndl()发送响应数据。你能告诉我们这是怎么做的。任何指针,例子都会有所帮助。

Thanks,
hrishikesh.

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

嗨Dhrishi,

I dont quite understand the use case, you mention that the 580 is attached to the external MCU (i suppose this is what you mean when you say controller) and the controller provides the values for the characteristics.

  • 作为了解您所说的究竟是什么例子,让我们掌握ATTS_READ_REQ_IND这将一旦中央将读取580的特征,因此您将获得该消息,并且您希望阻止发送确认中央,直到您从外部处理器读取值?是你在说什么。
  • 关于GATTC_WRITE_CMD_IND,这将在中央写入指定的特征时触发,因此您希望在发送确认之前阻止(如果外设需要确认,因为存在不需要响应的写入,因为不需要响应)?

那么,上面的情景做出了你想做的事吗?

Thanks MT_dialog

Dhrishi.
离线
最后一次露面:3年3个月前
加入:2017-02-10 09:56
是的。确切地。那是对的。

是的。确切地。那是对的。
我们如何做到这一点

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

嗨Dhrishi,

没有例子你想做什么since the databases values are kept in the internal database of the 580, also i am not quite sure about the block that you mentioned, since as soon as you get the indication (that a central has read or written a characteristic) the SDK will just report that to the application and its up to you what you are going to do. As far as i can tell, regarding what you woulid like to do, most of the commands used in the BLE spec are sequential, that means that most of the commands (including the Read Request and the Write Request) when issued by the central they should be confirmed by the peripheral which means that the central cannnot send an additional request if it doens't get a response from the previous command (this request/response scheme is like a flow control that the BLE protocol implements). So you can get the indication from the read or the write request, catch them in the catch_rest function and start your UART transaction, the central wont issue any additional request until you send a confirmation message, so as soon as your UART transaction is complete you can send the confirm on the other side of the link. Also be aware that not all commands follow the request/response scheme, for example a write command (write with no response) will trigger your indication but the central wont wait for a response and it can still issue an additional command while processing the previous one and that requires an additional flow control scheme.

因此,根据上面,当读取指示来自中心时,可以通过UART写入UART。关于发送你从UART读取的价值,就像我在不同的帖子中提到的那样,你不能只发送你通过UART直接获得的值,但你必须尽快在内部数据库中设置值读取指示,然后发送读取的确认。因此,在读取接收时触发UART事务调用ATTMDB_ATT_SET_VALUE()以便在数据库中设置值,然后在DG_ATTS_READ_CFM()中发送值。

此外,请注意,当您从UART读取时,您将不得不醒来,因此没有睡眠以获得XTAL16。

Thanks MT_dialog

Dhrishi.
离线
最后一次露面:3年3个月前
加入:2017-02-10 09:56
I already have attmdb_att

我已经有Attmdb_att_set_value()和dg_atts_read_cfm()在我的实现中。问题是,当在user_catch_rest_hndl()中收到Atts_Read_Req_ind时,我将必须先向外部MCU发送请求,以获得该特征的值在数据接收时,调用上述两个功能。正确的?

现在,来自外部MCU的UART响应将来自中断上下文。因此,如何使当前执行线程在user_catch_rest_hndl()中等待,直到从外部MCU接收到适当的响应。否则它将通过调用以上两个功能来返回,其中垃圾/不正确值以及对中央的读取响应将不正确。

简而言之,我们应该等到接收到UART(从中断上下文)的响应,并且在GATT数据库中保存相同,然后发送读取确认。

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

嗨Dhrishi,

是的,这是我思考的,获取指示,启动UART事务,获取数据,并通过UART获得的值发送确认。

The 580 its not a thread based system, it just has a scheduler that schedules messages and executing the corresponding callbacks evertime the rwip_schedule() function runs from the main loop. So what you can try is, as soon as you get the reading indication, start the UART transaction or set up the UART for receiving data from the external MCU (that depends on your implementation and how the interaction will be) and either leave the catch_rest handler (by setting up an read interrupt) or stay there (executing the UART transastion, in that case you can't stay as long as you want executing UART transaction since you will start missing BLE event and eventually you will get disconnected since you wont be executing the scheduling function since you wont go through the main loop) as soon as the interaction gets completed. When the UART interrupt hits or the transaction has finished then just send the confirmation message to the client.

Thanks MT_dialog