简体   繁体   English

STM BlueNRG-MS 最大特征长度

[英]STM BlueNRG-MS Max Characteristic length

My general understanding is that the BLE standard supports characteristics with a lenght of up to 512 bytes.我的一般理解是 BLE 标准支持的特征长度最大为 512 字节。 I'm using the BlueNRG-MS chip from STM but there the function call to add a characteristic has a uint8_t value for the length parameter我正在使用来自 STM 的 BlueNRG-MS 芯片,但是用于添加特征的 function 调用具有长度参数的 uint8_t 值

tBleStatus aci_gatt_add_char(uint16_t serviceHandle,
                 uint8_t charUuidType,
                 const uint8_t* charUuid, 
                 uint8_t charValueLen, 
                 uint8_t charProperties,
                 uint8_t secPermissions,
                 uint8_t gattEvtMask,
                 uint8_t encryKeySize,
                 uint8_t isVariable,
                 uint16_t* charHandle);

So this would allow only a maximum characteristic length of 255 bytes.所以这将只允许 255 个字节的最大特征长度。 According to this document the stack itself supports 2 bytes with FW 7.2 or higher.根据文档,堆栈本身支持 2 个字节,固件版本为 7.2 或更高版本。 I have 7.23 so this should be fine but I cannot find any reference or example of a BlueNRG-MS middleware that would support a call with charValueLen of type uint16_t .我有 7.23,所以这应该没问题,但我找不到任何支持使用uint16_t类型的 charValueLen 调用的charValueLen -MS 中间件的参考或示例。 I also downloaded the latest STSW-BLUENRG-DK and the examples also only support uint8_t charValueLen .我还下载了最新的 STSW-BLUENRG-DK 并且示例也仅支持uint8_t charValueLen

Yes, it supports charValueLen with uint16_t too.是的,它也支持带有 uint16_t 的 charValueLen。 Sample function would be as followed:样品 function 如下:

tBleStatus aci_gatt_add_char(uint16_t serviceHandle,
                         uint8_t charUuidType,
                         const uint8_t* charUuid, 
                         uint16_t charValueLen, 
                         uint8_t charProperties,
                         uint8_t secPermissions,
                         uint8_t gattEvtMask,
                         uint8_t encryKeySize,
                         uint8_t isVariable,
                         uint16_t* charHandle)
{
  struct hci_request rq;
  gatt_add_serv_rp resp;
  uint8_t buffer[26];
  ... // code omitted w/o needing modification

  Osal_MemCpy(buffer + indx, charUuid, uuid_len);
  indx +=  uuid_len;

  charValueLen = htobs(charValueLen);
  Osal_MemCpy(buffer + indx, &charValueLen, 2);
  indx += 2;

  buffer[indx] = charProperties;
  indx++;
  ... // code omitted w/o needing modification
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM