/*JSON{
    "type" : "staticmethod",
    "class" : "Bluetooth",
    "name" : "init", 
    "generate" : "jswrap_nrf_bluetooth_init"
}*/
void jswrap_nrf_bluetooth_init(void)
{
    uint32_t err_code;
    bool erase_bonds;
    
    // Initialize.
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, false);
    buttons_leds_init(&erase_bonds);
    ble_stack_init();
    gap_params_init();
    services_init();
    advertising_init();
    conn_params_init();
    
    err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);
    
    ble_com = false;

    // Enter main loop.
    //for (;;)
    //{
        //power_manage();
    //}
}
/**@brief Function for application main entry.
 */
int main(void)
{
    bool erase_bonds;

    // Initialize.
    log_init();
    timers_init();
    buttons_leds_init(&erase_bonds);
    power_management_init();
    ble_stack_init();
    gap_params_init();
    gatt_init();

	  services_init();
		advertising_init();



    conn_params_init();
    peer_manager_init();

    // Start execution.
    NRF_LOG_INFO("OurCharacteristics tutorial started.");
    application_timers_start();

    advertising_start(erase_bonds);

    // Enter main loop.
    for (;;)
    {
        idle_state_handle();
    }
}
Beispiel #3
0
/**@brief Function for application main entry.
 */
int main(void)
{
    uint32_t err_code;
    bool erase_bonds;

#ifdef ENABLE_DEBUG_LOG_SUPPORT
    app_trace_init();
#endif

    APPL_LOG("START\r\n");

    // Initialize.
    timers_init();
    buttons_leds_init(&erase_bonds);
    adc_config();
    ble_stack_init();
    device_manager_init(erase_bonds);
    gap_params_init();
    advertising_init();
    services_init();
    conn_params_init();

    // Start execution.
    err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);
    APPL_LOG("start advertising : %u\n", err_code);

    // Enter main loop.
    for (;;)
    {
        power_manage();
    }
}
Beispiel #4
0
/**@brief Function for application main entry.
 */
int main(void)
{
    uint32_t err_code;
    bool erase_bonds;

    // Initialize.
    err_code = NRF_LOG_INIT();
    APP_ERROR_CHECK(err_code);

    timers_init();
    buttons_leds_init(&erase_bonds);
    ble_stack_init();
    peer_manager_init(erase_bonds);
    if (erase_bonds == true)
    {
        NRF_LOG_DEBUG("Bonds erased!\r\n");
    }
    gap_params_init();
    advertising_init();
    db_discovery_init();
    alert_notification_init();
    conn_params_init();

    // Start execution.
    advertising_start();

    // Enter main loop.
    for (;;)
    {
        power_manage();
    }
}
Beispiel #5
0
/**@brief Function for application main entry.
 */
int main(void)
{
    uint32_t err_code;
    bool erase_bonds;

    // Initialize.
    timers_init();
    buttons_leds_init(&erase_bonds);
    ble_stack_init();
    device_manager_init(erase_bonds);
    gap_params_init();
    advertising_init();
    services_init();
    sensor_simulator_init();
    conn_params_init();

    ble_evt_pool      = osPoolCreate(osPool(ble_evt_pool));
    ble_stack_msg_box = osMessageCreate(osMessageQ(ble_stack_msg_box), NULL);

    // Start execution.
    ble_stack_thread_id = osThreadCreate(osThread(ble_stack_thread), NULL);
    UNUSED_VARIABLE(ble_stack_thread_id);
    application_timers_start();
    err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);

    // Enter main loop.
    for (;; )
    {
        UNUSED_VARIABLE(osDelay(1000));
    }
}
/**@brief Function for application main entry.
 */
int main(void)
{
    SEGGER_RTT_WriteString(0, "\033[2JTutorial Start.\n\n");
    uint32_t err_code;
    bool erase_bonds;

    // Initialize.
    timers_init();
    buttons_leds_init(&erase_bonds);
    ble_stack_init();
    device_manager_init(erase_bonds);
    gap_params_init();
    services_init();
    advertising_init();
    conn_params_init();

    // Start execution.
    application_timers_start();
    err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);

    // Enter main loop.
    for (;;)
    {
        power_manage();
    }
}
Beispiel #7
0
/**@brief Function for application main entry.
 */
