Hi,
I'm using Segger Embedded Studio with Ubuntu, trying to write a minimal code to let the chip start advertising.
I tried to read and understand the example codes provided in the SDK, but found myself frustrated understanding these Macros, data structures and the SoftDevice handler functions. Now I'm trying another approach to use the SoftDevice directly, I feel more comfortable to understand these Message Sequence Charts and related SoftDevice APIs.
I started a new nRF52832 project from the "New Project" menu of the IDE, included the necessary folders of the SDK, and wrote a very simple code. My target is to get the chip start advertising and that is all. The project get compiled with no error, but the code size it generated is only 1.7kB, apparently the SoftDevice is not included, but I don't now how to fix it, anybody can help?
Here is my code:
File : main.c Purpose : Generic application start */ #include <nrf_sdm.h> #include <ble.h> void stop_on_fault(uint32_t id, uint32_t pc, uint32_t info) { while(1); } /********************************************************************* * * main() * * Function description * Application entry point. */ void main(void) { int i; uint32_t ram_start_addr = 0x20001000; nrf_clock_lf_cfg_t clock_cfg = {.source=NRF_CLOCK_LF_SRC_RC, .rc_ctiv=16, .rc_temp_ctiv=2, .accuracy=NRF_CLOCK_LF_ACCURACY_500_PPM}; ble_cfg_t ble_cfg; ble_cfg.conn_cfg.conn_cfg_tag = 1; ble_cfg.conn_cfg.params.gap_conn_cfg.conn_count = 1; ble_gap_addr_t local_addr; local_addr.addr_type = BLE_GAP_ADDR_TYPE_RANDOM_STATIC; local_addr.addr[0] = 0x12; local_addr.addr[1] = 0x34; local_addr.addr[2] = 0x56; local_addr.addr[3] = 0x78; local_addr.addr[4] = 0x90; local_addr.addr[5] = 0xab; uint8_t adv_handle; adv_handle = BLE_GAP_ADV_SET_HANDLE_NOT_SET; const uint8_t adv_buf[] = {0x02, 0x01, 0x06, 0x03, 0x09, 0x4e, 0x65}; const uint8_t scn_rsp_buf[] = {0x02, 0x01, 0x06, 0x03, 0x09, 0x6f, 0x7a}; ble_data_t adv_dat, rsp_dat; adv_dat.p_data = adv_buf; adv_dat.len = sizeof(adv_buf); rsp_dat.p_data = scn_rsp_buf; rsp_dat.len = sizeof(scn_rsp_buf); ble_gap_adv_data_t adv_data; adv_data.adv_data = adv_dat; adv_data.scan_rsp_data = rsp_dat; ble_gap_adv_params_t adv_params; adv_params.properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED; adv_params.properties.include_tx_power = 1; adv_params.properties.anonymous = 0; adv_params.interval = (125/0.625); adv_params.duration = BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED; sd_softdevice_enable(&clock_cfg, stop_on_fault); sd_ble_cfg_set(BLE_CONN_CFG_GAP, &ble_cfg, ram_start_addr); sd_ble_enable(&ram_start_addr); sd_ble_gap_addr_set(&local_addr); sd_ble_gap_adv_set_configure(&adv_handle, &adv_data, &adv_params); while (1); } /*************************** End of file ****************************/
I must missed something, maybe some settings in the Segger IDE?