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.

SimpleBLECentral如何接收SimpleBLEPeripheral发出的广播包



有三个问题

1、在BLE STACK 给的示例程序中SimpleBLECentral如何接收SimpleBLEPeripheral发出的广播包,能持续接收广播包吗,就像packet sniffer 那样。

2、广播包的接收在哪部分程序里?

3、广播数据能够动态改变吗,我想将用户数据加入到SimpleBLEPeripheral的广播包中,并且保证数据加入后能够被其他设别连接,可行吗?

谢谢

  • 1.只要Central不断的扫描,既可以持续接收到广播包。

    2.广播包数据的设置:GAPRole_SetParameter( GAPROLE_ADVERT_DATA, sizeof( advertData ), (uint8*)&advertData );,advertData 就是包含广播数据的数组。

    3.广播数据可以动态改变,改变广播数据前,先关闭广播,

    uint8 initial_advertising_enable = FALSE;

    GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &initial_advertising_enable );

    然后重新设置广播数据,GAPRole_SetParameter( GAPROLE_ADVERT_DATA, sizeof( advertData ), (uint8*)&advertData );

    再打开广播,

    uint8 initial_advertising_enable = TRUE;

    GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &initial_advertising_enable );

  •  当收到串口数据后触发一个串口事件时(自己添加的事件),将接收到的数据设为广播数据广播出去。用你提供的这种方式,结果是:通过串口助手给节点写一次串口停止广播,再写一次串口开始广播,就像一个开关一样。

    我想实现的是写一次串口就发送携带串口数据的广播包,完了之后恢复为初始的广播包。是一种交替的。

    还有 Central 扫描接收数据的程序在哪一部分呢,刚接触不太懂,求指导,谢谢!