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.

CCS/CC2650: How to send accelerometer movement data in BLE broadcast?

Part Number: CC2650

Tool/software: Code Composer Studio

I am trying to use CC2650 sensor tags on a movable entity to collect the accelerometer data for the entity.
I have placed multiple raspberry Pis in the entire perimeter where the entities move, which will collect the accelerometer data and forward it to the back-end.
There are multiple entities each carrying a CC2650 within it in the perimeter.

I want to send the accelerometer data as a payload in the BLE broadcast which can be received by the Raspberry Pi.
I have started working on simple_peripheral.c example code for the same. 

Can you please help me with below queries:

1. How to collect the accelerometer data ( I assume it is collected in sensortag_mov.c) in the simple_peripheral.c example file?

2. How to change the payload data that I need to send in the simple_peripheral.c? 

3. How to regulate the broadcast interval? I want to broadcast if I have enough data (size crosses a threshold) or timeout.

  • Hi Mahesh,

    1. Please use the sensortag code base to undestand how the accelerometer data is collected. You will need to manually migrate that code.
    2. I do not remember the API for CC2650 based SDK, but something in the line of GAPRole_SetParameter(GAPROLE_ADVERT_DATA, sizeof(advertData), advertData);
    3. Please see this SLA: 
  • J Lindh (5296913), thank you very much for the response.

    I am able to send an updated advertisement now with custom data in it.

    Now I want to add 6 bytes of accelerometer data and add it to the advData array.

    this is my code:

    void SensorTag_updateAdvertisingData(uint8_t keyStatus)
    {
        // Record key state in advertising data
        uint8_t data[6];
        
        // Collect accelaerometer data 
        SensorMpu9250_accRead((uint16_t*)data);
    
        uint8_t advData[] = {
                 0xD, 0x3, 'A', 'C', 'C', devID, packetID,
                 data[0],
                 data[1],
                 data[2],
                 data[3],
                 data[4],
                 data[5],
                 keyStatus
            };
        packetID++;
        if(packetID == 0) {
            packetID++;
        }
      	
        GAPRole_SetParameter(GAPROLE_ADVERT_DATA, sizeof(advData), advData);
    }

    The problem here is, I am getting the same 6 bytes data for the accelerometer.

    Even if I call "SensorMpu9250_gyroRead" instead of "SensorMpu9250_accRead", it gives me the same set of 6 bytes data.

    Note: I haven't changed the sensortag_mov.c, so I am assuming the initialization and resetting of SensorMpu9250 is already handled there.

    Can you please tell me how can I get the updated accelerometer data in this function?
  • Hello Mahesh,
    You are using GAP_ADTYPE_16BIT_COMPLETE AD type in your advData. You should either use GAP_ADTYPE_SERVICE_DATA or Manufacture Specific data. Please refer to the Supplement to the Bluetooth Core Specification (CSS) for detail s on AD types and format and review our example code.

    The accelerometer needs to be powered. Please review the soruce code and
    SensorTagMov_processCharChangeEvt
    case SENSOR_CONF:
    appStateSet(APP_STATE_ACTIVE); -> powers on and enables the movement sensor.

    This is usually done from the connected client (Master) in normal demo operations.