■Development environment
Board: KW45B41Z-EVK
Sample SDK: kw45b41zevk_wireless_uart_bm
Hello, I'm a software developer.
I'm currently developing software using the KW45B41Z-EVK.
The sample program I'm using is kw45b41zevk_wireless_uart_bm.
As an implementation requirement, it is necessary to use 255-byte Notify, which is currently being considered.
Looking at the sample program above, there is a battery level notification definition in "\source\gatt_db.h", but the battery level value is 1 byte, so I tried to add a new Notify notification definition and process. thinking about. The 255 bytes to be notified can be set to any desired value and sent.
I tried adding a new Notify definition to gatt_db.h, but an error "gGattDbCharacteristicNotFound_c" occurred in the function "GattDb_FindCharValueHandleInService" to obtain the handle before sending, and I was unable to send.
Could you please tell me how to define gatt_db.h?
The test results, definitions and Additional Infomation are shown below.
■Execution results
The return value of the function that obtains the handle before writing to the DB resulted in an error, and Notify could not be sent.
Return value of function "GattDb_FindCharValueHandleInService" = 0x0902 (gGattDbCharacteristicNotFound_c)
■Definition of PRIMARY_SERVICE, CHARACTERISTIC, VALUE, CCCD
\source\gatt_db.h
*The following definition is obtained by copying the already defined "service_gatt", then changing the name and changing the Indicate specification to Notify specification.
--------
PRIMARY_SERVICE(service_command_notify, gBleSig_GenericAttributeProfile_d)
CHARACTERISTIC(char_command_notify, gBleSig_GattServiceChanged_d, (gGattCharPropNotify_c))
VALUE(value_command_notify, gBleSig_GattServiceChanged_d, (gPermissionFlagReadable_c), 255)
CCCD(cccd_command_notify)
--------
■Source code
The code below is a copy of the battery level handling and renamed.
\bluetooth\profiles\dku2r_notify\dku2r_notify_interface.h
--------
/*! Notify Service - Configuration */
typedef struct dku2rNotifyConfig_tag
{
uint16_t serviceHandle;
uint8_t value[255];
bool_t* aValidSubscriberList;
uint8_t validSubscriberListSize;
} dku2rNotifyConfig_t;
--------
\bluetooth\profiles\dku2r_notify\dku2r_notify_service.c
--------
bleResult_t DKU2R_Notify_RecordNotificationMeasurement(dku2rNotifyConfig_t *pServiceConfig)
{
uint16_t handle = gGattDbInvalidHandle_d;
bleResult_t result = gBleSuccess_c;
bleUuid_t uuid = Uuid16(gBleSig_GenericAttributeProfile_d);
/* Get handle of characteristic */
result = GattDb_FindCharValueHandleInService(pServiceConfig->serviceHandle, gBleUuidType16_c, &uuid, &handle);
DPRINTF("[DBG][%s] called GattDb_FindCharValueHandleInService ret = 0x%04x\n", __func__, result);
if (result == gBleSuccess_c)
{
/* Update characteristic value and send notification */
result = GattDb_WriteAttribute(handle, (uint16_t)sizeof(uint8_t), &pServiceConfig->value);
DPRINTF("[DBG][%s] called GattDb_WriteAttribute ret = 0x%04x\n", __func__, result);
if (result == gBleSuccess_c)
{
DKU2R_Notify_SendNotifications(pServiceConfig, handle);
}
}
return result;
}
--------
■Additional Infomation
In the sample SDK that I am currently using (kw45b41zevk_wireless_uart_bm), the following characteristics are defined, but the only Notify is the battery level. There was a similar Indicate, but when I copied the service of this Indicate and changed the name and changed the Indicate specification to Notify specification, gGattDbCharacteristicNotFound_c occurred.
●Used in indicate
・gBleSig_GattServiceChanged_d
●Used in read
・gBleSig_GapDeviceName_d, gBleSig_GapAppearance_d, gBleSig_GattSecurityLevels_d, gBleSig_ManufacturerNameString_d, gBleSig_ModelNumberString_d, gBleSig_SerialNumberString_d, gBleSig_HardwareRevisionString_d, gBleSig_FirmwareRevisionString _d, gBleSig_SoftwareRevisionString_d,
●Used in write
・uuid_uart_stream・・・This UUID is defined by NXP
●Used with Notify
・gBleSig_BatteryLevel_d
Thank you.
Hello @masayuki_I,
Hope you are doing well.
Please, refer to the BLE Application Developer's Guide included in KW45 SDK documentation folder > docs > wireless Bluetooth. This document explains how to integrate the Bluetooth Low Energy Host Stack in an application and provides detailed explanations of the most commonly used APIs and code examples. This document also sets out the prerequisites and the initialization of the BLE Host Stack, followed by the presentation of APIs grouped by layers and by application role.
You can consult the following sections:
Regards,
Eduardo.
thank you for your reply.
Thank you for letting me know about the KW45 SDK documentation. When I checked the API description in Chapter 6, I realized that there was an error in how I used the API.
After correcting the error, it is now possible to send multi-byte Notify.
thank you very much.
Masayuki.