I am trying to take the ble_uart code and encapsulate it , so I took all the code and put it into another C file I made.
Then from the main.c program I call a function in this new C file to start the bluetooth.
It compiles and run but will not even log that it started/nor it will advertise . Why is that ?
Please see the attached project file
My main.c file
#include "Bluetooth.h"
static void log_init(void)
{
ret_code_t err_code = NRF_LOG_INIT(NULL);
APP_ERROR_CHECK(err_code);
}
static void power_manage(void)
{
uint32_t err_code = sd_app_evt_wait();
APP_ERROR_CHECK(err_code);
}
int main(void)
{
log_init();
NRF_LOG_INFO("Setting up ble\r\n"); // will not print
setupBluetooth();
for (;;)
{
power_manage();
}
}
My bluetooth C file, which does exactly what the main.c was doing only in another c file function:
#include "Bluetooth.h"
void setupBluetooth()
{
uart_init();
uint32_t err_code;
bool erase_bonds;
// Initialize.
err_code = app_timer_init();
APP_ERROR_CHECK(err_code);
uart_init();
buttons_leds_init(&erase_bonds);
ble_stack_init();
gap_params_init();
gatt_init();
services_init();
advertising_init();
conn_params_init();
err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
APP_ERROR_CHECK(err_code);
}
// Here goes all the ble_uart static functions that where in the main, (they declared in .h also)