static void
ble_gatts_read_test_misc_init(uint16_t *out_conn_handle)
{
    int rc;

    ble_hs_test_util_init();

    rc = ble_gatts_register_svcs(ble_gatts_read_test_svcs,
                                 ble_gatts_read_test_misc_reg_cb, NULL);
    TEST_ASSERT_FATAL(rc == 0);
    TEST_ASSERT_FATAL(ble_gatts_read_test_chr_1_def_handle != 0);
    TEST_ASSERT_FATAL(ble_gatts_read_test_chr_1_val_handle ==
                      ble_gatts_read_test_chr_1_def_handle + 1);
    TEST_ASSERT_FATAL(ble_gatts_read_test_chr_2_def_handle != 0);
    TEST_ASSERT_FATAL(ble_gatts_read_test_chr_2_val_handle ==
                      ble_gatts_read_test_chr_2_def_handle + 1);

    ble_gatts_start();

    ble_hs_test_util_create_conn(2, ble_gatts_read_test_peer_addr, NULL, NULL);

    if (out_conn_handle != NULL) {
        *out_conn_handle = 2;
    }
}
示例#2
0
文件: main.c 项目: A-Paul/RIOT
int main(void)
{
    puts("NimBLE GATT Server Example");

    int rc = 0;

    /* verify and add our custom services */
    rc = ble_gatts_count_cfg(gatt_svr_svcs);
    assert(rc == 0);
    rc = ble_gatts_add_svcs(gatt_svr_svcs);
    assert(rc == 0);

    /* set the device name */
    ble_svc_gap_device_name_set(device_name);
    /* reload the GATT server to link our added services */
    ble_gatts_start();

    /* configure and set the advertising data */
    uint8_t buf[BLE_HS_ADV_MAX_SZ];
    bluetil_ad_t ad;
    bluetil_ad_init_with_flags(&ad, buf, sizeof(buf), BLUETIL_AD_FLAGS_DEFAULT);
    bluetil_ad_add_name(&ad, device_name);
    ble_gap_adv_set_data(ad.buf, ad.pos);

    /* start to advertise this node */
    start_advertise();

    return 0;
}
示例#3
0
int
ble_hs_start(void)
{
    int rc;

    ble_hs_parent_task = os_sched_get_current_task();

    ble_hs_heartbeat_timer_reset(BLE_HS_HEARTBEAT_OS_TICKS);

    ble_gatts_start();

    rc = ble_hs_startup_go();
    return rc;
}