This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

关于仿写通知特征值simpleGATTprofile中Characteristic4的问题

有两个问题:

1. notify的数据长度最长有多少?是20字节么?在程序里体现了么?

2. Characteristic 4里是单字节的notify,如果改成多字节的,只要把和数据相关的地方参照characterristic5(多字节的特征)来改就可以了么?具体有哪些呢?

……小白跪谢!

  • 我修改的地方有:

    1. simpleBLEPeripheral.c 中 void SimpleBLEPeripheral_Init( uint8 task_id )里

        初始化:uint8 charValue4[SIMPLEPROFILE_CHAR4_LEN] = { 1, 2, 3, 4, 5};

    2. simpleGATTprofile.h 中定义#define SIMPLEPROFILE_CHAR4_LEN           5

    3. simpleGATTprofile.c 中:

    3.1 定义 static uint8 simpleProfileChar4[SIMPLEPROFILE_CHAR4_LEN] = { 1, 2, 3, 4, 5};

    3.2 属性表里 把simpleProfileChar4 之前的&去掉了

    // Characteristic Value 4
    {
    { ATT_BT_UUID_SIZE, simpleProfilechar4UUID },
    0,
    0,
    simpleProfileChar4
    },

    3.3 在bStatus_t SimpleProfile_SetParameter( uint8 param, uint8 len, void *value )里修改

    case SIMPLEPROFILE_CHAR4:
    if ( len == SIMPLEPROFILE_CHAR4_LEN )
    {
    VOID osal_memcpy( simpleProfileChar4, value, SIMPLEPROFILE_CHAR4_LEN );

    // See if Notification has been enabled
    GATTServApp_ProcessCharCfg( simpleProfileChar4Config, simpleProfileChar4, FALSE,
    simpleProfileAttrTbl, GATT_NUM_ATTRS( simpleProfileAttrTbl ),
    INVALID_TASK_ID );
    }
    3.4 在bStatus_t SimpleProfile_GetParameter( uint8 param, void *value )里修改:

    case SIMPLEPROFILE_CHAR4:
    VOID osal_memcpy( value, simpleProfileChar4, SIMPLEPROFILE_CHAR4_LEN );
    break;

    3.5 在 static uint8 simpleProfile_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr, uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen )里修改:

    case SIMPLEPROFILE_CHAR4_UUID:
    *pLen = SIMPLEPROFILE_CHAR4_LEN;
    VOID osal_memcpy( pValue, pAttr->pValue, SIMPLEPROFILE_CHAR4_LEN );

    结果是手持端开始notification以后没反应,修改的地方漏了什么么?

  • Michael,

    1, 最多只有20个字节,你可以在代码里面查找MTU研究一下。

    2. 是的,只要把单字节修改成数组,然后编译,有错误的地方照着改改就行。

  • 1. 谢谢~

    2. 我改了以上的地方,编译通过但是手持端没有数据发出来,不知道漏改了什么……

  • Yan

          你说notify最大可以是20个字节,为何我把这样定义

           SIMPLEPROFILE_CHAR1_LEN           20

           用btool调试会出现 ATTR_NOT_FOUND

    而定义为    SIMPLEPROFILE_CHAR1_LEN          19   

    就正常。能否解释一下,困扰了两天了。