bt_gatt_server_console_write()
Description
This function is utilized to update the GATT console RX characteristic value, enabling the GATT client to perform a read operation. Furthermore, it includes functionality to transmit a notification when this feature is activated at console init.
Syntax
bt_gatt_server_console_write(data[], data_length);
Parameters
Variable | Input |
|---|---|
| Data utilized to update the GATT server console characteristic value and transmit to the GATT client. |
| The length of the data utilized for updating the GATT server console characteristic value and sending notifications. Maximum value is 200 bytes. |
Returns
Return value | Return explanation |
SCRIPT_OPERATION_SUCCESS | Successfully updated GATT console RX characteristic. |
SCRIPT_OPERATION_FAILED | GATT console characteristic is not registered. |
SCRIPT_NO_ACCESS | Bluetooth GATT server is not initialized. |
SCRIPT_PARAM_INVALID | Reasons:
|
Function call example
#include <io>
#include <read>
#include <float>
#include <string>
#include <core>
#include <write>
#include <define>
#include <socket>
#include <bluetooth>
new gatt_rx_data[64];
new data[4] = [0x74, 0x65, 0x73, 0x74];
forward public callback (event);
public callback (event)
{
switch(event)
{
case BT_GATT_SERVER_RX:
{
new data_len = bt_gatt_server_receive(gatt_rx_data);
if (gatt_rx_data[GATT_RX_HEADER_USER_REF_POS] == GATT_CONSOLE_REFERENCE)
{
gatt_console_rx(data_len);
}
}
}
return 0;
}
gatt_console_rx(msg_len)
{
/* Handle console rx code start */
/* Handle console rx code end */
}
main()
{
bt_init();
bt_gatt_server_init();
bt_gatt_server_console_init(GATT_CHRC_PROP_NOTIFY);
bt_gatt_server_start();
Delay(1000);
bt_gatt_server_console_write(data, sizeof(data));
for(;;)
{
Delay(100);
}
}