Commit 956c9c91 authored by Rahix's avatar Rahix

Merge 'BLE cleanups and security updates'

See merge request card10/firmware!244
parents 53297345 31ef150a
......@@ -256,228 +256,272 @@ static uint16_t initLightSensorLen = sizeof(initLightSensorValue);
*/
static const attsAttr_t card10SvcAttrList[] = {
{ .pUuid = attPrimSvcUuid,
.pValue = (uint8_t *)UUID_svc,
.pLen = (uint16_t *)&UUID_len,
.maxLen = sizeof(UUID_svc),
.permissions = ATTS_PERMIT_READ },
{
.pUuid = attPrimSvcUuid,
.pValue = (uint8_t *)UUID_svc,
.pLen = (uint16_t *)&UUID_len,
.maxLen = sizeof(UUID_svc),
.permissions = ATTS_PERMIT_READ,
},
// TIME
{ .pUuid = attChUuid,
.pValue = (uint8_t *)UUID_char_time,
.pLen = (uint16_t *)&UUID_char_len,
.maxLen = sizeof(UUID_char_time),
.permissions = ATTS_PERMIT_READ },
{ .pUuid = UUID_attChar_time,
.pValue = timeValue,
.pLen = &timeLen,
.maxLen = sizeof(uint64_t),
.settings = (ATTS_SET_WRITE_CBACK | ATTS_SET_READ_CBACK),
.permissions =
(ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC |
ATTS_PERMIT_WRITE_AUTH | ATTS_PERMIT_READ |
ATTS_PERMIT_READ_ENC | ATTS_PERMIT_READ_AUTH) },
{
.pUuid = attChUuid,
.pValue = (uint8_t *)UUID_char_time,
.pLen = (uint16_t *)&UUID_char_len,
.maxLen = sizeof(UUID_char_time),
.permissions = ATTS_PERMIT_READ,
},
{
.pUuid = UUID_attChar_time,
.pValue = timeValue,
.pLen = &timeLen,
.maxLen = sizeof(uint64_t),
.settings = ATTS_SET_WRITE_CBACK | ATTS_SET_READ_CBACK,
.permissions = ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC |
ATTS_PERMIT_WRITE_AUTH | ATTS_PERMIT_READ |
ATTS_PERMIT_READ_ENC | ATTS_PERMIT_READ_AUTH,
},
// VIBRA
{ .pUuid = attChUuid,
.pValue = (uint8_t *)UUID_char_vibra,
.pLen = (uint16_t *)&UUID_char_len,
.maxLen = sizeof(UUID_char_vibra),
.permissions = ATTS_PERMIT_READ },
{ .pUuid = UUID_attChar_vibra,
.pValue = NULL,
.maxLen = sizeof(uint16_t),
.settings = ATTS_SET_WRITE_CBACK,
.permissions =
(ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC |
ATTS_PERMIT_WRITE_AUTH) },
{
.pUuid = attChUuid,
.pValue = (uint8_t *)UUID_char_vibra,
.pLen = (uint16_t *)&UUID_char_len,
.maxLen = sizeof(UUID_char_vibra),
.permissions = ATTS_PERMIT_READ,
},
{
.pUuid = UUID_attChar_vibra,
.pValue = NULL,
.maxLen = sizeof(uint16_t),
.settings = ATTS_SET_WRITE_CBACK,
.permissions = ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC |
ATTS_PERMIT_WRITE_AUTH,
},
// ROCKETS
{ .pUuid = attChUuid,
.pValue = (uint8_t *)UUID_char_rockets,
.pLen = (uint16_t *)&UUID_char_len,
.maxLen = sizeof(UUID_char_rockets),
.permissions = ATTS_PERMIT_READ },
{ .pUuid = UUID_attChar_rockets,
.pValue = NULL,
.maxLen = 3 * sizeof(uint8_t),
.settings = ATTS_SET_WRITE_CBACK,
.permissions =
(ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC |
ATTS_PERMIT_WRITE_AUTH) },
{
.pUuid = attChUuid,
.pValue = (uint8_t *)UUID_char_rockets,
.pLen = (uint16_t *)&UUID_char_len,
.maxLen = sizeof(UUID_char_rockets),
.permissions = ATTS_PERMIT_READ,
},
{
.pUuid = UUID_attChar_rockets,
.pValue = NULL,
.maxLen = 3 * sizeof(uint8_t),
.settings = ATTS_SET_WRITE_CBACK,
.permissions = ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC |
ATTS_PERMIT_WRITE_AUTH,
},
// BG LED Bottom left
{ .pUuid = attChUuid,
.pValue = (uint8_t *)UUID_char_led_bg_bottom_left,
.pLen = (uint16_t *)&UUID_char_len,
.maxLen = sizeof(UUID_char_led_bg_bottom_left),
.permissions = ATTS_PERMIT_READ },
{ .pUuid = UUID_attChar_led_bg_bottom_left,
.pValue = NULL,
.maxLen = 3 * sizeof(uint8_t),
.settings = ATTS_SET_WRITE_CBACK,
.permissions =
(ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC |
ATTS_PERMIT_WRITE_AUTH) },
{
.pUuid = attChUuid,
.pValue = (uint8_t *)UUID_char_led_bg_bottom_left,
.pLen = (uint16_t *)&UUID_char_len,
.maxLen = sizeof(UUID_char_led_bg_bottom_left),
.permissions = ATTS_PERMIT_READ,
},
{
.pUuid = UUID_attChar_led_bg_bottom_left,
.pValue = NULL,
.maxLen = 3 * sizeof(uint8_t),
.settings = ATTS_SET_WRITE_CBACK,
.permissions = ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC |
ATTS_PERMIT_WRITE_AUTH,
},
// BG LED Bottom right
{ .pUuid = attChUuid,
.pValue = (uint8_t *)UUID_char_led_bg_bottom_right,
.pLen = (uint16_t *)&UUID_char_len,
.maxLen = sizeof(UUID_char_led_bg_bottom_right),
.permissions = ATTS_PERMIT_READ },
{ .pUuid = UUID_attChar_led_bg_bottom_right,
.pValue = NULL,
.maxLen = 3 * sizeof(uint8_t),
.settings = ATTS_SET_WRITE_CBACK,
.permissions =
(ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC |
ATTS_PERMIT_WRITE_AUTH) },
{
.pUuid = attChUuid,
.pValue = (uint8_t *)UUID_char_led_bg_bottom_right,
.pLen = (uint16_t *)&UUID_char_len,
.maxLen = sizeof(UUID_char_led_bg_bottom_right),
.permissions = ATTS_PERMIT_READ,
},
{
.pUuid = UUID_attChar_led_bg_bottom_right,
.pValue = NULL,
.maxLen = 3 * sizeof(uint8_t),
.settings = ATTS_SET_WRITE_CBACK,
.permissions = ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC |
ATTS_PERMIT_WRITE_AUTH,
},
// BG LED top right
{ .pUuid = attChUuid,
.pValue = (uint8_t *)UUID_char_led_bg_top_right,
.pLen = (uint16_t *)&UUID_char_len,
.maxLen = sizeof(UUID_char_led_bg_top_right),
.settings = 0,
.permissions = ATTS_PERMIT_READ },
{ .pUuid = UUID_attChar_led_bg_top_right,
.pValue = NULL,
.maxLen = 3 * sizeof(uint8_t),
.settings = ATTS_SET_WRITE_CBACK,
.permissions =
(ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC |
ATTS_PERMIT_WRITE_AUTH) },
{
.pUuid = attChUuid,
.pValue = (uint8_t *)UUID_char_led_bg_top_right,
.pLen = (uint16_t *)&UUID_char_len,
.maxLen = sizeof(UUID_char_led_bg_top_right),
.settings = 0,
.permissions = ATTS_PERMIT_READ,
},
{
.pUuid = UUID_attChar_led_bg_top_right,
.pValue = NULL,
.maxLen = 3 * sizeof(uint8_t),
.settings = ATTS_SET_WRITE_CBACK,
.permissions = ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC |
ATTS_PERMIT_WRITE_AUTH,
},
// BG LED top left
{ .pUuid = attChUuid,
.pValue = (uint8_t *)UUID_char_led_bg_top_left,
.pLen = (uint16_t *)&UUID_char_len,
.maxLen = sizeof(UUID_char_led_bg_top_left),
.permissions = ATTS_PERMIT_READ },
{ .pUuid = UUID_attChar_led_bg_top_left,
.pValue = NULL,
.maxLen = 3 * sizeof(uint8_t),
.settings = ATTS_SET_WRITE_CBACK,
.permissions =
(ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC |
ATTS_PERMIT_WRITE_AUTH) },
{
.pUuid = attChUuid,
.pValue = (uint8_t *)UUID_char_led_bg_top_left,
.pLen = (uint16_t *)&UUID_char_len,
.maxLen = sizeof(UUID_char_led_bg_top_left),
.permissions = ATTS_PERMIT_READ,
},
{
.pUuid = UUID_attChar_led_bg_top_left,
.pValue = NULL,
.maxLen = 3 * sizeof(uint8_t),
.settings = ATTS_SET_WRITE_CBACK,
.permissions = ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC |
ATTS_PERMIT_WRITE_AUTH,
},
// Dim bottom module
{ .pUuid = attChUuid,
.pValue = (uint8_t *)UUID_char_leds_bottom_dim,
.pLen = (uint16_t *)&UUID_char_len,
.maxLen = sizeof(UUID_char_leds_bottom_dim),
.permissions = ATTS_PERMIT_READ },
{ .pUuid = UUID_attChar_leds_bottom_dim,
.pValue = NULL,
.pLen = 0,
.maxLen = sizeof(uint8_t),
.settings = ATTS_SET_WRITE_CBACK,
.permissions =
(ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC |
ATTS_PERMIT_WRITE_AUTH) },
{
.pUuid = attChUuid,
.pValue = (uint8_t *)UUID_char_leds_bottom_dim,
.pLen = (uint16_t *)&UUID_char_len,
.maxLen = sizeof(UUID_char_leds_bottom_dim),
.permissions = ATTS_PERMIT_READ,
},
{
.pUuid = UUID_attChar_leds_bottom_dim,
.pValue = NULL,
.pLen = 0,
.maxLen = sizeof(uint8_t),
.settings = ATTS_SET_WRITE_CBACK,
.permissions = ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC |
ATTS_PERMIT_WRITE_AUTH,
},
// Dim top module
{ .pUuid = attChUuid,
.pValue = (uint8_t *)UUID_char_leds_top_dim,
.pLen = (uint16_t *)&UUID_char_len,
.maxLen = sizeof(UUID_char_leds_top_dim),
.permissions = ATTS_PERMIT_READ },
{ .pUuid = UUID_attChar_leds_top_dim,
.pValue = NULL,
.maxLen = sizeof(uint8_t),
.settings = ATTS_SET_WRITE_CBACK,
.permissions =
(ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC |
ATTS_PERMIT_WRITE_AUTH) },
{
.pUuid = attChUuid,
.pValue = (uint8_t *)UUID_char_leds_top_dim,
.pLen = (uint16_t *)&UUID_char_len,
.maxLen = sizeof(UUID_char_leds_top_dim),
.permissions = ATTS_PERMIT_READ,
},
{
.pUuid = UUID_attChar_leds_top_dim,
.pValue = NULL,
.maxLen = sizeof(uint8_t),
.settings = ATTS_SET_WRITE_CBACK,
.permissions = ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC |
ATTS_PERMIT_WRITE_AUTH,
},
// led powersafe
{ .pUuid = attChUuid,
.pValue = (uint8_t *)UUID_char_led_powersafe,
.pLen = (uint16_t *)&UUID_char_len,
.maxLen = sizeof(UUID_char_led_powersafe),
.permissions = ATTS_PERMIT_READ },
{ .pUuid = UUID_attChar_led_powersafe,
.pValue = NULL,
.maxLen = sizeof(uint8_t),
.settings = ATTS_SET_WRITE_CBACK,
.permissions =
(ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC |
ATTS_PERMIT_WRITE_AUTH) },
{
.pUuid = attChUuid,
.pValue = (uint8_t *)UUID_char_led_powersafe,
.pLen = (uint16_t *)&UUID_char_len,
.maxLen = sizeof(UUID_char_led_powersafe),
.permissions = ATTS_PERMIT_READ,
},
{
.pUuid = UUID_attChar_led_powersafe,
.pValue = NULL,
.maxLen = sizeof(uint8_t),
.settings = ATTS_SET_WRITE_CBACK,
.permissions = ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC |
ATTS_PERMIT_WRITE_AUTH,
},
// flashlight
{ .pUuid = attChUuid,
.pValue = (uint8_t *)UUID_char_flashlight,
.pLen = (uint16_t *)&UUID_char_len,
.maxLen = sizeof(UUID_char_flashlight),
.permissions = ATTS_PERMIT_READ },
{ .pUuid = UUID_attChar_flashlight,
.pValue = NULL,
.maxLen = sizeof(uint8_t),
.settings = ATTS_SET_WRITE_CBACK,
.permissions =
(ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC |
ATTS_PERMIT_WRITE_AUTH) },
{
.pUuid = attChUuid,
.pValue = (uint8_t *)UUID_char_flashlight,
.pLen = (uint16_t *)&UUID_char_len,
.maxLen = sizeof(UUID_char_flashlight),
.permissions = ATTS_PERMIT_READ,
},
{
.pUuid = UUID_attChar_flashlight,
.pValue = NULL,
.maxLen = sizeof(uint8_t),
.settings = ATTS_SET_WRITE_CBACK,
.permissions = ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC |
ATTS_PERMIT_WRITE_AUTH,
},
// personal state
{ .pUuid = attChUuid,
.pValue = (uint8_t *)UUID_char_personal_state,
.pLen = (uint16_t *)&UUID_char_len,
.maxLen = sizeof(UUID_char_personal_state),
.permissions = ATTS_PERMIT_READ },
{ .pUuid = UUID_attChar_personal_state,
.pValue = &personalStateValue,
.pLen = &personalStateLen,
.maxLen = sizeof(uint16_t),
.settings = (ATTS_SET_WRITE_CBACK | ATTS_SET_READ_CBACK),
.permissions =
(ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC |
ATTS_PERMIT_WRITE_AUTH | ATTS_PERMIT_READ |
ATTS_PERMIT_READ_ENC | ATTS_PERMIT_READ_AUTH) },
{
.pUuid = attChUuid,
.pValue = (uint8_t *)UUID_char_personal_state,
.pLen = (uint16_t *)&UUID_char_len,
.maxLen = sizeof(UUID_char_personal_state),
.permissions = ATTS_PERMIT_READ,
},
{
.pUuid = UUID_attChar_personal_state,
.pValue = &personalStateValue,
.pLen = &personalStateLen,
.maxLen = sizeof(uint16_t),
.settings = ATTS_SET_WRITE_CBACK | ATTS_SET_READ_CBACK,
.permissions = ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC |
ATTS_PERMIT_WRITE_AUTH | ATTS_PERMIT_READ |
ATTS_PERMIT_READ_ENC | ATTS_PERMIT_READ_AUTH,
},
// ABOVE LEDS
{ .pUuid = attChUuid,
.pValue = (uint8_t *)UUID_char_leds_above,
.pLen = (uint16_t *)&UUID_char_len,
.maxLen = sizeof(UUID_char_leds_above),
.permissions = ATTS_PERMIT_READ },
{ .pUuid = UUID_attChar_leds_above,
.pValue = NULL,
.maxLen = 11 * 3 * sizeof(uint8_t),
.settings = ATTS_SET_WRITE_CBACK,
.permissions =
(ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC |
ATTS_PERMIT_WRITE_AUTH) },
{
.pUuid = attChUuid,
.pValue = (uint8_t *)UUID_char_leds_above,
.pLen = (uint16_t *)&UUID_char_len,
.maxLen = sizeof(UUID_char_leds_above),
.permissions = ATTS_PERMIT_READ,
},
{
.pUuid = UUID_attChar_leds_above,
.pValue = NULL,
.maxLen = 11 * 3 * sizeof(uint8_t),
.settings = ATTS_SET_WRITE_CBACK,
.permissions = ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC |
ATTS_PERMIT_WRITE_AUTH,
},
// Light sensor
{ .pUuid = attChUuid,
.pValue = (uint8_t *)UUID_char_light_sensor,
.pLen = (uint16_t *)&UUID_char_len,
.maxLen = sizeof(UUID_char_light_sensor),
.permissions = ATTS_PERMIT_READ },
{ .pUuid = UUID_attChar_light_sensor,
.pValue = initLightSensorValue,
.pLen = &initLightSensorLen,
.maxLen = sizeof(uint8_t),
.settings = ATTS_SET_READ_CBACK,
.permissions =
(ATTS_PERMIT_READ | ATTS_PERMIT_READ_ENC |
ATTS_PERMIT_READ_AUTH) },
{
.pUuid = attChUuid,
.pValue = (uint8_t *)UUID_char_light_sensor,
.pLen = (uint16_t *)&UUID_char_len,
.maxLen = sizeof(UUID_char_light_sensor),
.permissions = ATTS_PERMIT_READ,
},
{
.pUuid = UUID_attChar_light_sensor,
.pValue = initLightSensorValue,
.pLen = &initLightSensorLen,
.maxLen = sizeof(uint8_t),
.settings = ATTS_SET_READ_CBACK,
.permissions = ATTS_PERMIT_READ | ATTS_PERMIT_READ_ENC |
ATTS_PERMIT_READ_AUTH,
},
};
// validating, that the service really get all charateristics
......
......@@ -143,7 +143,8 @@ static const attsAttr_t fileTransCfgList[] = {
.pLen = NULL,
.maxLen = 128,
.settings = ATTS_SET_WRITE_CBACK | ATTS_SET_VARIABLE_LEN,
.permissions = ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_AUTH,
.permissions = ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC |
ATTS_PERMIT_WRITE_AUTH,
},
/* File transfer Central RX characteristic */
{
......@@ -161,7 +162,8 @@ static const attsAttr_t fileTransCfgList[] = {
.pLen = &attRxChConfigValue_len,
.maxLen = sizeof(attRxChConfigValue),
.settings = ATTS_SET_VARIABLE_LEN,
.permissions = ATTS_PERMIT_READ | ATTS_PERMIT_READ_AUTH,
.permissions = ATTS_PERMIT_READ | ATTS_PERMIT_READ_ENC |
ATTS_PERMIT_READ_AUTH,
},
/* File transfer Central RX notification channel */
{
......@@ -170,8 +172,9 @@ static const attsAttr_t fileTransCfgList[] = {
.pLen = &attRxChConfigValue_len,
.maxLen = sizeof(attRxChConfigValue),
.settings = ATTS_SET_CCC,
.permissions = ATTS_PERMIT_READ | ATTS_PERMIT_READ_AUTH |
ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_AUTH,
.permissions = ATTS_PERMIT_READ | ATTS_PERMIT_READ_ENC |
ATTS_PERMIT_READ_AUTH | ATTS_PERMIT_WRITE |
ATTS_PERMIT_WRITE_ENC | ATTS_PERMIT_WRITE_AUTH,
},
};
......
......@@ -31,66 +31,84 @@ enum { UART_SVC_HDL = UART_START_HDL, /*!< \brief UART service declaration */
/* clang-format off */
static const uint8_t UARTSvc[] = {0x9E,0xCA,0xDC,0x24,0x0E,0xE5,0xA9,0xE0,0x93,0xF3,0xA3,0xB5,0x01,0x00,0x40,0x6E};
static const uint16_t UARTSvc_len = sizeof(UARTSvc);
static const uint8_t uartRxCh[] = {ATT_PROP_WRITE, UINT16_TO_BYTES(UART_RX_HDL), 0x9E,0xCA,0xDC,0x24,0x0E,0xE5,0xA9,0xE0,0x93,0xF3,0xA3,0xB5,0x02,0x00,0x40,0x6E};
const uint8_t attUartRxChUuid[] = {0x9E,0xCA,0xDC,0x24,0x0E,0xE5, 0xA9,0xE0,0x93,0xF3,0xA3,0xB5,0x02,0x00,0x40,0x6E};
static const uint16_t uartRxCh_len = sizeof(uartRxCh);
static const uint8_t attUartRxChUuid[] = {0x9E,0xCA,0xDC,0x24,0x0E,0xE5, 0xA9,0xE0,0x93,0xF3,0xA3,0xB5,0x02,0x00,0x40,0x6E};
static const uint8_t uartTxCh[] = {ATT_PROP_READ | ATT_PROP_NOTIFY, UINT16_TO_BYTES(UART_TX_HDL), 0x9E,0xCA,0xDC,0x24,0x0E,0xE5,0xA9,0xE0,0x93,0xF3,0xA3,0xB5,0x03,0x00,0x40,0x6E};
const uint8_t attUartTxChUuid[] = {0x9E,0xCA,0xDC,0x24,0x0E,0xE5, 0xA9,0xE0,0x93,0xF3,0xA3,0xB5,0x03,0x00,0x40,0x6E};
/* clang-format on */
static const uint16_t uartTxCh_len = sizeof(uartTxCh);
static const uint8_t attUartTxChUuid[] = {0x9E,0xCA,0xDC,0x24,0x0E,0xE5, 0xA9,0xE0,0x93,0xF3,0xA3,0xB5,0x03,0x00,0x40,0x6E};
static void *SvcUARTAddGroupDyn(void)
{
void *pSHdl;
uint8_t initCcc[] = { UINT16_TO_BYTES(0x0000) };
/* Create the service */
pSHdl = AttsDynCreateGroup(UART_START_HDL, UART_END_HDL);
if (pSHdl != NULL) {
/* clang-format off */
/* Primary service */
AttsDynAddAttrConst( pSHdl, attPrimSvcUuid, UARTSvc, sizeof(UARTSvc),
0, ATTS_PERMIT_READ);
/* UART rx characteristic */
AttsDynAddAttrConst( pSHdl, attChUuid, uartRxCh, sizeof(uartRxCh),
0, ATTS_PERMIT_READ);
// XXX: attUartRxChUuid is 16 bytes but nothing says so....
/* UART rx value */
// XXX: not sure if max value of 128 is fine...
AttsDynAddAttr( pSHdl, attUartRxChUuid, NULL, 0, 128,
ATTS_SET_WRITE_CBACK | ATTS_SET_VARIABLE_LEN, ATTS_PERMIT_WRITE);
/* UART tx characteristic */
AttsDynAddAttrConst( pSHdl, attChUuid, uartTxCh, sizeof(uartTxCh),
0, ATTS_PERMIT_READ);
/* UART tx value */
/* TODO: do we need ATTS_SET_READ_CBACK ? */
AttsDynAddAttr( pSHdl, attUartTxChUuid, NULL, 0, sizeof(uint8_t),
ATTS_SET_READ_CBACK, ATTS_PERMIT_READ);
/* UART tx CCC descriptor */
AttsDynAddAttr( pSHdl, attCliChCfgUuid, initCcc, sizeof(uint16_t), sizeof(uint16_t),
ATTS_SET_CCC, ATTS_PERMIT_READ | ATTS_PERMIT_WRITE);
/* clang-format on */
}
static uint8_t ble_uart_tx_buf[128];
static uint16_t ble_uart_buf_tx_fill = 0;
/* clang-format on */
return pSHdl;
}
/* Attribute list for uriCfg group */
static const attsAttr_t uartAttrCfgList[] = {
/* Primary service */
{
.pUuid = attPrimSvcUuid,
.pValue = (uint8_t *)UARTSvc,
.pLen = (uint16_t *)&UARTSvc_len,
.maxLen = sizeof(UARTSvc),
.settings = 0,
.permissions = ATTS_PERMIT_READ,
},
/* UART rx characteristic */
{
.pUuid = attChUuid,
.pValue = (uint8_t *)uartRxCh,
.pLen = (uint16_t *)&uartRxCh_len,
.maxLen = sizeof(uartRxCh),
.settings = 0,
.permissions = ATTS_PERMIT_READ,
},
/* UART rx value */
{
.pUuid = attUartRxChUuid,
.pValue = NULL,
.pLen = NULL,
.maxLen = 128,
.settings = ATTS_SET_WRITE_CBACK | ATTS_SET_VARIABLE_LEN,
.permissions = ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC |
ATTS_PERMIT_WRITE_AUTH,
},
/* UART tx characteristic */
{
.pUuid = attChUuid,
.pValue = (uint8_t *)uartTxCh,
.pLen = (uint16_t *)&uartTxCh_len,
.maxLen = sizeof(uartTxCh),
.settings = 0,
.permissions = ATTS_PERMIT_READ,
},
/* UART tx value */
{
.pUuid = attUartTxChUuid,
.pValue = ble_uart_tx_buf,
.pLen = &ble_uart_buf_tx_fill,
.maxLen = sizeof(ble_uart_tx_buf),
.settings = 0,
.permissions = ATTS_PERMIT_READ | ATTS_PERMIT_READ_ENC |
ATTS_PERMIT_READ_AUTH,
},
/* UART tx CCC descriptor */
{
.pUuid = attCliChCfgUuid,
.pValue = NULL,
.pLen = NULL,
.maxLen = 0,
.settings = ATTS_SET_CCC,
.permissions = ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC |
ATTS_PERMIT_WRITE_AUTH | ATTS_PERMIT_READ |
ATTS_PERMIT_READ_ENC | ATTS_PERMIT_READ_AUTH,
},
};
dmConnId_t active_connection = 0;
static uint8_t UARTReadCback(
dmConnId_t connId,