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.

How do I use a private, non-resolvable address on the CC2541?

I have a broadcaster application that does nothing except send out advertising data roughly every second.  Due to some weirdness on iOS, I'd like to experiment with changing our device address periodically (perhaps even as often as every advertising packet).

It seems that this function call would do the trick:

GAP_ConfigDeviceAddr(ADDRTYPE_PRIVATE_NONRESOLVE, NULL);

However, when I call this, I get error bleIncorrectMode ("Not setup properly to perform that task") - which tells me I'm doing it at the wrong time.

When is the appropriate time to call this?  Is there an event sent to peripheralStateNotificationCB() when an advertising packet is sent (or going to be sent)?

(Along those lines, where are the events - such as "GAPROLE_STARTED" - documented?  I could not find them in the "Documents" folder of the BLE stack.

Thanks.

#define  bleIncorrectMode   0x12
  Not setup properly to perform that task. 
  • Hello,

    If you are getting bleIncorrectMode, this means you are either advertising and/or in a connection when you are attempting to change the address. You will need to stop advertising or verify you are not in a connection before changing the address.

    Best wishes
  • I was afraid of that. Can someone point me to some code to stop and restart advertising every second or so?
  • I need some more help with this...

    I need to stop advertising, call GAP_ConfigDeviceAddr(), then restart advertising. Can someone suggest where in the flow it is safe to do this?

    Related question: Is there a document that describes the event signals sent to the peripheral State Notification callback? (Ie: Under what conditions do the events GAPROLE_STARTED, GAPROLE_ADVERTISING, and GAPROLE_WAITING get sent?)

    Thanks.
  • Hi Jim,

    Take a look at the code for:

    In this example we switches roles from peripheral to central and back depending on a key press.

    When switching from peripheral to central we disable advertising. You can follow this pattern through the code in the linked project.

    here is a code snippet:

          // PERIPHERAL --> CENTRAL
          new_adv_enabled_status = FALSE;
          
          //change the GAP advertisement status to opposite of current status
          GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &new_adv_enabled_status ); 

  • Thank you. Your post inspired me to the right solution, so I finally have this solved.

    For those who may be curious: I have a timer that goes off periodically. When it happens, I disabled advertising by setting GAPROLE_ADVERT_ENABLED false. This triggers a GAPROLE_WAITING event to be sent to my callback routine - where I can callGAP_ConfigDeviceAddr() to set my private address, and then re-enable advertising. I now have advertising going at the desired frequency, with each packet using a different private address.

    (Note: This may not be my final solution, but now I can control the timers and events as desired - so I can decide what my final solution will be).

    Thank you all!