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.

请教下,关于修改协议来实现发送多个数据问题

Other Parts Discussed in Thread: CC2540

你好

1:修改了SimpleProfile_SetParameter,里面给数组赋值和写了长度,但是仍然是只收到1个字节,需要修改协议哪里呢?

2:read和notify有什么区别呢?

  • Li,

    1,是SimpleBLEPeripheral吗? 具体你是怎么调用这个函数写的呢?

    2. read 是central主动发起请求,要peripheral 发数据过去。notify是peripheral 主动把数据发给central.

  • 首先,感谢您这么快回复!非常感谢!

    1:是的,现在修改了2个地方

    simpleBLEPeripheral.c中,修改函数static void performPeriodicTask( void )中,

    SimpleProfile_SetParameter( SIMPLEPROFILE_CHAR4, 0x05, &valueToCopy);

    在,simpleGATTprofile.c里面修改

    bStatus_t SimpleProfile_SetParameter( uint8 param, uint8 len, void *value )
    ....

    case SIMPLEPROFILE_CHAR4:

    if ( len ==0x05 )
    {
    simpleProfileChar4 = *((uint8*)value);
    VOID osal_memcpy( simpleProfileChar4, value,0x05 );

    }
    break;

    ................................

    修改这2处后,还是不能收到发出的数据,在characteristics 4改过后,在characteristics 2,3都试过了,应该还需要修改什么地方吧?

    2:请问在read中,例如手机发起请求,以SimpleBLEPeripheral为蓝本,通过characteristics 1,发送1个字节给 cc2540,然后cc2540收到后,怎么发给手机呢,直接发送吗?还是要遵循什么协议呢?

      谢谢

  • 楼主,

    1.你要把 static uint8 simpleProfileChar4 = 0;改成一个数组,如

    static uint8 simpleProfileChar4[10];

    2.修改属性表static gattAttribute_t simpleProfileAttrTbl[]=

    {

    // Characteristic Value 4
    {
    { ATT_BT_UUID_SIZE, simpleProfilechar4UUID },
    0,
    0,
    simpleProfileChar4 //用数组名
    },

    }

    3.修改特征值属性static uint8 simpleProfileChar4Props = GATT_PROP_NOTIFY;//原始属性只有Notify,而不可读写。

    static uint8 simpleProfileChar4Props = GATT_PROP_NOTIFY|GATT_PROP_READ | GATT_PROP_WRITE;

    4.修改特征值写回调函数simpleProfile_WriteAttrCB及读回调函数simpleProfile_ReadAttrCB。这个可以参照Char1

    OK,祝你成功!

  • 你好:

      我是这样设置的,但主机向从机发送5个字节的数据,从机还是只能收到一个字节,不知道哪里设置错误,期待你的回答,谢谢