This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to unlock the BLE and take over control of the NRF_Radio Module.

Hi. I need the NRF52832 to work in two modes. After power-up, the radio module worked like a normal NRF24L02, and after pressing the button, the BLE started. I took the example of Gazelle and framed my piece of code there. When you press the button, the application switches the operation modes, but the packets that are not in the NRF24L02 mode do not go away, although a piece of code is executed.Maybe there is an opportunity to take control of the radio module from the softdevice?

int main(void)
{
    uint32_t     err_code;
    radio_mode_t previous_mode = running_mode;

    // Setup logger.
    err_code = NRF_LOG_INIT(NULL);
    APP_ERROR_CHECK(err_code);

    NRF_LOG_DEFAULT_BACKENDS_INIT();

    NRF_LOG_INFO("Multiprotocol application example started.");
    NRF_LOG_INFO("BLE mode");

    power_management_init();
    ble_stack_start();
    NRF_LOG_FLUSH();

    // Initialize timer module, making it use the scheduler.
    err_code = app_timer_init();
    APP_ERROR_CHECK(err_code);

    bsp_init_app();
    ble_hrs_app_start();

    // Enter main loop.
    for (;;)
    {
        NRF_LOG_FLUSH();
        nrf_pwr_mgmt_run();

        if (bsp_button_is_pressed(BLE_BUTTON_ID))
        {
            running_mode = BLE;
        }
        else if (bsp_button_is_pressed(GZLL_BUTTON_ID))
        {
            running_mode = GAZELL;
        }

        if (running_mode != previous_mode)
        {
            previous_mode = running_mode;
            if (running_mode == GAZELL)
            {
                NRF_LOG_INFO("Gazell mode");

                // Stop all heart rate functionality before disabling the SoftDevice.
                ble_hrs_app_stop();

                // Disable the softdevice stack.
                ble_stack_stop();

                err_code = bsp_indication_set(BSP_INDICATE_IDLE);
                APP_ERROR_CHECK(err_code);

                // Enable Gazell.
								
                InitNRFRadio ();
								SendPacket (0);
								SendPacket (0);
								SendPacket (0);
            }
            else if (running_mode == BLE)
            {
                NRF_LOG_INFO("BLE mode");

                // Disable Gazell.
                //gzll_app_stop();

                err_code = bsp_indication_set(BSP_INDICATE_IDLE);
                APP_ERROR_CHECK(err_code);

                // Re-enable the softdevice stack.
                ble_stack_start();
                ble_hrs_app_start();
            }
        }
    }
}

Parents Reply Children
No Data
Related