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.

BLE Multi senor Sync in broadcaster observer method & central, peripheral

Other Parts Discussed in Thread: CC2541, TEST2

Hi,

We are working on BLE Multi sensor synchronization. In that one is master Sensor & others 2 are slaves. We are using CC2541 & stack version is BLE-CC254x-1.4.2.2.

We explored 2 methods.

Method 1: peripheral+Broadcaster, peripheral+ Observer

Method 2:Central, peripheral

Data packet length is 8 byte.

Method 1

Master sensor is in Peripheral + Broadcaster role

Slave sensors are in Peripheral + Observer role.

Master BLE will broadcast the message to other Slaves based on the external trigger input.

Master BLE will advertise when it is required to send information to observer in non connectable method.

The minimum advertising interval of non connectable advertise is 100ms.

To avoid the data loss, same trigger information will advertise 3 times.

For optimize the non connectable advertise time, We are enabling & disabling the Advertise for 3 times.

After following the above step, we could able to receive data in slave around 7-9ms in 1st attempt , 15-18ms in 2nd time and having data loss

Observer settings are as follows

// Maximum number of scan responses
#define DEFAULT_MAX_SCAN_RES 16

// Scan duration in ms
#define DEFAULT_SCAN_DURATION 4000

// Discovey mode (limited, general, all)
#define DEFAULT_DISCOVERY_MODE DEVDISC_MODE_ALL

// TRUE to use active scan
#define DEFAULT_DISCOVERY_ACTIVE_SCAN FALSE

// TRUE to use white list during discovery
#define DEFAULT_DISCOVERY_WHITE_LIST FALSE

GAP_SetParamValue( TGAP_GEN_DISC_SCAN, DEFAULT_SCAN_DURATION );
// GAP_SetParamValue( TGAP_LIM_DISC_SCAN, DEFAULT_SCAN_DURATION );

GAP_SetParamValue( TGAP_GEN_DISC_SCAN_INT, 16);
GAP_SetParamValue( TGAP_GEN_DISC_SCAN_WIND, 16);
GAP_SetParamValue(TGAP_FILTER_ADV_REPORTS,FALSE);

 

Problem:

How we  can avoid the data loss in method1.

Method2

Master BLE is in Central role

Slave BLE is in Peripheral role.

Master BLE will connect to 2 peripheral when it is powered on. 2 Peripheral MAC address are hard coded.

We have measured the timings in BLE-CC254x-1.4.0 stack

Below are the timing details

Connection interval 7ms. Advertising interval is 62ms

Method 2

Master Sensor1 ms

Sensor2ms

Sensor3 ms

TEST1 Started sampling in

0

23

30

TEST2 Started sampling in

0

72

79

TEST3 Started sampling in

0

42

48

TEST4 Started sampling in

0

15

20

TEST5 Started sampling in

0

90

100

TEST6 Started sampling in

0

10

103

TEST7 Started sampling in

0

30

140


Connection interval 7ms. Advertising interval is 20 ms

Method 2

Master Sensor1 ms

Sensor2ms

Sensor3 ms

TEST1 Started sampling in

0

35

90

TEST2 Started sampling in

0

35

90

TEST3 Started sampling in

0

110

165

TEST4 Started sampling in

0

25

80

TEST5 Started sampling in

0

45

190

TEST6 Started sampling in

0

35

80

TEST7 Started sampling in

0

35

75

  1. How to reduce the data transmission time.

  2. Is it possible to send the same data to 2 peripherals at a time. Whether 2 peripheral will receive the message at a same time.

  3. How to synchronize the timings between 3 device.

Other issues

  • BLE device is not advertising after some time which advertise before. Even after power reset device is in same state. We have seen that after re-flashing the device is coming up.

  • BLE device has paired with Android device. We have observed that the communication is not happening after some time. To workaround we unpaired & paired the device again. For your information, We are using BLE-CC254x-1.4.2.2. 

 

Regards,

