2022-05-07 09:32 AM
I use the sample program to copy a program, but it doesn't work, the error code is 0x47
How do achieve new characteristics and services?
2022-05-09 03:54 AM
Hi,
Have you tried increasing the MIN_NUM_LINK_CONF, NUM_APP_GATT_SERVICES_CONF and NUM_APP_GATT_CHAR_ATTRIBUTES_CONF macros under SerialPort_config.h?
It had solved the issue for me.
2022-05-09 12:16 PM
Thank you for your prompt reply,
I use the ST supply version 3.2.2 of the "BLE_SerialPort_Master_Slave" project. I try modify gatt_db.c add new characteristics UUID,
but did not succeed, system appears error code is "0x47",
After I reference the "PM0257" document and found I do not modify several parameters in SerialPort_config.h, such as
"NUM_APP_GATT_SERVICES",
"NUM_APP_GATT_ATTRIBUTES",
"ATT_VALUE_ARRAY_SIZE",
other the "gatt_db.c" service API "aci_gatt_add_service" fourth parameter must write the right value can create UUID and work on.
Final attached my result:
2022-05-09 10:27 PM
Hi @元�? 鄭,
Here is an example of how you can add services. In the below example, I am adding a battery service & a serial port service (this is the service that is already provided in the example code), under gatt_db.c.
/* Serial port TX (notification), RX(write without response) characteristics definition */
static const ble_gatt_chr_def_t serial_port_chars[] = {
{
.properties = BLE_GATT_SRV_CHAR_PROP_NOTIFY,
.permissions = BLE_GATT_SRV_PERM_NONE,
.min_key_size = BLE_GATT_SRV_MAX_ENCRY_KEY_SIZE,
.uuid = BLE_UUID_INIT_128(TX_CHR_UUID),
.descrs = {
.descrs_p = &BLE_GATT_SRV_CCCD_DEF_NAME(tx),
.descr_count = 1U,
},
},
{
.properties = BLE_GATT_SRV_CHAR_PROP_WRITE | BLE_GATT_SRV_CHAR_PROP_WRITE_NO_RESP,
.permissions = BLE_GATT_SRV_PERM_NONE,
.min_key_size = BLE_GATT_SRV_MAX_ENCRY_KEY_SIZE,
.uuid = BLE_UUID_INIT_128(RX_CHR_UUID),
},
};
/* Serial port Service definition */
static const ble_gatt_srv_def_t serial_port_service = {
.type = BLE_GATT_SRV_PRIMARY_SRV_TYPE,
.uuid = BLE_UUID_INIT_128(SRVC_UUID),
.chrs = {
.chrs_p = (ble_gatt_chr_def_t *)serial_port_chars,
.chr_count = 2U,
},
};
uint8_t battery_level_value = 20;
ble_gatt_val_buffer_def_t battery_level_val_buff = {
.buffer_len = 1,
.buffer_p = &battery_level_value,
};
ble_gatt_chr_def_t batt_level_chr = {
.properties = BLE_GATT_SRV_CHAR_PROP_READ,
.permissions = BLE_GATT_SRV_PERM_NONE,
.uuid = BLE_UUID_INIT_16(0x2A19),
.val_buffer_p = &battery_level_val_buff,
};
ble_gatt_srv_def_t battery_level_srvc = {
.type = BLE_GATT_SRV_PRIMARY_SRV_TYPE,
.uuid = BLE_UUID_INIT_16(0x180F),
.chrs = {
.chrs_p = &batt_level_chr,
.chr_count = 1,
},
};
And here are the macros that are changed under SerialPort_config.h:
/* Default number of link */
#define MIN_NUM_LINK_CONF 10
/* Number of services */
#define NUM_APP_GATT_SERVICES_CONF (10) /* attributes for serial port service */
/* Number of characteristics attributes requests */
#define NUM_APP_GATT_CHAR_ATTRIBUTES_CONF (10) /* attributes for serial port service characteristics */
You can try to copy paste this and check if there are two new services added.
Let me know if it helps.
Thanks.