/************************************************************************** * * Configures the nRF8001 and starts advertising the service * * @param[in] advTimeout * The advertising timeout in seconds * (0 = infinite advertising). * @param[in] advInterval * The delay between advertising packets in 0.625ms units * (1600 = 1 second). * **************************************************************************/ bool GoosciBleGatt::begin(int advTimeout, int advInterval) { // Store the advertising timeout and interval // TODO(nmai): check for valid ranges. adTimeout = advTimeout; adInterval = advInterval; // Setup the service data from nRFGo Studio (services.h) if (NULL != services_pipe_type_mapping) { aci_state.aci_setup_info.services_pipe_type_mapping = &services_pipe_type_mapping[0]; } else { aci_state.aci_setup_info.services_pipe_type_mapping = NULL; } aci_state.aci_setup_info.number_of_pipes = NUMBER_OF_PIPES; aci_state.aci_setup_info.setup_msgs = (hal_aci_data_t *)setup_msgs; aci_state.aci_setup_info.num_setup_msgs = NB_SETUP_MESSAGES; // Setup the nRF8001 pins. aci_state.aci_pins.board_name = BOARD_DEFAULT; aci_state.aci_pins.reqn_pin = _REQ; aci_state.aci_pins.rdyn_pin = _RDY; aci_state.aci_pins.mosi_pin = MOSI; aci_state.aci_pins.miso_pin = MISO; aci_state.aci_pins.sck_pin = SCK; // SPI_CLOCK_DIV8 = 2MHz SPI speed. aci_state.aci_pins.spi_clock_divider = SPI_CLOCK_DIV8; // The Active pin is optional and can be marked UNUSED. aci_state.aci_pins.reset_pin = _RST; aci_state.aci_pins.active_pin = UNUSED; aci_state.aci_pins.optional_chip_sel_pin = UNUSED; // Interrupts still not available in Chipkit. aci_state.aci_pins.interface_is_interrupt = false; aci_state.aci_pins.interrupt_number = 1; // The second parameter is for turning debug printing on // for the ACI Commands and Events so they be printed on the Serial lib_aci_init(&aci_state, false); // Get the device address lib_aci_get_address(); // Wait for the get address response addrReceived = false; while (!addrReceived) { pollACI(); } return true; }
void ble_get_mac_addr(uint8_t *bd_addr) { if(!addr_get) { lib_aci_get_address(); // Get device's MAC address and address type while(!addr_get) { process_events(); } } memcpy(bd_addr, bd_addr_own, BTLE_DEVICE_ADDRESS_SIZE); }