int main(void)
{
    uint32_t err_code;
    

    // Initialize.
    app_trace_init();
    timers_init();
	
		bool erase_bonds;
    buttons_leds_init(&erase_bonds);
		device_manager_init(erase_bonds);
	
    ble_stack_init();
    gap_params_init();
    advertising_init();
    services_init();
    sensor_simulator_init();
    conn_params_init();

    // Start execution.
    application_timers_start();
    err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);
		
		
    // Enter main loop.
    for (;;)
    {
        power_manage();
    }
}
Beispiel #8
0
/**@brief Function for application main entry.
 */
int main(void)
{
    uint32_t err_code;
    bool     erase_bonds;

    // Initialize
    timers_init();
    nrf_log_init();
    buttons_leds_init(&erase_bonds);
    ble_stack_init();
    device_manager_init(erase_bonds);
    db_discovery_init();
    scheduler_init();
    gap_params_init();
    advertising_init();
    services_init();
    conn_params_init();

    // Start execution
    err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);

    NRF_LOG("\r\nCTS Start!\r\n");
    
    // Enter main loop
    for (;;)
    {
        app_sched_execute();
        power_manage();
    }
}
Beispiel #9
0
/**@brief Application main function.
 */
int main(void)
{
    uint32_t err_code;
    bool erase_bonds;

    // Initialize.
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);

    buttons_leds_init(&erase_bonds);
    ble_stack_init();
    gap_params_init();
    services_init();
    advertising_init();
    conn_params_init();
	gpio_init();
	timer_init(); //timer task to refresh RGB LED Board
	game_init();

    err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);

    // Enter main loop.
    for (;;) {
        power_manage();
		moveDisc(getInput());
    }
}
Beispiel #10
0
int main(void)
{
    uint32_t err_code;
    bool erase_bonds;

    // Initialize.
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, NULL);
    buttons_leds_init(&erase_bonds);
    uart_init();
    printf("Relay Example\r\n");
    ble_stack_init();
    device_manager_init(erase_bonds);
    db_discovery_init();
    hrs_c_init();
    rscs_c_init();
    
    gap_params_init();
    services_init();
    advertising_init();
    conn_params_init();

    // Start scanning for peripherals and initiate connection
    // with devices that advertise Heart Rate UUID.
    scan_start();
    
    // Start advertising.
    err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);
    
    for (;; )
    {
        power_manage();
    }
}
Beispiel #11
0
/**@brief Function for application main entry.
 */
int main(void)
{
    uint32_t err_code;
    bool erase_bonds;

    // Initialize.
    timers_init();
    buttons_leds_init(&erase_bonds);
    ble_stack_init();
    device_manager_init(erase_bonds);
    gap_params_init();
    advertising_init();
    services_init();
    conn_params_init();
    saadc_init();

    // Start execution.
    application_timers_start();
    err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);

    // Enter main loop.
    for (;;)
    {
       			  // trigger next ADC conversion
        nrf_drv_saadc_sample_convert(0,&adc_sample);
        advdata.p_manuf_specific_data->data.p_data[0] = adc_sample/100 + '0';
        advdata.p_manuf_specific_data->data.p_data[1] = adc_sample%100/10 + '0';
        advdata.p_manuf_specific_data->data.p_data[2] = adc_sample%10 + '0';
        nrf_delay_ms(100);
        ble_advdata_set(&advdata, NULL);
    }
}
/**@brief Application main function.
 */
int main(void)
{
    uint32_t err_code;
    bool erase_bonds;

    // Initialize.
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);
    uart_init();
    
    buttons_leds_init(&erase_bonds);
    ble_stack_init();
    gap_params_init();
    services_init();
    advertising_init();
    conn_params_init();

    printf("\r\nUART Start!\r\n");
    err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);
    
    // Enter main loop.
    for (;;)
    {
        power_manage();
    }
}
Beispiel #13
0
/**@brief Function for application main entry.
 */
