Ejemplo n.º 1
0
/**@brief Application main function.
 */
int main(void)
{
    // Initialize
    leds_init();
    timers_init();
    gpiote_init();
    buttons_init();
    bond_manager_init();
    ble_stack_init();
    ble_error_log_init();
    gap_params_init();
    advertising_init();
    alert_notification_init();
    conn_params_init();
    sec_params_init();
    radio_notification_init();
    
    // Start execution
    advertising_start();

    // Enter main loop
    for (;;)
    {
        power_manage();
    }

}
Ejemplo n.º 2
0
/**@brief Application main function.
 */
int main(void)
{
    // Initialize
    leds_init();
    buttons_init();
    ble_stack_init();
    bond_manager_init();
    timers_init();
    gap_params_init();
    advertising_init();
    services_init();
    sensor_sim_init();
    conn_params_init();
    sec_params_init();
    radio_notification_init();

    // Start execution
    application_timers_start();
    advertising_start();

    // Enter main loop
    for (;;)
    {
        power_manage();
    }
}
Ejemplo n.º 3
0
 */
int main(void)
{
    // Initialize.
    leds_init();
    timers_init();
    gpiote_init();
    buttons_init();
    ble_stack_init();
    bond_manager_init();
    gap_params_init();
    advertising_init(BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE);
    services_init();
    sensor_sim_init();
    conn_params_init();
    sec_params_init();

    // Start execution.
    advertising_start();

    // Enter main loop.
    for (;;)
    {
        power_manage();
    }
Ejemplo n.º 4
0
/**@brief Function for application main entry.
 */
int main(void)
{
    gpio_config();

    bool success = nrf6350_lcd_init();
    APP_ERROR_CHECK_BOOL(success);
    success = nrf6350_lcd_write_string("    BLE ANCS    ", MAX_CHARACTERS_PER_LINE, LCD_UPPER_LINE, 0);
    APP_ERROR_CHECK_BOOL(success);

    // Initialize.
    leds_init();
    timers_init();
    gpiote_init();
    buttons_init();
    ble_stack_init();    
    bond_manager_init();
    gap_params_init();
    service_add();    
    advertising_init();
    conn_params_init();
    sec_params_init();
    radio_notification_init();
    
    // Start execution.
    advertising_start();

    // Enter main loop.
    for (;;)
    {
        power_manage();
    }

}
Ejemplo n.º 5
0
/**@brief Application main function.
 */
int main(void)
{
    // Initialize
    leds_init();
    timers_init();
    gpiote_init();
    buttons_init();
    bond_manager_init();
    ble_stack_init();
    scheduler_init();
    gap_params_init();
    advertising_init(BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE);
    services_init();
    sensor_sim_init();
    conn_params_init();
    sec_params_init();
    radio_notification_init();
    
    // Start execution
    timers_start();
    advertising_start();
    
    // Enter main loop
    for (;;)
    {
        app_sched_execute();
        power_manage();
    }
}
Ejemplo n.º 6
0
/**@brief Function for the application main entry.
 */
int main(void)
{
    uint32_t err_code;

    timers_init();
    gpiote_init();
    buttons_init();

    nrf_gpio_cfg_output(CONNECTED_LED_PIN_NO);  //DM: Green LED controlled directly. Red through GPIOTE task (Timer1_Compare[0])

    ble_stack_init();
    bond_manager_init();

    // Initialize Bluetooth Stack parameters
    gap_params_init();
    advertising_init();
    services_init();
    conn_params_init(); //just for relayr, iBeacon does´t allow connect
    sec_params_init();  //iBeacon: no security

    // Start advertising
    advertising_start();

    // Enter main loop
    for (;;)
    {
        // Switch to a low power state until an event is available for the application
        err_code = sd_app_evt_wait();
        APP_ERROR_CHECK(err_code);
    }
}
Ejemplo n.º 7
0
error_t btle_init(void)
{
    const bool useScheduler = false;
#ifdef TARGET_HRM1017
    SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_RC_250_PPM_4000MS_CALIBRATION, useScheduler);
#else
    SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, useScheduler);
