亲爱的各位,
我正在建造一个定制的BLE服务,我无意中发现了这个问题:
因为我需要使用一个AtTytMut-3大小,所以我只能在每个通知中发送20字节的数据。但是我必须发送一个更长的通知(例如36字节),所有这些字节需要存储在相同的特性中。现在我想知道是否有办法把这个数据分成2个通知。
我现在的部分将发送20字节数据的通知,我可以在客户端接收它。当我在客户端使用读函数时,我得到了36个字节的数据。每当我将长度从20更改为更大的通知时,该通知将不被发送,我知道这与AtTytMTU大小有关。(我不想增加ATTHMTU的大小!)!)
无效更新(无效)
{
如果(CyByLyGestStand())!= CyBySt-状态连接
{
返回;
}
CyBLY-GATSH-HANDLY ValueEntfft瞬变;
ToPHANDEL.AtHuffRe= CyByLyPrimultHub句柄;
TyPHANDEL.ValueVal=(U
ti8*)和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
datain 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");
}
}
0