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.

A couple of SimpleBLEPeripheral code questions

Other Parts Discussed in Thread: CC2541, CC2540, CC2541S

Hi, I am starting to put something together in IAR based on the SimpleBLEPeripheral project. I have the CC2541 Mini Kit which comes with the CC2540 USB dongle.

I want to do some range testing to see the difference between the CC2540 & CC2541 (I believe the CC2541 has lower power) and looking through the code in IAR I see that a define is used to determine which power to use:

#if defined( CC2541) || defined( CC2541S )

#define LL_EXT_MAX_TX_POWER                            LL_EXT_TX_POWER_0_DBM

#else // CC2540

#define LL_EXT_MAX_TX_POWER                            LL_EXT_TX_POWER_4_DBM

#endif // CC2541 || CC2541S

However I can't find where this is defined in the CC2541 project. I've search and looked at every instance of CC2541 and i've looked in the Preprocessor Defined Symbols list. Can anyone tell me where/if this should be defined so I can compile for CC2540 & CC2541.

 

2) If I add the line 'HalLedSet (HAL_LED_2, HAL_LED_MODE_FLASH);' to peripheralStateNotificationCB method under case GAPROLE_ADVERTISING then the LED flashes when I start advertising and continues to flash when advertising is stopped by pressing the button, which is what I expect. However if I use HAL_LED_MODE_ON the LED blinks much faster and when advertising ends by pressing the button the LED stops. There is no code that I can find that is setting the LED to OFF apart from whats in the initialization routines. This has me somewhat confused. Are the initialization routines running again when advertising is stopped? But why wouldn't  flashing led stop also?

 

3) Also in the peripheralStateNotificationCB method, it seems that GAPROLE_WAITING case is called both when a connected device is disconnected and also when advertising is stopped. Is there no case to determine between the 2? I would like to know when advertising has stopped even if a device is connected.

 

I hope someone can help and some or all of these questions.

 

Thanks 

  • 1) By default the project is defined for CC2540, so add the CC2541 switch to your projects preprocessors to support the output power of CC2541.

    2)   Here is an example on how to turn off LEDs

    // makes sure LEDs are off
      HalLedSet( (HAL_LED_1 | HAL_LED_2), HAL_LED_MODE_OFF );

    3) This is the callback function for the differerent profile notifications that can happen or be recceived by the peripheral device.

    LPRF Rocks the World

  • Thanks for the reply, just a few comments:

    1) Should the CC2541 projects not already have this defined? What would happen to performance if this wasn't defined on a CC2541 chip? Obviously it can't physically output power that the chip wont do. So is it necessary?

    2) I know how to turn them off, my observation was that nowhere in the sample code where they being switched off, yet they are actually being turned off somehow. The only code that switches them off is in the init's. So is the chip going through the init's again after broadcasting stops?