Kayathri

 

  • Hi,

    What do you mean by data loss? Can you try these observer parameters for method 1:
    GAP_SetParamValue( TGAP_GEN_DISC_SCAN_INT, 176);
    GAP_SetParamValue( TGAP_GEN_DISC_SCAN_WIND, 176);

    You can initiate sending the data at the same time from the master, but the controller will send the data over the air at the next connection event.
    What do you mean by synchronizing the timings between the three devices, do you want a timestamp on the sensor data?

    Best wishes
  • Hi Zahid Haq,

    Observer is not receiving all the data what broadcaster is transmitting.

    I have changed the TGAP_GEN_DISC_SCAN_INT, TGAP_GEN_DISC_SCAN_WIND to 176. In that, out of 300 packet 6 packet is not received in observer. In this method data transmission time is predictable but data loss is the problem. Guide me on how to receive all the ADV packet in observer side. Am i missing anything?

    I am exploring another method due to problem in above one. In central, peripheral method timing is not deterministic. I need to synchronize the BLE. FYI, Sensor is connected to different MCU & Sensor MCU is connected to BLE via UART. I require time stamp on sensor data. In this scenario, from where do i take time stamp for better accuracy

    Regards,
    Kayathri
  • Hi Zahid Haq,

    Device is receiving all the data if it is scanning only (not advertising) . If the device is in peripheral+observer role device is advertising as well as scanning.So, Data loss is there

    I moved to connection method (central, peripheral). I can connect 2 peripheral device. But If one device is connected, Scanning is not happening till 1st peripheral terminates the connection. Does TI CC2541 BLE stack BLE-CC254x-1.4.2 support the scanning feature if central is already connected to one peripheral

    I followed below link to work on multi connection
    e2e.ti.com/.../1939343

    Earlier I used notification method but I need ACK for data transfer. I want to transfer 256 bytes of data between central & peripheral.

    I can read & write values of SIMPLEPROFILE_CHAR5_UUID using GATT_WriteCharValue & GATT_ReadCharValue API.

    How to use GATT_WriteLongCharValue & GATT_readLongCharValue in central & peripheral code for larger bytes. I am not getting Response message using LongCharValue. I am using SimpleBLEPeripheral & SimpleBLECentralMulti.

    Please share the example code for the same.


    Regards,
    Kayathri
  • Hi,

    Yes, it should be possible to scan after the connection. Are you not getting a GAP_DEVICE_DISCOVERY_EVENT after starting the discovery? You said you are able to connect to 2 devices so you are able to scan for the second device.

    Refer to here for an example on how to do long writes:
    e2e.ti.com/.../212423

    The write callback will be called several times with different offset based on the length of the data being sent.

    Best wishes
  • Hi Zahid Haq,

    I am able to detect 2nd peripheral while already central is connected to a peripheral by following this thread e2e.ti.com/.../1939343

    Problem was GAP_DEVICE_DISCOVERY_EVENT getting detected but simpleBLEScanRes is 0.

    I will see the Writelongvalue & update the result

    Thank you,
    Regards,
    Kayathri
  • Hi Zahid Haq,

    Now I can read 200 bytes of data from cc2541 SimpleBLEPeripheral using ATT_ReadBlobReq command in Btool.

    I have tried ATT_PrepareWriteReq from Btool. Device is not received any request and simpleProfile_WriteAttrCB is not getting called.

    How this GATTServApp_SetParameter(GATT_PARAM_NUM_PREPARE_WRITES, 1, &u8VarWithNumber); relates to that.

    Help me to move forward

    Regards,
    Kayathri
  • Hi,

    To write long attributes, you would call ATT_PrepareWriteReq() a number of times based on the amount of data with the corresponding offset, then you would call ATT_ExecuteWriteReq() to actually write the complete value.

    The parameter GATT_PARAM_NUM_PREPARE_WRITES determines how much memory is allocated to hold the data for the prepare writes.

    Best wishes
  • Hi Zahid Haq,

    Thank You for your guidance. It helped a lot.

    Now i can send & receive data in central & peripheral.

    My aim is to do multi sensor time synchronization & sensor is connected in external MCU not in cc2541. So i need to exchange packets for time synchronization via BLE.

    To send data from master BLE to slave BLE(Write request method), it is taking 80ms to 90ms . To send data from peripheral to central (indication method), it is taking 80 to 90ms

    Due to 80ms delay i cannot get time synchronization with good accuracy. Is it possible to reduce the data transmission timing further in BLE?

    Connection parameter settings are as follows

    Central side

    // Maximum number of scan responses
    #define DEFAULT_MAX_SCAN_RES 8

    // Scan duration in ms
    #define DEFAULT_SCAN_DURATION 4000

    // Discovey mode (limited, general, all)
    #define DEFAULT_DISCOVERY_MODE DEVDISC_MODE_ALL

    // TRUE to use active scan
    #define DEFAULT_DISCOVERY_ACTIVE_SCAN TRUE

    // TRUE to use white list during discovery
    #define DEFAULT_DISCOVERY_WHITE_LIST FALSE

    // TRUE to use high scan duty cycle when creating link
    #define DEFAULT_LINK_HIGH_DUTY_CYCLE FALSE

    // TRUE to use white list when creating link
    #define DEFAULT_LINK_WHITE_LIST FALSE

    // Default RSSI polling period in ms
    #define DEFAULT_RSSI_PERIOD 1000

    // Whether to enable automatic parameter update request when a connection is formed
    #define DEFAULT_ENABLE_UPDATE_REQUEST FALSE

    // Minimum connection interval (units of 1.25ms) if automatic parameter update request is enabled
    #define DEFAULT_UPDATE_MIN_CONN_INTERVAL 16

    // Maximum connection interval (units of 1.25ms) if automatic parameter update request is enabled
    #define DEFAULT_UPDATE_MAX_CONN_INTERVAL 16

    // Slave latency to use if automatic parameter update request is enabled
    #define DEFAULT_UPDATE_SLAVE_LATENCY 0

    // Supervision timeout value (units of 10ms) if automatic parameter update request is enabled
    #define DEFAULT_UPDATE_CONN_TIMEOUT 600

    Peripheral side


    // What is the advertising interval when device is discoverable (units of 625us, 160=100ms)
    #define DEFAULT_ADVERTISING_INTERVAL 160

    // Minimum connection interval (units of 1.25ms, 80=100ms) if automatic parameter update request is enabled
    #define DEFAULT_DESIRED_MIN_CONN_INTERVAL 8

    // Maximum connection interval (units of 1.25ms, 800=1000ms) if automatic parameter update request is enabled
    #define DEFAULT_DESIRED_MAX_CONN_INTERVAL 8

    // Slave latency to use if automatic parameter update request is enabled
    #define DEFAULT_DESIRED_SLAVE_LATENCY 0

    // Supervision timeout value (units of 10ms, 1000=10s) if automatic parameter update request is enabled
    #define DEFAULT_DESIRED_CONN_TIMEOUT 1000

    // Whether to enable automatic parameter update request when a connection is formed
    #define DEFAULT_ENABLE_UPDATE_REQUEST FALSE

    Regards,

    Kayathri
  • Hi,

    I am opening new thread for time optimization between central & peripheral.

    Regards,

    Kayathri