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; } }
int gatt_svr_register(void) { int rc; rc = ble_gatts_register_svcs(gatt_svr_svcs, gatt_svr_register_cb, NULL); return rc; }
static void prphtest_register_attrs(void) { int rc; rc = ble_gatts_register_svcs(prphtest_svcs, prphtest_register_cb, NULL); assert(rc == 0); }
} TEST_CASE(ble_gatts_reg_test_svc_return) { int rc; ble_gatts_reg_test_init(); /*** Missing type. */ struct ble_gatt_svc_def svcs_no_type[] = { { .uuid128 = BLE_UUID16(0x1234), }, { .type = BLE_GATT_SVC_TYPE_END, } }; rc = ble_gatts_register_svcs(svcs_no_type, NULL, NULL); TEST_ASSERT(rc == BLE_HS_EINVAL); /*** Missing UUID. */ struct ble_gatt_svc_def svcs_no_uuid[] = { { .type = BLE_GATT_SVC_TYPE_PRIMARY, }, { .type = BLE_GATT_SVC_TYPE_END, } }; rc = ble_gatts_register_svcs(svcs_no_uuid, NULL, NULL); TEST_ASSERT(rc == BLE_HS_EINVAL); /*** Circular dependency. */ struct ble_gatt_svc_def svcs_circ[] = { { .type = BLE_GATT_SVC_TYPE_PRIMARY,