使用通知问题

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.wsdof.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
5个帖子/ 0新
Last post
Max44
Offline
最后一次露面:9 months 2 weeks ago
加入:2016-02-08 15:58
使用通知问题

你好对话框,

我最近使用我希望你有所帮助的通知遇到问题。

一段时间我一直在逃跑g custom application based on the ble_app_peripheral example which records sensor data in an external memory. I implemented a command in an Android app that retrieves the recorded data and stores it in a file on an Android tablet. To do this (based on advice from this forum) I used a 20 byte characteristic with read, write, and notify properties. The procedure is to enable notifications from the Android app, then send a custom command to the DA to begin data transfer. This is simply sends 20 bytes with a notify message and waits until the notify is confirmed via CUSTS1_VAL_NTF_CFM, then sends 20 more bytes with another notify message. Then repeating the process until all the expected data is sent. This works great and I have sent large blocks of data using this technique.

Recently I tried adding notifications to another characteristic for some sensor data to be displayed when it changes. This characteristic already had the notify property defined but I hadn't used it. This also appears to work OK. When notifications are enabled the sensor data changes are sent when they are detected and I can display it on the Android tablet. This happens at a slow rate of once per second. However, in testing I found if I disable the sensor data notifications and then attempt a data transfer as described above, it starts, transfers a few thousand bytes and stops. The DA needs to be reset when this occurs. So far, I've been unable to determine why this is happening. It doesn't make sense to me why enabling/disabling notifications on another characteristic would cause a malfunction on my data transfer characteristic. In my experience with the DA14580 this appears to be similar behavior to messages not being consumed and accumulating until the system fails. I don't know how to verify if that's what is happening or not though ..... or if the problem is something else.

任何想法可能导致这个和/或我可能看的东西?到目前为止,我仔细阅读了user_custs1_def.c中的数据库描述和user_custs1_impl.c中的处理程序,并且到目前为止还没有看到任何不正确的。我在BLE_APP_PERITIALL中使用了ADC示例作为所需的指南。

谢谢你,马克斯

Device:
mt_dialog.
Offline
最后一次露面:2个月2周前
Staff
加入:2015-06-08 11:34
Hi Max44,

Hi Max44,

From the behaviour that you are describing i would assume the same thing, that you are generating messages and not consuming them (apparently the device hits an assertion of not being able to allocate memory), perhaps the connection interval of the current connection isn't frequent enough so that data that you are sending are not actually send but accumulated. I am not sure that i fully understand the testing that you perform. Check the assertion that you get and make sure that you hit the fail to allocate memory assertion and since that you have assured that this is the reason that your device stops responding check if you accidentally somehow generate data without actually sending them.

谢谢mt_dialog.

Max44
Offline
最后一次露面:9 months 2 weeks ago
加入:2016-02-08 15:58
公吨,

公吨,

对不起。我试图简短而不是用太多信息来负担你。我将把我的测试更详细地描述,希望能够为您提供更清晰的图片我试图做什么以及我得到的故障。

我认为我不像上面提到的那样得到了一个断言错误,但我会重新审视这一点。我试图看看我在keil调试器中停止的地方,但并不清楚。我确实可以通过ON oud Stude获取数据传输以运行而不发生错误。也就是说,我读取并转移从SPI Flash到我的Android平板电脑的17,000字节(**)并将数据存储在平板电脑上的文件中。在检查时,平板电脑文件中的数据看起来正确。这似乎表明连接间隔是足够的,但我将其留在BLE_APP_PERITIELAL示例设置中,我认为我认为是10分钟和20 max。我曾经认为Custs1代码将根据Custs1_task.c:以下评论调整到连接间隔的内容:
gattc_cmp_evt消息,用于完成gattc_notify的完成
*一旦通知PDU已发送,请立即发送操作
* 空气。
因此,这发送了我在user_peripheral.c中获得的custs1_val_ntf_cfm,我用它来指示我可以发送下一个通知。这不是意味着BLE数据包已被传输?在我的情况下,由于我发送了20个字节,它应该在一个BLE传输中出去。

What's bothering me is that the data transfer works by itself and can send a large amount of data to the Android tablet. If I go and activate notifications on another characteristic, it causes the data transfer routine to fail. I'm having difficulty figuring out what the interaction is ..... or if I've done something stupid and/or have an error in the code somewhere. So far I haven't found an error in the code, but I'll keep looking.

谢谢你,马克斯

(** 17,000 bytes). 17,000 may seem like a strange number, but I'm really looking for 16,384 bytes. Because of the 20 byte characteristic (which as you know is determined by the BLE data payload), my algorithm for data transfer reads 1000 bytes from flash and pushes it out to the Android tablet with 50 x 20 byte notifications. I decided the easiest thing to do would be to run 17 iterations of this loop and let the tablet or PC data anaysis routine sift through the data and discard the extra. The BLE module and Android tablet are set up for a fixed 17,000 byte transmit and receive loop.

Max44
Offline
最后一次露面:9 months 2 weeks ago
加入:2016-02-08 15:58
公吨,

公吨,

我终于发现了什么是错的。事实证明Android应用程序未发送描述符以禁用通知即使触及GUI上的按钮以执行此操作。我正在使用的应用程序是由蓝牙开发者Studio + Android Studio生成的,并表现与蓝色放大镜相似。我的传感器数据特性具有用于读取,写入和启用通知的GUI按钮,以与我实现的DA14580自定义服务进行交互。触摸启用通知按钮将描述符与启用值发送并更改按钮以禁用通知。触摸按钮以禁用通知时,Android应用程序刚刚重新发送启用值。由于我每秒更新传感器数据一次,我期望禁用通知将切换回以更新读取的特征数据库。相反,当我在平板电脑上禁用时,我继续发送通知,从而导致错误。

I found that disabling notifications was a problem experienced by other Android developers with Android BLE service and there are some fixes suggested online if anyone else on this forum encounters this.

我做了纠正,看起来我现在正在收到描述符值,以便现在禁用DA14580上的通知。数据传输现在似乎在启用和禁用我的传感器数据特性上的通知后工作。

所以我们现在可以关闭这个话题。感谢收听!

问候,最大

mt_dialog.
Offline
最后一次露面:2个月2周前
Staff
加入:2015-06-08 11:34
Hi Max44,

Hi Max44,

感谢分享。

最好的问候mt_dialog.