#endif

    // Enable BLE stack
    /**
     * Using this call, the application can select whether to include the
     * Service Changed characteristic in the GATT Server. The default in all
     * previous releases has been to include the Service Changed characteristic,
     * but this affects how GATT clients behave. Specifically, it requires
     * clients to subscribe to this attribute and not to cache attribute handles
     * between connections unless the devices are bonded. If the application
     * does not need to change the structure of the GATT server attributes at
     * runtime this adds unnecessary complexity to the interaction with peer
     * clients. If the SoftDevice is enabled with the Service Changed
     * Characteristics turned off, then clients are allowed to cache attribute
     * handles making applications simpler on both sides.
     */
    static const bool IS_SRVC_CHANGED_CHARACT_PRESENT = true;
    ble_enable_params_t enableParams = {
        .gatts_enable_params = {
            .service_changed = IS_SRVC_CHANGED_CHARACT_PRESENT
        }
    };
    if (sd_ble_enable(&enableParams) != NRF_SUCCESS) {
        return ERROR_INVALID_PARAM;
    }

    ble_gap_addr_t addr;
    if (sd_ble_gap_address_get(&addr) != NRF_SUCCESS) {
        return ERROR_INVALID_PARAM;
    }
    if (sd_ble_gap_address_set(BLE_GAP_ADDR_CYCLE_MODE_NONE, &addr) != NRF_SUCCESS) {
        return ERROR_INVALID_PARAM;
    }

    ASSERT_STATUS( softdevice_ble_evt_handler_set(btle_handler));
    ASSERT_STATUS( softdevice_sys_evt_handler_set(sys_evt_dispatch));

#if NEED_BOND_MANAGER /* disabled by default */
    bond_manager_init();
#endif
    btle_gap_init();

    return ERROR_NONE;
}
Ejemplo n.º 8
0
error_t btle_init(void)
{
    APP_TIMER_INIT(0, 8, 5, false);
    SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, false);

    ASSERT_STATUS( softdevice_ble_evt_handler_set(btle_handler));
    ASSERT_STATUS( softdevice_sys_evt_handler_set(sys_evt_dispatch));

#if NEED_BOND_MANAGER /* disabled by default */
    bond_manager_init();
#endif
    btle_gap_init();

    return ERROR_NONE;
}
Ejemplo n.º 9
0
/**@brief Application main function.
 */
int main(void)
{
    uint32_t err_code;

    timers_init();
    gpiote_init();
    buttons_init();

    if (is_first_start())
    {
        // The startup was not because of button presses. This is the first start.
        // Go into System-Off mode.
        // NOTE: This register cannot be set directly after ble_stack_init() because the SoftDevice
        //       will be enabled.
        GPIO_WAKEUP_BUTTON_CONFIG(HR_INC_BUTTON_PIN_NO);
        GPIO_WAKEUP_BUTTON_CONFIG(HR_DEC_BUTTON_PIN_NO);
        NRF_POWER->SYSTEMOFF = 1;
    }

    bond_manager_init();
    ble_stack_init();
    radio_notification_init();

    // Initialize Bluetooth Stack parameters
    gap_params_init();
    advertising_init();
    services_init();
    conn_params_init();
    sec_params_init();

    // Actually start advertising
    advertising_start();

    // Enter main loop
    for (;;)
    {
        // Switch to a low power state until an event is available for the application
        err_code = sd_app_event_wait();
        APP_ERROR_CHECK(err_code);
    }
}
Ejemplo n.º 10
0
/**@brief Application main function.
 */
