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/CC1352R: Adding BLE stack/support to existing project

Part Number: CC1352R

Tool/software: Code Composer Studio

I am working with a custom board using the CC1352R to add BLE support to an existing project that currently only runs the sub-1GHz radio. This device will be a peripheral (advertise and wait for "master" to initiate connection).

I have looked through every document I can find and all of the information seems to start from the examples which already have the proper references set up. For example, I can see that the simple_peripheral project has a path variable SRC_BLE_DIR pointing to the ble5stack directory in the SDK and then some 'Other Repositories' based on that variable.

Do I just need to add this variable and (some of) these other repositories manually to my project? Or is there a "wizard" that I am missing to add BLE support to my existing project?

Also, the simple_peripheral application project seems to be dependent on a stack library project. The existing project that I am working with does have a TI-RTOS project on which it is dependent, but will/can it include the BLE stuff or do I need to create another "support" project for BLE?

Is there a guide that I have not found/noticed that provides the steps necessary to add BLE support to an existing project?

Thanks!
.Tim

  • Hi Tim,
    If I understand your use case correctly, i'd suggest you look into using the DMM. There are some useful OOB examples in the latest SDK;
    dev.ti.com/.../

    Otherwise, it's generally better to use a BLE based project and add whatever you need on top of that.
  • Joakim -

    Thank you for the response. I do not think I need the overhead of DMM as we will only be using BLE to provision the device in a special mode immediately following power-on and then can "switch it off" and run the "normal" activities with the sub-1GHz radio after that.

    It sounds like I should start with a BLE example and modify it to what I need, then add the sub-1GHz support I need to that project. If so, any suggestions on disabling one radio and enabling the other while running?

    Thanks again!
    .Tim
  • Hi Tim,

    In Joakim's absence (others from his team may reply also) I wanted to mention that our recommendation would still be to utilize DMM if possible, since this provides one of the more effective means in controlling not only the multi protocol operation, but also the state of each radio.  Check out this training video clip for DMM at around the 12:20 mark where it discusses this in more detail with the sample code shown:

    https://training.ti.com/multi-protocol-operation-cc1352

    As a less elegant method, one could also simply control the states of each radio via the sample project code itself, even outside of using DMM.  This below code will turn off advertising. You would simply just need to toggle advertising between FALSE and TRUE for example with the BLE advertising radio:

    1
    2
    AdvertEnable = AdvertEnable ^ 1;
    GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t), &AdvertEnable);

    Please let us know your thoughts and I'm sure together we can find a suitable solution for you.

    Regards,

    Chris

  • Chris -

    Thank you for the response. I looked more closely at the DMM information and have the WSNNode/SimplePeripheral example running on my board.

    I did not search hard for more details, but I modified things as seemed logical to disable BLE when I was done with it.

    In dmm_policy_blesp_wsnnode.h, added new state to bit map:

    #define DMMPOLICY_STACKSTATE_BLEPERIPH_DONE         0x00000008 //!< State for BLE when access is complete

    In dmm_policy_blesp_wsnnode_ble_high.c, added new state to table:

    //State 4: BleSp complete: BleSp  = Low Priority | Time None Critical, WsnNode = High Priority | Time Critical
        {
          {DMMPolicy_StackRole_BlePeripheral, DMMPolicy_StackRole_WsnNode},
          {(DMMPOLICY_STACKSTATE_BLEPERIPH_DONE) , (DMMPOLICY_STACKSTATE_WSNNODE_ANY)},
          {DMMPOLICY_PRIORITY_LOW, DMMPOLICY_TIME_NONE_CRITICAL, DMMPOLICY_PAUSED, //BLE SP Stack
           DMMPOLICY_PRIORITY_HIGH, DMMPOLICY_TIME_CRITICAL, DMMPOLICY_NOT_PAUSED} //WSN NODE Stack
        },
    

    And in simple_peripheral.c::SimplePeripheral_bleFastStateUpdateCb(), instead of entering _ADV state, modified to enter new _DONE state:

        else if( (prevStackState & LL_TASK_ID_SLAVE) && !(stackState & LL_TASK_ID_SLAVE))
        {
          //We just disconnected
    #ifdef RF_PROFILING
            PIN_setOutputValue(rfBleProfilingPinHandle, BLE_CONNECTED_GPIO, 0);
    #endif
    
            /* update DMM policy */
    //        DMMPolicy_updateStackState(DMMPolicy_StackRole_BlePeripheral, DMMPOLICY_STACKSTATE_BLEPERIPH_ADV);
            DMMPolicy_updateStackState(DMMPolicy_StackRole_BlePeripheral, DMMPOLICY_STACKSTATE_BLEPERIPH_DONE);
        }
    

    I am unsure if this code is running as I am unable to set a breakpoint there- CCS tells me there is "No code associated" with that line. There is no change in behavior when running the code- I am still able to connect with BTool after disconnecting.

    I am pretty sure the DMMPOLICY_PAUSED is doing something as I next modified main.c::main() to initialize the BLE state to _DONE:

      /*set the stacks in default states */
    //  DMMPolicy_updateStackState(DMMPolicy_StackRole_BlePeripheral, DMMPOLICY_STACKSTATE_BLEPERIPH_ADV);
      DMMPolicy_updateStackState(DMMPolicy_StackRole_BlePeripheral, DMMPOLICY_STACKSTATE_BLEPERIPH_DONE);
      DMMPolicy_updateStackState(DMMPolicy_StackRole_WsnNode, DMMPOLICY_STACKSTATE_WSNNODE_SLEEPING);
    

    and now BTool is unable to connect to the device.

    However, I do not see any change in power usage. Does the BLE radio not actually turn off?

    .Tim

  • RE: and now BTool is unable to connect to the device.

    Apparently, that is not a repeatable result. I tried modifying the states and table in my app to do the same thing and could not get it to work. I returned to my modified example application and found that it too no longer disables BLE access when I have the initial default state set to _DONE. I did not make any further changes to that code, just started a new debug session (which still appears to link the final binary before downloading it).

    Any ideas why I am getting inconsistent behavior?

    .Tim
  • Hi Tim,

    Sorry for the long delay in response here; by now you have probably moved on? Regardless, I'm hopeful Joakim may have additional input now that he has returned from holiday. Pop us an update on this topic if you get a chance.

    Thank you,
    Chris
  • Chris -

    Thanks for checking up. I actually made some progress starting with the DMM WSNNode BLE5 example. I first modified the BLE peripheral to match our desired service/characteristics. Then I removed the WSN Node source and put our sub-GHz RF code in its place. I actually got it running (although not exactly as I expected/desired and I had a significant power level difference compared to our original sub-GHz code running on our board, but good enough to start).

    Unfortunately, I then had a higher priority task and need to get back to where I was with this project. When I get back to that point and hopefully make some additional progress I might have more specific questions to followup.

    .Tim

  • I'm marking this as "TI Thinks Resolved" for now to satisfy our internal tracking. When you have an update, feel free to click "not resolved" and post the update.
  • For process sake, I will mark this as resolved. The DMM solution is basically working although I still have some issues. I will post new questions when I am working on the project again and unable to move forward otherwise.

    .Tim