Hi, I have a defined MACRO which I initialised the values of ble_gap_adv_params_t in main.c. I will pass this to the function to start advertising. I used the example (ble_app_blinky_pca10056_s140) to try out.
However , I have two error messages.
1) "expected expression before '{' token " in the line #define ADV_1M_LEGACY_CONNECTABLE {
2) "expected expression before ')' token in the function int main (void) { line m_adv_handle = advertising_init_common(&m_adv_data, ADV_1M_LEGACY_CONNECTABLE );
I wonder is my syntax of #define written wrongly or I cannot use this type.
#define ADV_1M_LEGACY_CONNECTABLE { \ .properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED, \ .p_peer_addr = NULL, \ .interval = APP_ADV_INTERVAL, \ .duration = APP_ADV_DURATION, \ .max_adv_evts = 0, \ .channel_mask = 0, \ .filter_policy = BLE_GAP_ADV_FP_ANY, \ .primary_phy = BLE_GAP_PHY_1MBPS, \ .secondary_phy = 0, \ .set_id = 0, \ .scan_req_notification = 0, \ }
static uint8_t advertising_init_common(ble_gap_adv_data_t* ble_gap_adv_data,ble_gap_adv_params_t* adv_params) { ret_code_t err_code; ble_advdata_t advdata; ble_advdata_t srdata; uint8_t advHandle; ble_uuid_t adv_uuids[] = {{LBS_UUID_SERVICE, m_lbs.uuid_type}}; // Build and set advertising data. memset(&ble_gap_adv_data->adv_data, 0, sizeof(ble_gap_adv_data->adv_data)); advdata.name_type = BLE_ADVDATA_FULL_NAME; advdata.include_appearance = true; advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE; memset(&srdata, 0, sizeof(srdata)); srdata.uuids_complete.uuid_cnt = sizeof(adv_uuids) / sizeof(adv_uuids[0]); srdata.uuids_complete.p_uuids = adv_uuids; err_code = ble_advdata_encode(&advdata, ble_gap_adv_data->adv_data.p_data, &ble_gap_adv_data->adv_data.len); APP_ERROR_CHECK(err_code); err_code = ble_advdata_encode(&srdata, ble_gap_adv_data->scan_rsp_data.p_data, &ble_gap_adv_data->scan_rsp_data.len); APP_ERROR_CHECK(err_code); // Set advertising parameters. err_code = sd_ble_gap_adv_set_configure(&advHandle, ble_gap_adv_data, &adv_params); APP_ERROR_CHECK(err_code); return advHandle; }
int main(void) { // Initialize. log_init(); leds_init(); timers_init(); buttons_init(); power_management_init(); ble_stack_init(); gap_params_init(); gatt_init(); services_init(); //advertising_init(); m_adv_handle = advertising_init_common(&m_adv_data, ADV_1M_LEGACY_CONNECTABLE ); conn_params_init(); // Start execution. NRF_LOG_INFO("Blinky example started."); advertising_start(m_adv_handle); // Enter main loop. for (;;) { idle_state_handle(); } }