int main(void)
{
    APP_GPIOTE_INIT(1); 
    connectivity_chip_reset();
    
    leds_init();
    buttons_init();    
    bond_manager_init();
    ble_stack_init();
    ble_error_log_init();
    timers_init();
    nrf_gpio_pin_set(NRF6310_LED_5);
    gap_params_init();
    nrf_gpio_pin_clear(NRF6310_LED_5);
    advertising_init();
    services_init();
    sensor_sim_init();
    conn_params_init();
    sec_params_init();
    radio_notification_init();
   
    // Start execution
    application_timers_start();
    //m_start_adv_flag = true;
    advertising_start();
    
    // Enter main loop
    for (;;)
    {
//         uint32_t err_code;
//         // Start/restart advertising.
//         if (m_start_adv_flag)
//         {
//             err_code = sd_ble_gap_adv_start(&m_adv_params);
//             APP_ERROR_CHECK(err_code);
//             nrf_gpio_pin_set(ADVERTISING_LED_PIN_NO);
//             m_start_adv_flag = false;
//         }
        power_manage();
    }
}
void BLE_Primx_Apps_Int(void)
{
	  leds_init();    // configure LED output
    timers_init();  // configure Timer
    gpiote_init();  // configure maximum no of GPIO external 
    buttons_init(); // configure the button handlering and button proporty
    bond_manager_init();  // load the previous bond data from flash
    ble_stack_init();     // Install BLE event Handler function list
    gap_params_init();     // set gap parameter
    advertising_init(BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE);  //set advertising mode, set UUID service
    services_init();      // add UUID service , and service function handler
    conn_params_init();   // set the connection parameter
    sec_params_init();    // set the security connect parameter
    radio_notification_init();   // active radio

    // Start execution
    advertising_start();    // start state mechine for adversting




}	
Ejemplo n.º 12
0
/**@brief Application main function.
 */
int main(void)
{
    uint32_t err_code;

    connected = false;

    mlog_init();
    timers_init();
    gpiote_init();
    buttons_init();
    step_counter_init();
    motor_init();
    led1_init();

    mlog_str("Starting MAIN...\r\n");

    bond_manager_init();
    ble_stack_init();
    radio_notification_init();

    // Initialize Bluetooth Stack parameters
    gap_params_init();
    advertising_init();
    services_init();
    conn_params_init();
    sec_params_init();

    // Actually start advertising
    //advertising_start();
    app_button_enable();

    // Enter main loop
    for (;;)
    {
        // Switch to a low power state until an event is available for the application
        err_code = sd_app_event_wait();
        APP_ERROR_CHECK(err_code);
    }
}
Ejemplo n.º 13
0
/**@brief Function for application main entry.
 */
int main(void)
{

    // Initialize	
//		nrf_gpio_cfg_output(23);
//		nrf_gpio_pin_write(23, 0);
//		nrf_gpio_pin_write(23, 1);
//		nrf_delay_ms(1000);
//		nrf_gpio_pin_write(23, 0);
		uart_init();
    leds_init();
    timers_init();
    gpiote_init();
    buttons_init();
		app_button_enable();
		wdt_init();	
#ifdef  DEBUG_LOG
		printf("uart_init\r\n");
		printf("leds_init\r\n");
		printf("timers_init\r\n");
		printf("gpiote_init\r\n");
		printf("buttons_init\r\n");
		printf("wdt_init\r\n");
#endif	
	
    bond_manager_init();
    ble_stack_init();
    gap_params_init();
#ifdef  DEBUG_LOG
		printf("bond_manager_init\r\n");
		printf("ble_stack_init\r\n");
		printf("gap_params_init\r\n");
#endif


    advertising_init(BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE);
    services_init();
    conn_params_init();
    sec_params_init();	
    radio_notification_init();
#ifdef  DEBUG_LOG
		printf("advertising_init\r\n");
		printf("services_init\r\n");
		printf("conn_params_init\r\n");
		printf("radio_notification_init\r\n");
#endif

    advertising_start();
#ifdef  DEBUG_LOG
		printf("advertising_start\r\n");
#endif		
		
		
			
		HTU21D_Init();
		
#ifdef  DEBUG_LOG
		printf("HTU21D_Init\r\n");
		printf("OLED_Init\r\n");
#endif		
		
		my_timer_init();
		Auto_Time_Set();
		
#ifdef  DEBUG_LOG
		printf("rtc my_timer_init\r\n");
		printf("Auto_Time_Set\r\n");
#endif
	
		wdt_start();
#ifdef  DEBUG_LOG
		printf("wdt_start\r\n");
		printf("Enter main loop\r\n");		
#endif	

		OLED_POWER_CONTROL(1);
		nrf_delay_ms(2000);
		OLED_POWER_CONTROL(0);
    for (;;)
    {
			
			updata_by_min();
			updata_by_hour();
			power_manage();
    }
}