This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

how to switch between peripheral mode and central mode?

Hi there,I am using s130, my device is now working at peripheral mode, it's advertising. I want to switch it into central mode by pressing a button. and switch back to peripheral mode when I press the button again. Anyone can help or give me some idea? Thanks a lot!

Parents
  • Thanks RK!

    1. I do this on system start:

      ble_stack_init(); gap_params_init(); services_init(); advertising_init(); conn_params_init(); ble_advertising_start(BLE_ADV_MODE_FAST); db_discovery_init(); nus_c_init();

    2.when I press the button:

    ble_advertising_start(BLE_ADV_MODE_IDLE);
    sd_ble_gap_adv_stop();
    scan_start();
    

    but when I do step 2, the system restart, I don't know what is wrong and how to deal with it.

Reply
  • Thanks RK!

    1. I do this on system start:

      ble_stack_init(); gap_params_init(); services_init(); advertising_init(); conn_params_init(); ble_advertising_start(BLE_ADV_MODE_FAST); db_discovery_init(); nus_c_init();

    2.when I press the button:

    ble_advertising_start(BLE_ADV_MODE_IDLE);
    sd_ble_gap_adv_stop();
    scan_start();
    

    but when I do step 2, the system restart, I don't know what is wrong and how to deal with it.

Children
No Data
Related