int main(void)
{
    bool erase_bonds;

    // Initialize.
    app_trace_init();
    timers_init();
    buttons_leds_init(&erase_bonds);
    ble_stack_init();
    adc_configure();
    device_manager_init(erase_bonds);
    gap_params_init();
    advertising_init(BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE);
    services_init();
    conn_params_init();

    // Start execution.
    advertising_start();

    // Enter main loop.
    for (;;)
    {
        power_manage();
    }
}
Beispiel #14
0
/**@brief Function for application main entry.
 */
int main(void)
{
    bool     erase_bonds;
    uint32_t err_code;

    // Initialize.
    app_trace_init();
    timers_init();
    uart_init();
    buttons_leds_init(&erase_bonds);
    ble_stack_init();
    APP_SCHED_INIT(SCHED_MAX_EVENT_DATA_SIZE, SCHED_QUEUE_SIZE);
    printf("BLE ANCS\n");
    device_manager_init(erase_bonds);
    db_discovery_init();
    scheduler_init();
    gap_params_init();
    service_init();
    advertising_init();
    conn_params_init();

    // Start execution.
    err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);

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

}
Beispiel #15
0
int main(void)
{
    bool erase_bonds;

    // Initialize.
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, NULL);
    buttons_leds_init(&erase_bonds);
    uart_init();
    printf("Battery collector example\r\n");
    ble_stack_init();
    device_manager_init(erase_bonds);
    db_discovery_init();
    //hrs_c_init();
    bas_c_init();
    pwm_init();

    // Start scanning for peripherals and initiate connection
    // with devices that advertise Heart Rate UUID.
    scan_start();

    for (;; )
    {
        power_manage();
    }
}
/**@brief Function for application main entry.
 */
int main(void)
{
    uint32_t err_code;
    bool erase_bonds;

    app_trace_init();
    // Initialize.
    timers_init();
    buttons_leds_init(&erase_bonds);
    ble_stack_init();
    device_manager_init(erase_bonds);
    gap_params_init();
    advertising_init();
    services_init();
    conn_params_init();

    // Start execution.
    application_timers_start();
    APPL_LOG("Start Advertising \r\n");
    printf("Dhavaltest\r\n");
    SEGGER_RTT_WriteString(0, "SEGGER Real-Time-Terminal Sample\r\n");
    err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);

    // Enter main loop.
    for (;;)
    {
        power_manage();
    }
}
Beispiel #17
0
/**@brief Application main function.
 */
int main(void)
{	
    uint32_t err_code;
    bool erase_bonds;
    uint8_t  start_string[] = START_STRING;
	
    // Initialize.
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);
    uart_init();
    buttons_leds_init(&erase_bonds);
    ble_stack_init();
    gap_params_init();
    services_init();
    advertising_init();
    conn_params_init();
    
    printf("%s",start_string);
	
    UnityMain(0, NULL, RunAllTests);

    err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);
    // Enter main loop.
    for (;;)
    {
        power_manage();
    }
}
Beispiel #18
0
int main(void)
{
    uint32_t err_code;
    bool erase_bonds;
   // uint8_t  start_string[] = START_STRING;
	  //const ble_gap_addr_t  t_addr={0,{0xaa,0x55,0x33,0x44,0x55,0x66}};
//    const char  temp_str[]={0xaa,0x5c,0x00,0x02,0x00,0x00,0xa1,0x55};
    // Initialize.
    //bsp_configuration();
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, false);    
    buttons_leds_init(&erase_bonds);
#if ENABLE_COS
    simple_uart_init(UART_POWEROFF_BT_DELAY);
#else 
    uart_init_lowPower();
#endif

		etSpim1NorFlashInit();
#if DEBUG_UART_EN    
   //DbgPrintf("\r\n===flash_init===\r\n");
#endif
    ble_stack_init();
    
#ifdef BLE_DFU_APP_SUPPORT 
    device_manager_init(erase_bonds);
#endif
    
    //BT_set_address((UINT8 *)DEVICE_MAC_ADDR);
    BT_set_address();
    gap_params_init();   
    advertising_init();    
    services_init();
    //advertising_init();
    conn_params_init();  
#if ENABLE_COS   
    SetToGetKEYID();
#endif
    dev_init();		
	  
    //err_code = ble_advertising_start(BLE_ADV_MODE_SLOW);
