Characteristic cannot be found by GattDb_FindCharValue

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Characteristic cannot be found by GattDb_FindCharValue

1,284件の閲覧回数
ppz
Contributor II

Hello,

I create a BLE application with specific UUID128 for a service & charactersistics.

My gatt_uuid128.h file looks like this

UUID128(uuid_service, 0x19, 0xB1, 0x00, 0x00, 0xE8, 0xF2, 0x53, 0x7E, 0x4F, 0x6C, 0xD1, 0x04, 0x76, 0x8A, 0x12, 0x14)

UUID128(uuid_datachar,0x14, 0x12, 0x8a, 0x76, 0x04, 0xd1, 0x6c, 0x4f, 0x7e, 0x53, 0xf2, 0xe8, 0x05, 0x00, 0xb1, 0x1)

My gatt_db.h file looks like this

PRIMARY_SERVICE_UUID128(service_r, uuid_service)
CHARACTERISTIC_UUID128(char_device_name, uuid_service, (gGattCharPropRead_c) )
VALUE_UUID128(value_device_name, uuid_service_ring, (gPermissionFlagReadable_c), 6, "cust0")
CHARACTERISTIC_UUID128(char_data, uuid_datachar, (gGattCharPropRead_c | gGattCharPropNotify_c))
VALUE_UUID128(value_data, uuid_datachar, (gPermissionFlagReadable_c),20, 0x00)

Then, in the function of a service start in custom_service.c file in a "bluetooth->profiles" directory I have such code.

uint8_t uuid_s_Array[] = {0x19, 0xB1, 0x00, 0x00, 0xE8, 0xF2, 0x53, 0x7E, 0x4F, 0x6C, 0xD1, 0x04, 0x76, 0x8A, 0x12, 0x14};
uint8_t uuid_data_Array[] = { 0x1, 0xb1, 0x00, 0x05, 0xe8, 0xf2, 0x53, 0x7e, 0x4f, 0x6c, 0xd1, 0x04, 0x76, 0x8a, 0x12, 0x14};

bleUuid_t uuidsService;
memcpy(uuidsService.uuid128,uuid_s_Array, 16);
bleUuid_t uuidDataChar;
memcpy(uuidDataChar.uuid128, uuid_data_Array, 16);

result = GattDb_FindCharValueHandleInService(serviceConfig->serviceHandle, gBleUuidType128_c, &uuidsService, &handle);

result |= GattDb_FindCharValueHandleInService(serviceConfig->serviceHandle, gBleUuidType128_c, &uuidDataChar, &handle);

For the first result, I have 0x00 a.k.a success return value, but the second one gives me 0x902 which goes for "Characterstic not found". How can I sort it out? I am running KSDK 2.0 on a KW41Z board.

Best regards,

Petr

ラベル(1)
タグ(5)
2 返答(返信)

1,085件の閲覧回数
gerardo_rodriguez
NXP Employee
NXP Employee

Hello Petr,

I have some comments about your service declaration:

PRIMARY_SERVICE_UUID128(service_r, uuid_service)
   CHARACTERISTIC_UUID128(char_device_name, uuid_service, (gGattCharPropRead_c) )
        VALUE_UUID128(value_device_name, uuid_service_ring, (gPermissionFlagReadable_c), 6, "cust0")
   CHARACTERISTIC_UUID128(char_data, uuid_datachar, (gGattCharPropRead_c | gGattCharPropNotify_c))

        VALUE_UUID128(value_data, uuid_datachar, (gPermissionFlagReadable_c),20, 0x00)

Your first characteristic has the same UUID as the service and it must have it's own UUID128 as the second characteristic and the uuid_service_ring is missing from gatt_uuid128.h.

About your code: 

result = GattDb_FindCharValueHandleInService(serviceConfig->serviceHandle, gBleUuidType128_c, &uuidsService, &handle);

result |= GattDb_FindCharValueHandleInService(serviceConfig->serviceHandle, gBleUuidType128_c, &uuidDataChar, &handle);

What is the purpose of the first function? The function is for finding Characteristic handles and you are looking for a service UUID.

In the second function, the UUID is in reverse order compared to the one declared in gatt_uuid128.h, so this might be the reason that the "Characterstic not found" result is being returned.

For more information on creating a custom GATT database, refer to the chapter 7.1 Creating static GATT database from the "..\SDK_2.2_MKW41Z512xxx4\docs\wireless\Bluetooth\BLE Application Developer's Guide.pdf" document.

Let me know your findings or if you have any question.

Regards,

Gerardo

1,085件の閲覧回数
ppz
Contributor II

Thank you for your response.

It is looked like you were right about both of the things, both of them were fixed and the code worked. Thanks!