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.

CC2540 Power Management

Other Parts Discussed in Thread: CC2540, Z-STACK

Hello........

After I power on the device, I should display the MAC ID of the device say for 5 seconds in Active mode i.e Advertising, then I should enter into PM2 for about 30 seconds and then come back again to Active mode and display the MAC ID for 5 seconds and the process should continue....

So how do I program CC2540 in order to achieve my task??

  • Hello,

    What sample application is your starting point? Are you using your own hardware with CC2540 or one of our development kits with a LCD display?
    Are you trying to accomplish what is shown in this wiki page for the simple BLE Application?

    http://processors.wiki.ti.com/index.php/LPRF_BLE_Simple_Application 

    Our power saving mode for any sample application is enabled with the compile flag POWER_SAVING in the preprocessor settings of your IAR EW8051 project.

    LPRF Rocks the World

  • Hello....

    Yeah I am using my own custom board which has CC2540 IC. I am trying to do the advertising operation from my custom board i.e I need to display my device's MAC ID to others for a certain amount of time in active mode and then go to PM2  for a certain period and then come back again to Active mode and display the MAC Id. 

    So If I need to do this, which program do I need to refer and what are all the modifications to be done??

  • And I am not using any LCD display in my custom board...

    I will just advertise my device's MAC ID to other devices such as iphone, Windows 8 supported Bluetooth systems, etc.

    This is what I basically need to do.....

  • Hello,

    Frist, I would start with the porting of the HAL layer to your platform. In our BLE Stack release their is no porting guide, so I have attached the one we provide with our Z-Stack release. This is just a guideline, but the same general idea applies.

    If you have not already done this, I recommend to ensure that the lower layer works properly first. Is this working correctly on your custom platform?

    8802.Z-Stack HAL Porting Guide.pdf

    Enjoy,
    LPRF Rocks the World

  • Hello......

    Thanks for the reply....

    How to port the HAL layer to my board and how to ensure that the lower layer works properly??

    Please guide me.....

    Thanks.

  • Hi Gautham,

    You can use the following to read the MAC address:

            uint8 ownAddress[B_ADDR_LEN];

            GAPRole_GetParameter(GAPROLE_BD_ADDR, ownAddress);

    Then simply put the result in an advertisment packet:

      /**

       * @brief       Setup or change advertising and scan response data.

       *

       *    NOTE:  if the return status from this function is SUCCESS,

       *           the task isn't complete until the GAP_ADV_DATA_UPDATE_DONE_EVENT

       *           is sent to the calling application task.

       *

       * @param       taskID - task ID of the app requesting the change

       * @param       adType - TRUE - advertisement data, FALSE  - scan response data

       * @param       dataLen - Octet length of advertData

       * @param       pAdvertData - advertising or scan response data

       *

       * @return      SUCCESS: data accepted,<BR>

       *              bleIncorrectMode: invalid profile role,<BR>

       */

      extern bStatus_t GAP_UpdateAdvertisingData( uint8 taskID, uint8 adType,

                                          uint8 dataLen, uint8 *pAdvertData );

    pAdvertData is where you put the MAC address (advData = 02:01:05:07:FF:OW:NA:DD:RE:SS:XX). The format of the Advertisment data is found in the Core spec Vol 3, Part C, Section 11 and 18. Byte 5 must be 0xFF to inform that you have vendor specific data you want to broadcast.

    /Fredrik

  • Hello Fredrik....

    Thanks....

    First I need to do the advertising operation i.e I need to display my MAC Id to other devices..... How can I do that ?? I am not using any LCD display devices.......

    And where can I find core spec vol 3, part C?? Can you post the link please??

    Also how can I put the result in an advertisement packet??

    Please guide me...

    Thanks.......

  • In my previous post I showed you both how you could get the MAC address of your device, and also how you could broadcast it in an advertisment packet. A good starting point would be to use the SimpleBLEPeripheral code and modify it according to your needs.

    The Bluetooth Core Spec is found here: https://www.bluetooth.org/Technical/Specifications/adopted.htm

    /Fredrik

  • Hello...

    Thanks...

    Will it be sufficient if I use the BLE broadcaster code alone to advertise my MAC Id??  

    In that code, will it automatically broadcast my MAC Id or do I need to use the advertisement packet to send??

    Regards....

    Gautham.

  • Hi Gautham,

    The MAC/IEEE address is part of the broadcast/advertisement packet. See below Sniffer capture of a broadcasted packed. The AdvA is the MAC/IEEE address.

    Best Regards 

  • May I know how the MAC address present in the advertisement packet is 6 byte i.e 48 bit??

    As per your image of the advertisement packet in the previous post, the MAC address is 0x90D7EBB19299.

    How this is a 6 byte addr?? 

  • 0x90 = 0b10010000 (1 byte)

    0xD7 = 0b11010111 (1 byte)

    0xEB = 0b11101011 (1 byte)

    0xB1 = 0b10110001 (1 byte)

    0x92 = 0b10010010 (1 byte)

    0x99 = 0b10011001 (1 byte)

    Total = 6 byte.

    /Fredrik

  • Thanks a lot Fredrik...

    Now, I am doing only advertising... So I am following only Simple Ble Broadcaster code....

    In that, I am planning to advertise my mac id for 2 sec alone and then make the device idle for 30 seconds and then again advertise for 2 sec..........

    So for this to happen, I am making use of a timer to trigger an osal event i.e Osal_Start_timerEx(simplebleperipheral_task id, event, evnt period).

    Then I am toggling the timer ie ON and OFF and then running this continuously by using performPeriodicTask() function....

    And, since I am making my own custom board, I dont have the keys for starting the advertisements..

    The advertising should start once I power on the device... So will my logic work for Simple Ble Broadcaster with the elimination of functions such as Handlekey() function   or I should use only simple ble Peripheral for my requirement??