完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
亲爱的各位,
我正在建造一个定制的BLE服务,我无意中发现了这个问题: 因为我需要使用一个AtTytMut-3大小,所以我只能在每个通知中发送20字节的数据。但是我必须发送一个更长的通知(例如36字节),所有这些字节需要存储在相同的特性中。现在我想知道是否有办法把这个数据分成2个通知。 我现在的部分将发送20字节数据的通知,我可以在客户端接收它。当我在客户端使用读函数时,我得到了36个字节的数据。每当我将长度从20更改为更大的通知时,该通知将不被发送,我知道这与AtTytMTU大小有关。(我不想增加ATTHMTU的大小!)!) 无效更新(无效) { 如果(CyByLyGestStand())!= CyBySt-状态连接 { 返回; } CyBLY-GATSH-HANDLY ValueEntfft瞬变; ToPHANDEL.AtHuffRe= CyByLyPrimultHub句柄; TyPHANDEL.ValueVal=(Uti8*)和MyDATA; TyPHANDEL.Value.Le= siZeof(MyDATA); CybLyggTraceWrrestAtvestValue:(0;and CysLyCon句柄,0); 如果(CyBygGATGETBUSTSTATUS()= = CyByth-StaskStaseEnFiel&App.;通知) { BelysEngEngress(CysLyPrimultRoad,(UTIN 8*)和GaIDATA,20); } } 虚空BelsSeNeNebug(CysLyggdBdAtdulAddiLext特性,UTI8*数据,UIT16长度) { CyBLY-GATSH-HANDLYVALIONEVITY NTFIFT通知; Valtual.Value.Val=数据; 长度=长度; 特征句柄=特征; 如果(CyBLY-GATS通知)(CyByLyCon句柄,和通知)!CyelyyeloRosiok { dggpPrimTf(“错误发送通知 rn”); } 其他的 { dggPrimtf(“发送通知 rn”); } } 以上来自于百度翻译 以下为原文 Dear all, I'm building a custom BLE-Service and i've stumbled on the folowing problem: Since I am required to use a ATT_MTU-3 Size i can only send 20 bytes of data in each notification. But I have to send a notification which is longer (e.g. 36 bytes) and all these bytes need to be stored in the same characteristic. Now I am wondering if there is a way to split this data into 2 notifications. The part i have now will send a notification of 20 bytes of data and i can receive it on the client side. When i use the READ function on the client side i get the full 36 bytes of data. Whenever i change the length from 20 to anything larger the notification will not be send, I am aware that this has to do with the ATT_MTU size. (I do not want to increase the ATT_MTU size!!) void UpdateGaid(void) { if(CyBle_GetState() != CYBLE_STATE_CONNECTED) { return; } CYBLE_GATTS_HANDLE_VALUE_NTF_T tempHandle; tempHandle.attrHandle = CYBLE_CHARACTER_HANDLE; tempHandle.value.val = (uint8 *)&MyData; tempHandle.value.len = sizeof(MyData); CyBle_GattsWriteAttributeValue(&tempHandle, 0, &cyBle_connHandle, 0); if(CyBle_GattGetBusStatus() == CYBLE_STACK_STATE_FREE && Notify) { ble_SendNotification(CYBLE_CHARACTER_HANDLE, (uint8 *)&GaiData, 20); } } void ble_SendNotification(CYBLE_GATT_DB_ATTR_HANDLE_T characteristic, uint8* data, uint16 length) { CYBLE_GATTS_HANDLE_VALUE_NTF_T notification; notification.value.val = data; notification.value.len = length; notification.attrHandle = characteristic; if (CyBle_GattsNotification(cyBle_connHandle, ¬ification) != CYBLE_ERROR_OK) { DBG_PRINTF("ERROR sending notificationrn"); } else { DBG_PRINTF("sending notificationrn"); } } |
|
相关推荐
3个回答
|
|
如果你想把一个特性分成两个单独的通知,我怀疑是否有办法做到这一点。
但是,如果你只是想让你的数据分离通知包,那么你可以设置你的发送服务器来发送两个不同的通知(比如NTF1和NTF2),每个通知都包含一部分数据。然后,您只发送NTF1一半的通知,然后发送NTF2一半,在接收侧重建原始特征/数据。不幸的是,这将需要两个单独的特性,但这将允许您区分数据的第一和第二部分。 另一种选择是将两个通知发送到同一个特性上,然后接收和存储通知数据到重新组装的包中。然而,这可能会覆盖你原来的特性。 以上来自于百度翻译 以下为原文 If you are wanting to split a single characteristic into two separate notifications, I would be doubtful there is a way to do that But, if you just want your data in to separate notification packets, then you could probably setup your sending-server to send two different notifications (say NTF1 and NTF2) that would each contain part of the data. Then, you merely send a notification with the NTF1 half, and send a NTF2 half afterwards, rebuilding the original characteristic/data on the receiving side. This would require two separate characteristics unfortunately, but would allow you to differentiate between the first and second half of the data. The other option, is to send both notifications on the same characteristic you have right now, and then to receive and store the notification data into the reassembled packet. This might overwrite your original characteristic however. |
|
|
|
yuhe82 发表于 2018-11-28 09:52 你好,你有什么关于如何建造这个的例子吗?但是,如果你只是想让你的数据分离通知包,那么你可以设置你的发送服务器来发送两个不同的通知(比如NTF1和NTF2),每个通知都包含一部分数据。然后,您只发送NTF1一半的通知,然后发送NTF2一半。 以上来自于百度翻译 以下为原文 e.pratt_1639216 Hello, do you have any example on how to build this? "But, if you just want your data in to separate notification packets, then you could probably setup your sending-server to send two different notifications (say NTF1 and NTF2) that would each contain part of the data. Then, you merely send a notification with the NTF1 half, and send a NTF2 half afterwards" |
|
|
|
hzy_jack 发表于 2018-11-28 10:09 不幸的是,我没有一个例子,但这将是与处理IP碎片(IP碎片-维基百科)相同的理论/实践。 你基本上是在获取数据,而不是同时尝试发送所有数据,而是在每一个数据包中发送一部分数据,然后接收端对数据进行分类和重新组合以供使用。 例如: 要发送0xAA,0xbb的“长”数据,您将发送一个通知 0x01,0xAA表示第一段数据是0xAA(0x01是接收端重新排序数据包) 接下来,您将发送一个带有0x02、0xbb的数据包,表示第二部分的数据是0xbb(0x02是用于接收端重新排序数据包)。 接收方需要做大量的工作来处理丢失的数据包,并在使用之前验证所有数据是否存在。但是,在精确的顺序/数据格式上进行一点尝试和错误应该是可行的。 您可能需要某种方式来指示通知的重试、您期望的数据包/通知的数量以及接收到的所有数据的使用。 以上来自于百度翻译 以下为原文 Unfortunately, I don't have an example of this, but it would be the same theory/practice as dealing with IP Fragmentation (IP fragmentation - Wikipedia ) You essentially take your data, and instead of trying to send it all at the same time, you send part of it in each packet, and the receiving side then sorts and recombines the data for use. For example: To send the "long" data of 0xAA,0xBB, you would send a notification with 0x01, 0xAA to signify the first section of data is 0xAA (0x01 is for the receiving side to reorder the packets) Next you would send a packet with 0x02, 0xBB to signify the second section of data is 0xBB (0x02 is for receiving side to reorder the packets) The receiving side would need to do alot of work to deal with missing packets of data, and verifying all of the data is present before using it. But it should be feasible with a little bit of trial and error on the exact sequencing/data formats. You will probably need to have some way to signal a retry of the notification, how many packets of data/notifications you expect, and all data received for use. |
|
|
|
只有小组成员才能发言,加入小组>>
752个成员聚集在这个小组
加入小组2069 浏览 1 评论
1824 浏览 1 评论
3633 浏览 1 评论
请问可以直接使用来自FX2LP固件的端点向主机FIFO写入数据吗?
1760 浏览 6 评论
1509 浏览 1 评论
CY8C4025LQI在程序中调用函数,通过示波器观察SCL引脚波形,无法将pin0.4(SCL)下拉是什么原因导致?
507浏览 2评论
CYUSB3065焊接到USB3.0 TYPE-B口的焊接触点就无法使用是什么原因导致的?
357浏览 2评论
CX3连接Camera修改分辨率之后,播放器无法播出camera的画面怎么解决?
410浏览 2评论
357浏览 2评论
使用stm32+cyw43438 wifi驱动whd,WHD驱动固件加载失败的原因?
854浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-22 06:49 , Processed in 0.840270 second(s), Total 81, Slave 64 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号