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.

init sequence for CC2540 network processor as peripheral

Other Parts Discussed in Thread: CC2540

Hi Sir;

    I am using CC2540 USB Dongle with network processor mode and i want to configure it as peripheral.  I send the command as follows:

   (1)GAP_DeviceInit 

   (2)GAP_UpdateAdvertisingData  with limited discoverable mode

   (3) GAP_SetParam to config the advertising interval for limited and general discoverable mode (to value 32mSec)

   (4) GAP_MakeDiscoverable with Connectable undirected advertisement.

   (5) GAP_MakeDiscoverableDone with actual advertising interval (107mSec)returned

After all above done, i can find and connect the device from my mobile phone.

Question:

  on the step (5) above, the actual advertising interval is not in the range i set.So i wonder if my init sequence is right?

  • Hi,

    Did you use the peripheral config in GAP_DeviceInit or receive any error responses?

    Best wishes
  • Hi JXS;

      Yes,GAP_DeviceInit is the first command sent . All commands respond success, I can connect the device through my phone. I just want to know why the actual advertising interval is not in the range i set.

  • Hi,

    What are the actual SetParm parameters & values being used?

    Best wishes

  • Hi JXS;
    Here lists the raw data sent to CC2540 :
    set gap parameter(lim & gen adv interval to 20ms)
    01 30 fe 03 06 20 00
    01 30 fe 03 07 20 00
    01 30 fe 03 08 20 00
    01 30 fe 03 09 20 00

    advertise data (limited discoverable mode)
    01 07 fe 10 01 0e 02 01 05 06 ff 00 00 00 00 00 03 02 f2 ff

    advertise request(Connectable undirected advertisement)
    01 06 fe 0a 00 00 00 00 00 00 00 00 07 00

    all respond success. Should i also set the TGAP_CONN_ADV_INT_MIN and TGAP_CONN_ADV_INT_MAX?
  • Yes, please configure TGAP_CONN_ADV_INT_MIN and TGAP_CONN_ADV_INT_MAX.

    Best wishes
  • Hi JXS;
    After configure TGAP_CONN_ADV_INT_MIN and TGAP_CONN_ADV_INT_MAX, no improvement.
    I find that the actual advertising interval value is not controllable as i want no matter i configure the parameter or not. Here lists the command and event follow.

    TX: 01 00 fe 26 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 (gap_init as peripheral)
    RX: 04 FF 06 7F 06 00 00 FE 00 (cmd_status_ok)
    04 FF 2C 00 06 00 73 CA A7 72 39 D0 1B 00 0C AA 99 31 BE 7C 54 48 E2 97 35 8E EC EB 65 15 CD 00 00 00 00 00 00 00 00 00 00 01 00 FE 26 04 00 (gap init confirm)
    TX-->: 01 07 fe 10 01 0e 02 01 05 06 ff 00 00 00 00 00 03 02 f2 ff (update_adv_data, limited discoverable)
    RX<--: 04 FF 06 7F 06 00 07 FE 00 (cmd_status_ok)
    04 FF 04 02 06 00 01 (update_adv_data done)
    /*configure advertising interval parameter*/
    TX-->: 01 30 fe 03 06 20 00 (set param TGAP_LIM_DISC_ADV_INT_MIN to 20ms)
    RX<--:04 FF 06 7F 06 00 30 FE 00(cmd_status_ok)
    TX:--> 01 30 fe 03 07 32 00 (set_param TGAP_LIM_DISC_ADV_INT_MAX to 32ms)
    RX<--:04 FF 06 7F 06 00 30 FE 00(cmd_status_ok)
    TX-->: 01 30 fe 03 08 20 00 (set_param TGAP_GEN_DISC_ADV_INT_MIN to 20ms)
    RX<--: 04 FF 06 7F 06 00 30 FE 00(cmd_status_ok)
    TX-->: 01 30 fe 03 09 32 00 (set_param TGAP_GEN_DISC_ADV_INT_MAX to 32ms)
    RX<--: 04 FF 06 7F 06 00 30 FE 00(cmd_status_ok)
    TX-->:01 30 fe 03 0a 20 00 (set_param TGAP_CONN_ADV_INT_MIN to 20ms)
    RX<--:04 FF 06 7F 06 00 30 FE 00(cmd_status_ok)
    TX-->: 01 30 fe 03 0b 32 00 (set_param TGAP_CONN_ADV_INT_MIN to 32ms)
    RX<--: 04 FF 06 7F 06 00 30 FE 00 (cmd_status_ok)
    /*start avertising*/
    TX-->:01 06 fe 0a 00 00 00 00 00 00 00 00 07 00 (start advertising)
    RX<--:04 FF 06 7F 06 00 06 FE 00 (cmd_status_ok)
    04 FF 05 03 06 00 68 00 (advertising start with actual interval 0x0068 = 104ms)

    /*stop advertising*/
    TX-->:01 08 fe 00 (stop advertising)
    RX<--:04 FF 06 7F 06 00 08 FE 00 (cmd_status_ok)
    04 FF 03 04 06 00 (advertising stoppped)

    /*restart avertising*/
    TX-->:01 06 fe 0a 00 00 00 00 00 00 00 00 07 00 (start advertising)
    RX<--:04 FF 06 7F 06 00 06 FE 00 (cmd_status_ok)
    04 FF 05 03 06 00 0F 00 (advertising start with actual interval 0x000f = 15ms)



    no matter you configure the advertising interval parameter or not, the advertising interval will be 0x0068 for the first time. Then its value changes to 0x000f for later advertising request.

    I also make a test on simpleBlePeripheral project and check the actual interval value in GAP_MAKE_DISCOVERABLE_DONE_EVENT of peripheral.c.

    First time advertising, the interval value is 279, 8 for the second time, the 15 for the later. I have set the DEFAULT_ADVERTISING_INTERVAL to be 32 defined in simpleBLEPeripheral.c.