Пример #1
0
/**
 * Function to test mesh functionality. We have to figure out if we have to enable the radio first, and that kind of
 * thing.
 */
void CMesh::init() {
	LOGi("For now we are testing the meshing functionality.");
	nrf_gpio_pin_clear(PIN_GPIO_LED0);

	rbc_mesh_init_params_t init_params;

	init_params.access_addr = 0xA541A68F;
	init_params.adv_int_ms = 100;
	init_params.channel = 38;
	init_params.handle_count = 2;
	init_params.packet_format = RBC_MESH_PACKET_FORMAT_ORIGINAL;
	init_params.radio_mode = RBC_MESH_RADIO_MODE_BLE_1MBIT;

	LOGi("Call rbc_mesh_init");
	uint8_t error_code;
	// checks if softdevice is enabled etc.
	error_code = rbc_mesh_init(init_params);
	APP_ERROR_CHECK(error_code);

	LOGi("Call rbc_mesh_value_enable. Todo. Do this on send() and receive()!");
	error_code = rbc_mesh_value_enable(1);
	APP_ERROR_CHECK(error_code);
	error_code = rbc_mesh_value_enable(2);
	APP_ERROR_CHECK(error_code);
}
Пример #2
0
/** @brief main function */
int main(void)
{
    /* Enable Softdevice (including sd_ble before framework */
    uint32_t error_code = 
        sd_softdevice_enable(NRF_CLOCK_LFCLKSRC_XTAL_75_PPM, sd_assert_handler);
    APP_ERROR_CHECK(error_code);
    
    ble_enable_params_t ble_enable_params;
    ble_enable_params.gatts_enable_params.service_changed = 0;
    
    error_code = sd_ble_enable(&ble_enable_params);
    APP_ERROR_CHECK(error_code);
    
    /* init leds and pins */
    gpio_init();
    
#ifdef RBC_MESH_SERIAL
    
    /* only want to enable serial interface, and let external host setup the framework */
    mesh_aci_init();

#else    
    /* Enable mesh framework on channel 37, min adv interval at 100ms, 
        2 characteristics */
    rbc_mesh_init_params_t init_params;

    init_params.access_addr = 0xA541A68F;
    init_params.adv_int_ms = 100;
    init_params.channel = 38;
    init_params.handle_count = 2;
    init_params.packet_format = RBC_MESH_PACKET_FORMAT_ORIGINAL;
    init_params.radio_mode = RBC_MESH_RADIO_MODE_BLE_1MBIT;
    
    error_code = rbc_mesh_init(init_params);
    APP_ERROR_CHECK(error_code);
    
    /* request values for both LEDs on the mesh */
    error_code = rbc_mesh_value_enable(1);
    APP_ERROR_CHECK(error_code);
    error_code = rbc_mesh_value_enable(2);
    APP_ERROR_CHECK(error_code);
    
    
    /* init BLE gateway softdevice application: */
    nrf_adv_conn_init();
    
#endif
    
    /* enable softdevice IRQ */
    sd_nvic_EnableIRQ(SD_EVT_IRQn);
    
    
    /* sleep */
    while (true)
    {
        sd_app_evt_wait();
    }
    

}
Пример #3
0
int main(void)
{
    uint32_t error_code;
    (void) error_code;

    uart_init();

    PUTS("LED Mesh initializing");

    error_code = 
        sd_softdevice_enable(NRF_CLOCK_LFCLKSRC_XTAL_75_PPM, sd_assert_handler);
    
    test_app_init();


#ifdef RBC_MESH_SERIAL
    mesh_aci_init();
#else

    PUTS("mesh service init");

    rbc_mesh_init_params_t init_params;

    init_params.access_addr = 0xA541A68F;
    init_params.adv_int_ms = 100;
    init_params.channel = 38;
    init_params.handle_count = 2;
    init_params.packet_format = RBC_MESH_PACKET_FORMAT_ORIGINAL;
    init_params.radio_mode = RBC_MESH_RADIO_MODE_BLE_1MBIT;

    error_code = rbc_mesh_init(init_params);
    APP_ERROR_CHECK(error_code);

    error_code = rbc_mesh_value_enable(1);
    APP_ERROR_CHECK(error_code);
    error_code = rbc_mesh_value_enable(2);
    APP_ERROR_CHECK(error_code);
#endif

    sd_nvic_EnableIRQ(SD_EVT_IRQn);

    /* sleep */
    while (true)
    {
        sd_app_evt_wait();
    }

}
Пример #4
0
/** @brief main function */
int main(void)
{
    uart_init();

    PUTS("LED Mesh initializing");

    /* Enable Softdevice (including sd_ble before framework */
    uint32_t error_code = 
        sd_softdevice_enable(NRF_CLOCK_LFCLKSRC_XTAL_75_PPM, sd_assert_handler);
    APP_ERROR_CHECK(error_code);
    
    ble_enable_params_t ble_enable_params;
    memset(&ble_enable_params, 0, sizeof(ble_enable_params));

    ble_enable_params.gatts_enable_params.service_changed = 0;
    ble_enable_params.gatts_enable_params.attr_tab_size = BLE_GATTS_ATTR_TAB_SIZE_DEFAULT;

    error_code = sd_ble_enable(&ble_enable_params);
    APP_ERROR_CHECK(error_code);

    /* init leds and pins */
    gpio_init();

#ifdef RBC_MESH_SERIAL

    /* only want to enable serial interface, and let external host setup the framework */
    mesh_aci_init();

#else
    /* Enable mesh framework on channel 37, min adv interval at 100ms, 
        2 characteristics */
    rbc_mesh_init_params_t init_params;

    init_params.access_addr = 0xA541A68F;
    init_params.adv_int_ms = 100;
    init_params.channel = 38;
    init_params.handle_count = 2;
    init_params.packet_format = RBC_MESH_PACKET_FORMAT_ORIGINAL;
    init_params.radio_mode = RBC_MESH_RADIO_MODE_BLE_1MBIT;

    error_code = rbc_mesh_init(init_params);
    APP_ERROR_CHECK(error_code);

    /* request values for both LEDs on the mesh */
    error_code = rbc_mesh_value_enable(1);
    APP_ERROR_CHECK(error_code);
    error_code = rbc_mesh_value_enable(2);
    APP_ERROR_CHECK(error_code);


    /* init BLE gateway softdevice application: */
    nrf_adv_conn_init();

#endif

    /* enable softdevice IRQ */
    error_code = sd_nvic_EnableIRQ(SD_EVT_IRQn);


#ifndef BUTTONS
    /* sleep */
    while (true)
    {
        sd_app_evt_wait();
    }


#else
    uint8_t mesh_data[16] = {0,0};
    while (true)
    {
        // red off
        if(nrf_gpio_pin_read(BUTTON_1) == 0)
        {
            PUTS("BUTTON_1 pressed");
            while(nrf_gpio_pin_read(BUTTON_1) == 0);
            mesh_data[0] = 0;
            rbc_mesh_value_set(1, mesh_data, 1);
        }
        // red on
        if(nrf_gpio_pin_read(BUTTON_2) == 0)
        {
            PUTS("BUTTON_1 pressed");
            while(nrf_gpio_pin_read(BUTTON_2) == 0);
            mesh_data[0] = 1;
            rbc_mesh_value_set(1, mesh_data, 1);
        }
        // green off 
        if(nrf_gpio_pin_read(BUTTON_3) == 0)
        {
            PUTS("BUTTON_3 pressed");
            while(nrf_gpio_pin_read(BUTTON_3) == 0);
            mesh_data[0] = 0;
            rbc_mesh_value_set(2, mesh_data, 1);
        }
        // green on
         if(nrf_gpio_pin_read(BUTTON_4) == 0)
        {
            PUTS("BUTTON_4 pressed");
            while(nrf_gpio_pin_read(BUTTON_4) == 0);
            mesh_data[0] = 1;
            rbc_mesh_value_set(2, mesh_data, 1);
        }
    }
#endif

}