#if DEBUG_UART_EN    
//    DbgPrintf("go to advertising7\r\n");
#endif     
	 err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
   APP_ERROR_CHECK(err_code);
    
    // Enter main loop.
    for (;;)
    {
		  main_loop();		  
		  power_manage();
		  #if TAP_DOUBLE_CLCIK_ENABLE
		  	test_display_step_num(test_click_count);
		  #endif
    }
}
Beispiel #19
0
int main(void)
{
    ret_code_t err_code;
    bool       erase_bonds;

    err_code = NRF_LOG_INIT();
    APP_ERROR_CHECK(err_code);

    NRF_LOG_PRINTF("Relay Example\r\n");

    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, NULL);
    buttons_leds_init(&erase_bonds);

    if (erase_bonds == true)
    {
        NRF_LOG("Bonds erased!\r\n");
    }

    ble_stack_init();

    peer_manager_init(erase_bonds);

    db_discovery_init();
    hrs_c_init();
    rscs_c_init();

    gap_params_init();
    conn_params_init();
    services_init();
    advertising_init();

    /** Start scanning for peripherals and initiate connection to devices which
     *  advertise Heart Rate or Running speed and cadence UUIDs. */
    scan_start();

    // Turn on the LED to signal scanning.
    LEDS_ON(CENTRAL_SCANNING_LED);

    // Start advertising.
    err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);

    for (;;)
    {
        // Wait for BLE events.
        power_manage();
    }
}
Beispiel #20
0
int main(void)
{
	// watchdog is still enabled after a software reset and needs to be cleared immediately
	MCUSR = 0;
	wdt_disable();
	
	//uart_init(UART_BAUD_SELECT_DOUBLE_SPEED(57600, F_CPU));
	
	buttons_leds_init();
	dimmer_init();
	hm_init();
	sei();
	
	while(1)
    {
		hm_task();
    }
}
Beispiel #21
0
/**@brief Function for application main entry.
 */
int main(void)
{
    bool     erase_bonds;
    uint32_t err_code;

    // Initialize.
    err_code = NRF_LOG_INIT(NULL);
    APP_ERROR_CHECK(err_code);

    // Clear bond flag
    bond_present = false;

    timers_init();
    buttons_leds_init(&erase_bonds);
    ble_stack_init();
    peer_manager_init(erase_bonds);
    if (erase_bonds == true)
    {
        NRF_LOG_INFO("Bonds erased!\r\n");
    }
    gap_params_init();
    advertising_init();
    services_init();
    sensor_simulator_init();
    conn_params_init();
    whitelist_load();
    nfc_init(erase_bonds);

    // Start execution.
    NRF_LOG_INFO("Heart Rate Sensor NFC Start!\r\n");
    application_timers_start();

    // Enter main loop.
    for (;;)
    {
        if (NRF_LOG_PROCESS() == false)
        {
            power_manage();
        }
    }
}
Beispiel #22
0
/**@brief Function for application main entry.
 */
int main(void)
{
    uint32_t err_code;
    bool erase_bonds;

    //uart_config();

    //printf("\n\rBDC HAL simple example\r\n"); //GETS HERE, Dies after first letter!

    // Initialize.
    timers_init();
    buttons_leds_init(&erase_bonds);
    ble_stack_init();
    device_manager_init(erase_bonds);
    gap_params_init();
    advertising_init();
    services_init();
    //sensor_simulator_init();
    conn_params_init();

    //uart_config();

    //printf("\n\rBDC HAL simple example\r\n"); //GETS HERE, Dies after first letter!

    //printf("Current sample value:\r\n");

    adc_config();

    // Start execution.
    application_timers_start();
    nrf_adc_start();
    err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);

    // Enter main loop.
    for (;;)
    {
        power_manage();
    }
}
Beispiel #23
0
/**@brief Function for application main entry.
 */
int main(void)
{
    uint32_t err_code;
    bool erase_bonds = true;
	char buffer[256] = {'\0'};

    // Initialize.
    timers_init();
    buttons_leds_init(&erase_bonds);
	UART_init();
	printf("S130 Template\n");
	printf(TBC);
	
    Ble_Init(erase_bonds);
	printf("BLE is up\n");
	printf(TBC);

    // Start execution.
    application_timers_start();
    err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);

	printf("app start\n");
	printf(TBC);

    // Enter main loop.
    for (;;)
    {
		if (UART_RxReady()) {
			UART_GetBuffer(buffer, sizeof(buffer) - 1);
			printf("<<< %s\n", buffer);
			BLE_Uart_Send(buffer, strlen(buffer));
		}

		if (UART_TxReady()) {
			power_manage();
		}
    }
}
Beispiel #24
0
/**@brief Application main function.
 */
