|
#define NRF_ERROR_BASE_NUM (0x0) ///< Global error base
#define NRF_ERROR_NO_MEM (NRF_ERROR_BASE_NUM + 4) ///< No Memory for operation错误代码类型
#define TEST1_UUID_BASE {0x12, 0xE0, 0x15, 0x23, 0x9D, 0xBC, 0x4C, 0x4A, 0x8D, 0x1E, 0x20, 0xB5, 0xBB, 0x94, 0xA7, 0x98}
//{0x23, 0xD1, 0xBC, 0xEA, 0x5F, 0x78, 0x23, 0x15, 0xDE, 0xEF, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00} //例程
//{0x12, 0xE0, 0x15, 0x23, 0x9D, 0xBC, 0x4C, 0x4A, 0x8D, 0x1E, 0x20, 0xB5, 0xBB, 0x94, 0xA7, 0x98} //自己生成的
#define TEST1_UUID_SERVICE 0x1526
#define TEST1_UUID_TEST_CHAR1 0x1527
#define TEST1_UUID_TEST_CHAR2 0x1528
//服务初始化函数
uint32_t test1_ble_init(ble_test1_t * p_test, const ble_test1_init_t * p_test_init){
/*this function is use to init test server
这个函数是用来初始化test 这个服务*/
uint32_t err_code;
ble_uuid_t ble_uuid;
p_test->conn_handle = BLE_CONN_HANDLE_INVALID;
p_test->char1_write_handler = p_test_init->char1_write_handle;
ble_uuid128_t base_uuid = {TEST1_UUID_BASE};
err_code = sd_ble_uuid_vs_add(&base_uuid,&p_test->uuid_type);
my_printf("test1_uuid_err_code:");
my_int_printf(err_code);
my_printf("\r\n");
VERIFY_SUCCESS(err_code);
ble_uuid.type = p_test->uuid_type;
ble_uuid.uuid = TEST1_UUID_SERVICE;
err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &p_test->service_handle);
VERIFY_SUCCESS(err_code);
return NRF_SUCCESS;
}
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|