«

»

Jan 01

iBeacons on the TI CC2541

Setting a Timer

The easiest way I found to set a timer is to call

uint8 osal_start_timerEx( uint8 taskID, uint16 event_id, uint32 timeout_value )

This call is used for setting the timeout value for turning the advertising back on in the code.  We are going to modify it so that we can turn the advertising off.  I don’t know the framework good enough to start adding tasks.  Instead we are going to modify GAPRole_ProcessEvent( uint8 task_id, uint16 events ) to take a new message that tells it to turn off the radio.  In my case I called it STOP_ADVERTISING_EVT.  This needs to run the following commands:

  if ( events & START_ADVERTISING_EVT )
  {
      ...
  }
  else if  (events & STOP_ADVERTISING_EVT)
  {
    VOID GAP_EndDiscoverable(gapRole_TaskID);
    gapRole_AdvEnabled = FALSE;
    return ( events ^ STOP_ADVERTISING_EVT );
  }

Wrap Up

This should help you as you work on making the example project match what you are actually doing.  Don’t expect this to be a one day project.  There’s a lot (remove the static typing from this variable, include this header, etc.). I left out in the name of brevity here.  Hopefully I’ll get another post out to go along with this.  Until next time.

Permanent link to this article: http://blog.curioussystem.com/2014/01/ibeacons-on-the-ti-cc2541/

3 comments

1 ping

  1. Gokhan

    Can you put batter level data from battery service in advertisement data?

    etc: battery level:%88 So is it possible to put that data in advertisement also?

  2. Dan

    Could you upload the firmware source somewhere? The tutorial page originally linked to has disappeared. If you also have a backup copy of the tutorial page, that would be great also.

  3. Glenn

    Hi Chad, do you have a copy of the radius networks CC2541 iBeacon project for the CC2541DK-MINI dev kit? Your links doesn’t work any more (they’ve moved the project/taken it down).

    Many thanks

  1. Updates on iBeacons with the CC2540 » Things Learned Along the Way

    […] good news is that I was able to leverage the code I wrote for the CC2541 previously.  This project was a little more complicated.  It has to take commands over the asynchronous […]

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>