int main(void)
{
    uint32_t err_code;
    bool erase_bonds;

    err_code = NRF_LOG_INIT(NULL);
    APP_ERROR_CHECK(err_code);

    // Initialize
    timers_init();
    buttons_leds_init(&erase_bonds);

    ble_stack_init();
    peer_manager_init(erase_bonds);
    if (erase_bonds == true)
    {
        NRF_LOG_INFO("Bonds erased!\r\n");
    }
    gap_params_init();
    advertising_init();
    services_init();
    sim_init();
    conn_params_init();

    // Start execution
    application_timers_start();
    NRF_LOG_INFO("Location and Navigation App started\r\n");
    err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);

    // Enter main loop
    for (;;)
    {
        if (NRF_LOG_PROCESS() == false)
        {
            power_manage();
        }
    }
}
int main(void)
{
    ret_code_t err_code;
    bool       erase_bonds;

    err_code = NRF_LOG_INIT();
    APP_ERROR_CHECK(err_code);

    NRF_LOG_PRINTF("Relay Example\r\n");

    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, NULL);
    buttons_leds_init(&erase_bonds);

    if (erase_bonds)
    {
        NRF_LOG_PRINTF("Bonds erased!\r\n");
    }

    ble_stack_init();

    peer_manager_init(erase_bonds);

    db_discovery_init();
    hrs_c_init();
    rscs_c_init();

    gap_params_init();
    conn_params_init();
    services_init();
    advertising_init();

    adv_scan_start();

    for (;;)
    {
        // Wait for BLE events.
        power_manage();
    }
}
/**@brief Function for application main entry.
 */
int main(void)
{
    uint32_t err_code;
    bool erase_bonds;
    rotation_counter = NRF_TIMER1;
    debounce_timer = NRF_TIMER2;
    
    // Initialize.
    app_trace_init();
    timers_init();
    buttons_leds_init(&erase_bonds);
    ble_stack_init();
    device_manager_init(erase_bonds);
    gap_params_init();
    advertising_init();
    services_init();
    sensor_simulator_init();
    conn_params_init();

    usr_init(30);
    set_pin(USR_EN_PIN);
    bat_adc_init(4);
    
    gpio_pin_out_init(BRD_LED_PIN);

    // Start execution.
    application_timers_start();
    err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);
    usr_init(30);

    // Enter main loop.
    for (;; )
    {
        power_manage();
    }
}
Beispiel #27
0
/**@brief Thread for handling the Application's BLE Stack events.
 *
 * @details This thread is responsible for handling BLE Stack events sent from on_ble_evt().
 *
 * @param[in]   arg   Pointer used for passing some arbitrary information (context) from the
 *                    osThreadCreate() call to the thread.
 */
static void ble_stack_thread(void * arg)
{
    uint32_t  err_code;
    bool      erase_bonds;

    UNUSED_PARAMETER(arg);

    // Initialize.
    timers_init();
    buttons_leds_init(&erase_bonds);
    ble_stack_init();
    device_manager_init(erase_bonds);
    gap_params_init();
    advertising_init();
    services_init();
    sensor_simulator_init();
    conn_params_init();

    application_timers_start();
    err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);

    while (1)
    {
        /* Wait for event from SoftDevice */
        while(pdFALSE == xSemaphoreTake(m_ble_event_ready, portMAX_DELAY))
        {
            // Just wait again in the case when INCLUDE_vTaskSuspend is not enabled
        }

        // This function gets events from the SoftDevice and processes them by calling the function
        // registered by softdevice_ble_evt_handler_set during stack initialization.
        // In this code ble_evt_dispatch would be called for every event found.
        intern_softdevice_events_execute();
    }
}
Beispiel #28
0
/**@brief Function for application main entry.
 */
int main(void)
{
    uint32_t err_code;
    bool erase_bonds;

    // Initialize.
    gpio_init();
    // TODO: Measure battery
    nrf_gpio_pin_set(LED_1);
    err_code = NRF_LOG_INIT();
    APP_ERROR_CHECK(err_code);
        
    twi_init();
    sensors_init(&m_app_twi, sensors_callback);

    timers_init();
    buttons_leds_init();
//    erase_bonds = false;
    ble_stack_init();
    detect_erase_bond_pressed(&erase_bonds);
//    bool button;
//    err_code = app_button_is_pushed(0, &button);
//    APP_ERROR_CHECK(err_code);
//    uint8_t count = 0;
//    while (button) {
//        nrf_delay_ms(100);
//        count++;
//        if (count > 20) {
//            erase_bonds = true;
//            NRF_LOG_DEBUG("Erasing bonds!\r\n");
//            break;
//        }
//        err_code = app_button_is_pushed(0, &button);
//        APP_ERROR_CHECK(err_code);
//    }
//    while (button) {
//        nrf_gpio_pin_clear(LED_1);
//        nrf_delay_ms(200);
//        nrf_gpio_pin_set(LED_1);
//        nrf_delay_ms(200);
//        err_code = app_button_is_pushed(0, &button);
//        APP_ERROR_CHECK(err_code);
//    }
//    
    
    peer_manager_init(erase_bonds);
    gap_params_init();
    advertising_init();
    services_init();
    conn_params_init();
//    radio_notification_init();
    nrf_gpio_pin_clear(LED_1);

    // Start execution.
    application_timers_start();
    advertising_start();
//    sensors_measure();
    sensors_timers_init();
    sensors_timers_start();

    // Enter main loop.
    for (;;)
    {
        power_manage();
    }
}
Beispiel #29
0
int main(void)
{
    uint32_t err_code;
    bool erase_bonds;
    uint8_t  start_string[] = START_STRING;
    
    // Initialize.
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);
    uart_init();
    buttons_leds_init(&erase_bonds);
    ble_stack_init();
    gap_params_init();
    services_init();
    advertising_init();
    conn_params_init();
    
    printf("%s",start_string);

    err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);
    shiftRegInit();
    // Enter main loop.
    while (1)
    {
		if(!(nrf_gpio_pin_read(13))) {
			ble_nus_string_send(&m_nus, solution, sizeof(solution));
		}
		if(!(nrf_gpio_pin_read(14)) && knappSjekk) {
			solution[6] = 1;
			ble_nus_string_send(&m_nus, solution, sizeof(solution));
			knappSjekk = false;
		}
		if (nrf_gpio_pin_read(14)) {
			solution[6] = 0;
			knappSjekk = true;
		}
//		if(!(nrf_gpio_pin_read(14))) {
//			
//			nrf_gpio_pin_toggle(18);
//			nrf_delay_ms(150);
//			nrf_gpio_pin_toggle(18);
//			nrf_delay_ms(150);
//		}
		if(nrf_gpio_pin_read(btn1)) {
			btn1_counter = testFunksjon(btn1, btn1_counter);
			solution[0] = btn1_counter;
		}
		else if(nrf_gpio_pin_read(btn2)) {
			btn2_counter = testFunksjon(btn2, btn2_counter);
			solution[1] = btn2_counter;		
		}
		else if(nrf_gpio_pin_read(btn3)) {
			btn3_counter = testFunksjon(btn3, btn3_counter);
			solution[2] = btn3_counter;			
		}
		else if(nrf_gpio_pin_read(btn4)) {
			btn4_counter = testFunksjon(btn4, btn4_counter);
			solution[3] = btn4_counter;			
		}
		else if(nrf_gpio_pin_read(btn5)) {
			btn5_counter = testFunksjon(btn5, btn5_counter);
			solution[4] = btn5_counter;			
		}
		else if(nrf_gpio_pin_read(btn6)) {
			btn6_counter = testFunksjon(btn6, btn6_counter);
			solution[5] = btn6_counter;
		}
		shiftRegWrite(ledMatriseA[btn1_counter]+ledMatriseB[btn2_counter], ledMatriseA[btn3_counter]+ledMatriseB[btn4_counter], ledMatriseA[btn5_counter]+ledMatriseB[btn6_counter]);
		
		

        //power_manage();
    }
}