Bluetooth: convert to using newly introduced integer sized types

Convert code to use u{8,16,32,64}_t and s{8,16,32,64}_t instead of C99
integer types.

Jira: ZEP-2051

Change-Id: I8f57a17f78e674aca5400f005db8975c9f9e150e
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
Kumar Gala 2017-04-20 12:00:29 -05:00
commit d0eb235510
100 changed files with 3697 additions and 3697 deletions

View file

@ -42,26 +42,26 @@ static struct {
struct net_buf *buf; struct net_buf *buf;
struct k_fifo fifo; struct k_fifo fifo;
uint16_t remaining; u16_t remaining;
uint16_t discard; u16_t discard;
bool have_hdr; bool have_hdr;
bool discardable; bool discardable;
uint8_t hdr_len; u8_t hdr_len;
uint8_t type; u8_t type;
union { union {
struct bt_hci_evt_hdr evt; struct bt_hci_evt_hdr evt;
struct bt_hci_acl_hdr acl; struct bt_hci_acl_hdr acl;
uint8_t hdr[4]; u8_t hdr[4];
}; };
} rx = { } rx = {
.fifo = K_FIFO_INITIALIZER(rx.fifo), .fifo = K_FIFO_INITIALIZER(rx.fifo),
}; };
static struct { static struct {
uint8_t type; u8_t type;
struct net_buf *buf; struct net_buf *buf;
struct k_fifo fifo; struct k_fifo fifo;
} tx = { } tx = {
@ -99,7 +99,7 @@ static inline void get_acl_hdr(void)
struct bt_hci_acl_hdr *hdr = &rx.acl; struct bt_hci_acl_hdr *hdr = &rx.acl;
int to_read = sizeof(*hdr) - rx.remaining; int to_read = sizeof(*hdr) - rx.remaining;
rx.remaining -= uart_fifo_read(h4_dev, (uint8_t *)hdr + to_read, rx.remaining -= uart_fifo_read(h4_dev, (u8_t *)hdr + to_read,
rx.remaining); rx.remaining);
if (!rx.remaining) { if (!rx.remaining) {
rx.remaining = sys_le16_to_cpu(hdr->len); rx.remaining = sys_le16_to_cpu(hdr->len);
@ -113,7 +113,7 @@ static inline void get_evt_hdr(void)
struct bt_hci_evt_hdr *hdr = &rx.evt; struct bt_hci_evt_hdr *hdr = &rx.evt;
int to_read = rx.hdr_len - rx.remaining; int to_read = rx.hdr_len - rx.remaining;
rx.remaining -= uart_fifo_read(h4_dev, (uint8_t *)hdr + to_read, rx.remaining -= uart_fifo_read(h4_dev, (u8_t *)hdr + to_read,
rx.remaining); rx.remaining);
if (rx.hdr_len == sizeof(*hdr) && rx.remaining < sizeof(*hdr)) { if (rx.hdr_len == sizeof(*hdr) && rx.remaining < sizeof(*hdr)) {
switch (rx.evt.evt) { switch (rx.evt.evt) {
@ -223,7 +223,7 @@ static void rx_thread(void *p1, void *p2, void *p3)
static size_t h4_discard(struct device *uart, size_t len) static size_t h4_discard(struct device *uart, size_t len)
{ {
uint8_t buf[33]; u8_t buf[33];
return uart_fifo_read(uart, buf, min(len, sizeof(buf))); return uart_fifo_read(uart, buf, min(len, sizeof(buf)));
} }

View file

@ -42,7 +42,7 @@ static struct k_delayed_work retx_work;
#define HCI_3WIRE_LINK_PKT 0x0f #define HCI_3WIRE_LINK_PKT 0x0f
#define HCI_VENDOR_PKT 0xff #define HCI_VENDOR_PKT 0xff
static bool reliable_packet(uint8_t type) static bool reliable_packet(u8_t type)
{ {
switch (type) { switch (type) {
case HCI_COMMAND_PKT: case HCI_COMMAND_PKT:
@ -87,11 +87,11 @@ static struct h5 {
struct k_fifo rx_queue; struct k_fifo rx_queue;
struct k_fifo unack_queue; struct k_fifo unack_queue;
uint8_t tx_win; u8_t tx_win;
uint8_t tx_ack; u8_t tx_ack;
uint8_t tx_seq; u8_t tx_seq;
uint8_t rx_ack; u8_t rx_ack;
enum { enum {
UNINIT, UNINIT,
@ -107,13 +107,13 @@ static struct h5 {
} rx_state; } rx_state;
} h5; } h5;
static uint8_t unack_queue_len; static u8_t unack_queue_len;
static const uint8_t sync_req[] = { 0x01, 0x7e }; static const u8_t sync_req[] = { 0x01, 0x7e };
static const uint8_t sync_rsp[] = { 0x02, 0x7d }; static const u8_t sync_rsp[] = { 0x02, 0x7d };
/* Third byte may change */ /* Third byte may change */
static uint8_t conf_req[3] = { 0x03, 0xfc }; static u8_t conf_req[3] = { 0x03, 0xfc };
static const uint8_t conf_rsp[] = { 0x04, 0x7b }; static const u8_t conf_rsp[] = { 0x04, 0x7b };
/* H5 signal buffers pool */ /* H5 signal buffers pool */
#define CONFIG_BLUETOOTH_MAX_SIG_LEN 3 #define CONFIG_BLUETOOTH_MAX_SIG_LEN 3
@ -135,7 +135,7 @@ static void h5_reset_rx(void)
h5.rx_state = START; h5.rx_state = START;
} }
static int h5_unslip_byte(uint8_t *byte) static int h5_unslip_byte(u8_t *byte)
{ {
int count; int count;
@ -164,8 +164,8 @@ static int h5_unslip_byte(uint8_t *byte)
static void process_unack(void) static void process_unack(void)
{ {
uint8_t next_seq = h5.tx_seq; u8_t next_seq = h5.tx_seq;
uint8_t number_removed = unack_queue_len; u8_t number_removed = unack_queue_len;
if (!unack_queue_len) { if (!unack_queue_len) {
return; return;
@ -211,7 +211,7 @@ static void process_unack(void)
} }
} }
static void h5_print_header(const uint8_t *hdr, const char *str) static void h5_print_header(const u8_t *hdr, const char *str)
{ {
if (H5_HDR_RELIABLE(hdr)) { if (H5_HDR_RELIABLE(hdr)) {
BT_DBG("%s REL: seq %u ack %u crc %u type %u len %u", BT_DBG("%s REL: seq %u ack %u crc %u type %u len %u",
@ -226,7 +226,7 @@ static void h5_print_header(const uint8_t *hdr, const char *str)
} }
#if defined(CONFIG_BLUETOOTH_DEBUG_HCI_DRIVER) #if defined(CONFIG_BLUETOOTH_DEBUG_HCI_DRIVER)
static void hexdump(const char *str, const uint8_t *packet, size_t length) static void hexdump(const char *str, const u8_t *packet, size_t length)
{ {
int n = 0; int n = 0;
@ -260,7 +260,7 @@ static void hexdump(const char *str, const uint8_t *packet, size_t length)
#define hexdump(str, packet, length) #define hexdump(str, packet, length)
#endif #endif
static uint8_t h5_slip_byte(uint8_t byte) static u8_t h5_slip_byte(u8_t byte)
{ {
switch (byte) { switch (byte) {
case SLIP_DELIMITER: case SLIP_DELIMITER:
@ -277,9 +277,9 @@ static uint8_t h5_slip_byte(uint8_t byte)
} }
} }
static void h5_send(const uint8_t *payload, uint8_t type, int len) static void h5_send(const u8_t *payload, u8_t type, int len)
{ {
uint8_t hdr[4]; u8_t hdr[4];
int i; int i;
hexdump("<= ", payload, len); hexdump("<= ", payload, len);
@ -338,7 +338,7 @@ static void retx_timeout(struct k_work *work)
/* Queue unack packets to the beginning of the queue */ /* Queue unack packets to the beginning of the queue */
while ((buf = net_buf_get(&h5.unack_queue, K_NO_WAIT))) { while ((buf = net_buf_get(&h5.unack_queue, K_NO_WAIT))) {
/* include also packet type */ /* include also packet type */
net_buf_push(buf, sizeof(uint8_t)); net_buf_push(buf, sizeof(u8_t));
net_buf_put(&h5.tx_queue, buf); net_buf_put(&h5.tx_queue, buf);
h5.tx_seq = (h5.tx_seq - 1) & 0x07; h5.tx_seq = (h5.tx_seq - 1) & 0x07;
unack_queue_len--; unack_queue_len--;
@ -364,7 +364,7 @@ static void ack_timeout(struct k_work *work)
stack_analyze("rx_stack", rx_stack, sizeof(rx_stack)); stack_analyze("rx_stack", rx_stack, sizeof(rx_stack));
} }
static void h5_process_complete_packet(uint8_t *hdr) static void h5_process_complete_packet(u8_t *hdr)
{ {
struct net_buf *buf; struct net_buf *buf;
@ -402,7 +402,7 @@ static void h5_process_complete_packet(uint8_t *hdr)
} }
} }
static inline struct net_buf *get_evt_buf(uint8_t evt) static inline struct net_buf *get_evt_buf(u8_t evt)
{ {
struct net_buf *buf; struct net_buf *buf;
@ -427,9 +427,9 @@ static inline struct net_buf *get_evt_buf(uint8_t evt)
static void bt_uart_isr(struct device *unused) static void bt_uart_isr(struct device *unused)
{ {
static int remaining; static int remaining;
uint8_t byte; u8_t byte;
int ret; int ret;
static uint8_t hdr[4]; static u8_t hdr[4];
ARG_UNUSED(unused); ARG_UNUSED(unused);
@ -570,14 +570,14 @@ static void bt_uart_isr(struct device *unused)
} }
} }
static uint8_t h5_get_type(struct net_buf *buf) static u8_t h5_get_type(struct net_buf *buf)
{ {
return net_buf_pull_u8(buf); return net_buf_pull_u8(buf);
} }
static int h5_queue(struct net_buf *buf) static int h5_queue(struct net_buf *buf)
{ {
uint8_t type; u8_t type;
BT_DBG("buf %p type %u len %u", buf, bt_buf_get_type(buf), buf->len); BT_DBG("buf %p type %u len %u", buf, bt_buf_get_type(buf), buf->len);
@ -609,7 +609,7 @@ static void tx_thread(void)
while (true) { while (true) {
struct net_buf *buf; struct net_buf *buf;
uint8_t type; u8_t type;
BT_DBG("link_state %u", h5.link_state); BT_DBG("link_state %u", h5.link_state);
@ -641,7 +641,7 @@ static void tx_thread(void)
} }
} }
static void h5_set_txwin(uint8_t *conf) static void h5_set_txwin(u8_t *conf)
{ {
conf[2] = h5.tx_win & 0x07; conf[2] = h5.tx_win & 0x07;
} }

View file

@ -57,8 +57,8 @@
*/ */
#define SPI_MAX_MSG_LEN 255 /* As defined by X-NUCLEO-IDB04A1 BSP */ #define SPI_MAX_MSG_LEN 255 /* As defined by X-NUCLEO-IDB04A1 BSP */
static uint8_t rxmsg[SPI_MAX_MSG_LEN]; static u8_t rxmsg[SPI_MAX_MSG_LEN];
static uint8_t txmsg[SPI_MAX_MSG_LEN]; static u8_t txmsg[SPI_MAX_MSG_LEN];
static struct device *spi_dev; static struct device *spi_dev;
#if defined(CONFIG_BLUETOOTH_SPI_BLUENRG) #if defined(CONFIG_BLUETOOTH_SPI_BLUENRG)
@ -82,10 +82,10 @@ static struct spi_config spi_conf = {
#if defined(CONFIG_BLUETOOTH_DEBUG_HCI_DRIVER) #if defined(CONFIG_BLUETOOTH_DEBUG_HCI_DRIVER)
#include <misc/printk.h> #include <misc/printk.h>
static inline void spi_dump_message(const uint8_t *pre, uint8_t *buf, static inline void spi_dump_message(const u8_t *pre, u8_t *buf,
uint8_t size) u8_t size)
{ {
uint8_t i, c; u8_t i, c;
printk("%s (%d): ", pre, size); printk("%s (%d): ", pre, size);
for (i = 0; i < size; i++) { for (i = 0; i < size; i++) {
@ -101,15 +101,15 @@ static inline void spi_dump_message(const uint8_t *pre, uint8_t *buf,
} }
#else #else
static inline static inline
void spi_dump_message(const uint8_t *pre, uint8_t *buf, uint8_t size) {} void spi_dump_message(const u8_t *pre, u8_t *buf, u8_t size) {}
#endif #endif
static inline uint16_t bt_spi_get_cmd(uint8_t *txmsg) static inline u16_t bt_spi_get_cmd(u8_t *txmsg)
{ {
return (txmsg[CMD_OCF] << 8) | txmsg[CMD_OGF]; return (txmsg[CMD_OCF] << 8) | txmsg[CMD_OGF];
} }
static inline uint16_t bt_spi_get_evt(uint8_t *rxmsg) static inline u16_t bt_spi_get_evt(u8_t *rxmsg)
{ {
return (rxmsg[EVT_VENDOR_CODE_MSB] << 8) | rxmsg[EVT_VENDOR_CODE_LSB]; return (rxmsg[EVT_VENDOR_CODE_MSB] << 8) | rxmsg[EVT_VENDOR_CODE_LSB];
} }
@ -120,7 +120,7 @@ static void bt_spi_isr(struct device *unused1, struct gpio_callback *unused2,
k_sem_give(&sem_request); k_sem_give(&sem_request);
} }
static void bt_spi_handle_vendor_evt(uint8_t *rxmsg) static void bt_spi_handle_vendor_evt(u8_t *rxmsg)
{ {
switch (bt_spi_get_evt(rxmsg)) { switch (bt_spi_get_evt(rxmsg)) {
case EVT_BLUE_INITIALIZED: case EVT_BLUE_INITIALIZED:
@ -133,10 +133,10 @@ static void bt_spi_handle_vendor_evt(uint8_t *rxmsg)
static void bt_spi_rx_thread(void) static void bt_spi_rx_thread(void)
{ {
struct net_buf *buf; struct net_buf *buf;
uint8_t header_master[5] = { SPI_READ, 0x00, 0x00, 0x00, 0x00 }; u8_t header_master[5] = { SPI_READ, 0x00, 0x00, 0x00, 0x00 };
uint8_t header_slave[5]; u8_t header_slave[5];
struct bt_hci_acl_hdr acl_hdr; struct bt_hci_acl_hdr acl_hdr;
uint8_t size; u8_t size;
memset(&txmsg, 0xFF, SPI_MAX_MSG_LEN); memset(&txmsg, 0xFF, SPI_MAX_MSG_LEN);
@ -213,8 +213,8 @@ static void bt_spi_rx_thread(void)
static int bt_spi_send(struct net_buf *buf) static int bt_spi_send(struct net_buf *buf)
{ {
uint8_t header[5] = { SPI_WRITE, 0x00, 0x00, 0x00, 0x00 }; u8_t header[5] = { SPI_WRITE, 0x00, 0x00, 0x00, 0x00 };
uint32_t pending; u32_t pending;
/* Buffer needs an additional byte for type */ /* Buffer needs an additional byte for type */
if (buf->len >= SPI_MAX_MSG_LEN) { if (buf->len >= SPI_MAX_MSG_LEN) {

View file

@ -79,7 +79,7 @@ void bt_conn_unref(struct bt_conn *conn)
BT_DBG("handle %u ref %u", conn->handle, atomic_get(&conn->ref)); BT_DBG("handle %u ref %u", conn->handle, atomic_get(&conn->ref));
} }
struct bt_conn *bt_conn_lookup_handle(uint16_t handle) struct bt_conn *bt_conn_lookup_handle(u16_t handle)
{ {
int i; int i;
@ -133,8 +133,8 @@ int bt_conn_get_info(const struct bt_conn *conn, struct bt_conn_info *info)
return 0; return 0;
} }
static inline bool bt_le_conn_params_valid(uint16_t min, uint16_t max, static inline bool bt_le_conn_params_valid(u16_t min, u16_t max,
uint16_t latency, uint16_t timeout) u16_t latency, u16_t timeout)
{ {
if (min > max || min < 6 || max > 3200) { if (min > max || min < 6 || max > 3200) {
return false; return false;
@ -184,7 +184,7 @@ int bt_conn_le_param_update(struct bt_conn *conn,
return 0; return 0;
} }
int bt_conn_disconnect(struct bt_conn *conn, uint8_t reason) int bt_conn_disconnect(struct bt_conn *conn, u8_t reason)
{ {
struct nble_gap_disconnect_req req; struct nble_gap_disconnect_req req;
@ -323,7 +323,7 @@ int bt_conn_security(struct bt_conn *conn, bt_security_t sec)
return err; return err;
} }
uint8_t bt_conn_enc_key_size(struct bt_conn *conn) u8_t bt_conn_enc_key_size(struct bt_conn *conn)
{ {
return 0; return 0;
} }

View file

@ -4,4 +4,4 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
struct bt_conn *bt_conn_lookup_handle(uint16_t handle); struct bt_conn *bt_conn_lookup_handle(u16_t handle);

View file

@ -5,8 +5,8 @@
*/ */
struct bt_conn { struct bt_conn {
uint16_t handle; u16_t handle;
uint8_t role; u8_t role;
atomic_t ref; atomic_t ref;
bt_addr_le_t dst; bt_addr_le_t dst;
@ -14,9 +14,9 @@ struct bt_conn {
bt_security_t sec_level; bt_security_t sec_level;
bt_security_t required_sec_level; bt_security_t required_sec_level;
uint16_t interval; u16_t interval;
uint16_t latency; u16_t latency;
uint16_t timeout; u16_t timeout;
enum { enum {
BT_CONN_DISCONNECTED, BT_CONN_DISCONNECTED,

View file

@ -33,7 +33,7 @@
#define NBLE_VERSION_PATCH(v) (((v) >> 0) & 0xFF) #define NBLE_VERSION_PATCH(v) (((v) >> 0) & 0xFF)
/* Set the firmware compatible with Nordic BLE RPC */ /* Set the firmware compatible with Nordic BLE RPC */
static const uint32_t compatible_firmware = NBLE_VERSION(4, 0, 31); static const u32_t compatible_firmware = NBLE_VERSION(4, 0, 31);
static bt_ready_cb_t bt_ready_cb; static bt_ready_cb_t bt_ready_cb;
static bt_le_scan_cb_t *scan_dev_found_cb; static bt_le_scan_cb_t *scan_dev_found_cb;
@ -121,7 +121,7 @@ static int set_ad(struct nble_eir_data *eir, const struct bt_data *ad,
int i; int i;
for (i = 0; i < ad_len; i++) { for (i = 0; i < ad_len; i++) {
uint8_t *p; u8_t *p;
/* Check if ad fit in the remaining buffer */ /* Check if ad fit in the remaining buffer */
if (eir->len + ad[i].data_len + 2 > 31) { if (eir->len + ad[i].data_len + 2 > 31) {
@ -277,7 +277,7 @@ int bt_le_scan_start(const struct bt_le_scan_param *param, bt_le_scan_cb_t cb)
} }
void on_nble_gap_adv_report_evt(const struct nble_gap_adv_report_evt *evt, void on_nble_gap_adv_report_evt(const struct nble_gap_adv_report_evt *evt,
const uint8_t *buf, uint8_t len) const u8_t *buf, u8_t len)
{ {
BT_DBG(""); BT_DBG("");
@ -312,7 +312,7 @@ void on_nble_gap_scan_start_stop_rsp(const struct nble_common_rsp *rsp)
BT_DBG(""); BT_DBG("");
} }
void nble_log(const struct nble_log_s *param, char *format, uint8_t len) void nble_log(const struct nble_log_s *param, char *format, u8_t len)
{ {
#if defined(CONFIG_BLUETOOTH_DEBUG) #if defined(CONFIG_BLUETOOTH_DEBUG)
/* Build meaningful output */ /* Build meaningful output */
@ -348,7 +348,7 @@ void on_nble_common_rsp(const struct nble_common_rsp *rsp)
BT_DBG("status %d", rsp->status); BT_DBG("status %d", rsp->status);
} }
void rpc_init_cb(uint32_t version, bool compatible) void rpc_init_cb(u32_t version, bool compatible)
{ {
BT_DBG(""); BT_DBG("");

View file

@ -45,13 +45,13 @@ enum NBLE_GAP_SM_EVT {
}; };
struct nble_log_s { struct nble_log_s {
uint8_t param0; u8_t param0;
uint8_t param1; u8_t param1;
uint8_t param2; u8_t param2;
uint8_t param3; u8_t param3;
}; };
void nble_log(const struct nble_log_s *par, char *data, uint8_t len); void nble_log(const struct nble_log_s *par, char *data, u8_t len);
struct nble_common_rsp { struct nble_common_rsp {
int status; int status;
@ -70,13 +70,13 @@ void on_nble_common_rsp(const struct nble_common_rsp *rsp);
void nble_panic_req(void); void nble_panic_req(void);
struct nble_version { struct nble_version {
uint8_t version; u8_t version;
uint8_t major; u8_t major;
uint8_t minor; u8_t minor;
uint8_t patch; u8_t patch;
char version_string[20]; char version_string[20];
uint8_t build_hash[4]; u8_t build_hash[4];
uint8_t hash[4]; u8_t hash[4];
}; };
typedef void (*ble_get_version_cb_t)(const struct nble_version *ver); typedef void (*ble_get_version_cb_t)(const struct nble_version *ver);
@ -103,44 +103,44 @@ enum NBLE_GAP_SVC_ATTR_TYPE {
struct nble_gap_device_name { struct nble_gap_device_name {
/* Security mode for writing device name, see BLE_GAP_SEC_MODES */ /* Security mode for writing device name, see BLE_GAP_SEC_MODES */
uint8_t sec_mode; u8_t sec_mode;
/* 0: no authorization, 1: authorization required */ /* 0: no authorization, 1: authorization required */
uint8_t authorization; u8_t authorization;
/* Device name length (0-248) */ /* Device name length (0-248) */
uint8_t len; u8_t len;
uint8_t name_array[20]; u8_t name_array[20];
}; };
struct nble_conn_param { struct nble_conn_param {
/* minimal connection interval: range 0x0006 to 0x0c80 (unit 1.25ms) */ /* minimal connection interval: range 0x0006 to 0x0c80 (unit 1.25ms) */
uint16_t interval_min; u16_t interval_min;
/* maximum connection interval: range 0x0006 to 0x0c80 must be bigger then min! */ /* maximum connection interval: range 0x0006 to 0x0c80 must be bigger then min! */
uint16_t interval_max; u16_t interval_max;
/* maximum connection slave latency: 0x0000 to 0x01f3 */ /* maximum connection slave latency: 0x0000 to 0x01f3 */
uint16_t slave_latency; u16_t slave_latency;
/* link supervision timeout: 0x000a to 0x0c80 (unit 10ms) */ /* link supervision timeout: 0x000a to 0x0c80 (unit 10ms) */
uint16_t link_sup_to; u16_t link_sup_to;
}; };
struct nble_gap_service_req { struct nble_gap_service_req {
/* GAP Characteristics attribute type see NBLE_GAP_SVC_ATTR_TYPE */ /* GAP Characteristics attribute type see NBLE_GAP_SVC_ATTR_TYPE */
uint16_t attr_type; u16_t attr_type;
union { union {
struct nble_gap_device_name name; struct nble_gap_device_name name;
/* Appearance UUID */ /* Appearance UUID */
uint16_t appearance; u16_t appearance;
/* Preferred Peripheral Connection Parameters */ /* Preferred Peripheral Connection Parameters */
struct nble_conn_param ppcp; struct nble_conn_param ppcp;
/* Central Address Resolution support 0: no, 1: yes */ /* Central Address Resolution support 0: no, 1: yes */
uint8_t car; u8_t car;
}; };
}; };
void nble_gap_service_req(const struct nble_gap_service_req *req); void nble_gap_service_req(const struct nble_gap_service_req *req);
struct nble_dbg_req { struct nble_dbg_req {
uint32_t u0; u32_t u0;
uint32_t u1; u32_t u1;
void *user_data; void *user_data;
}; };
@ -148,8 +148,8 @@ void nble_dbg_req(const struct nble_dbg_req *req);
struct nble_dbg_rsp { struct nble_dbg_rsp {
int status; int status;
uint32_t u0; u32_t u0;
uint32_t u1; u32_t u1;
void *user_data; void *user_data;
}; };
@ -192,8 +192,8 @@ struct nble_get_bda_rsp {
void on_nble_get_bda_rsp(const struct nble_get_bda_rsp *rsp); void on_nble_get_bda_rsp(const struct nble_get_bda_rsp *rsp);
struct nble_eir_data { struct nble_eir_data {
uint8_t len; u8_t len;
uint8_t data[31]; u8_t data[31];
}; };
struct nble_gap_set_adv_data_req { struct nble_gap_set_adv_data_req {
@ -206,15 +206,15 @@ struct nble_gap_set_adv_data_req {
void nble_gap_set_adv_data_req(struct nble_gap_set_adv_data_req *req); void nble_gap_set_adv_data_req(struct nble_gap_set_adv_data_req *req);
struct nble_gap_set_adv_params_req { struct nble_gap_set_adv_params_req {
uint16_t timeout; u16_t timeout;
/* min interval 0xffff: use default 0x0800 */ /* min interval 0xffff: use default 0x0800 */
uint16_t interval_min; u16_t interval_min;
/* max interval 0xffff: use default 0x0800 */ /* max interval 0xffff: use default 0x0800 */
uint16_t interval_max; u16_t interval_max;
/* advertisement types see GAP_ADV_TYPES */ /* advertisement types see GAP_ADV_TYPES */
uint8_t type; u8_t type;
/* filter policy to apply with white list */ /* filter policy to apply with white list */
uint8_t filter_policy; u8_t filter_policy;
/* bd address of peer device in case of directed advertisement */ /* bd address of peer device in case of directed advertisement */
bt_addr_le_t peer_bda; bt_addr_le_t peer_bda;
}; };
@ -228,7 +228,7 @@ void on_nble_gap_start_adv_rsp(const struct nble_common_rsp *rsp);
void nble_gap_stop_adv_req(void *user_data); void nble_gap_stop_adv_req(void *user_data);
struct nble_gap_conn_update_req { struct nble_gap_conn_update_req {
uint16_t conn_handle; u16_t conn_handle;
struct nble_conn_param params; struct nble_conn_param params;
}; };
@ -237,8 +237,8 @@ void nble_gap_conn_update_req(const struct nble_gap_conn_update_req *req);
void on_nble_gap_conn_update_rsp(const struct nble_common_rsp *rsp); void on_nble_gap_conn_update_rsp(const struct nble_common_rsp *rsp);
struct nble_gap_disconnect_req { struct nble_gap_disconnect_req {
uint16_t conn_handle; u16_t conn_handle;
uint8_t reason; u8_t reason;
}; };
void nble_gap_disconnect_req(const struct nble_gap_disconnect_req *req); void nble_gap_disconnect_req(const struct nble_gap_disconnect_req *req);
@ -253,16 +253,16 @@ void on_nble_sm_config_rsp(struct nble_sm_config_rsp *rsp);
struct nble_sm_pairing_param { struct nble_sm_pairing_param {
/* authentication level see BLE_GAP_SM_OPTIONS */ /* authentication level see BLE_GAP_SM_OPTIONS */
uint8_t auth; u8_t auth;
uint8_t io_capabilities; u8_t io_capabilities;
uint8_t max_key_size; u8_t max_key_size;
uint8_t min_key_size; u8_t min_key_size;
uint8_t oob_flag; u8_t oob_flag;
}; };
struct nble_sm_security_req { struct nble_sm_security_req {
struct bt_conn *conn; struct bt_conn *conn;
uint16_t conn_handle; u16_t conn_handle;
/* Local authentication/bonding parameters */ /* Local authentication/bonding parameters */
struct nble_sm_pairing_param params; struct nble_sm_pairing_param params;
}; };
@ -275,17 +275,17 @@ enum NBLE_SM_PASSKEY_TYPE {
}; };
struct nble_sm_passkey { struct nble_sm_passkey {
uint8_t type; /* see NBLE_SM_PASSKEY_TYPE */ u8_t type; /* see NBLE_SM_PASSKEY_TYPE */
union { union {
uint32_t passkey; u32_t passkey;
uint8_t oob[16]; u8_t oob[16];
uint8_t reason; u8_t reason;
}; };
}; };
struct nble_sm_passkey_reply_req { struct nble_sm_passkey_reply_req {
struct bt_conn *conn; struct bt_conn *conn;
uint16_t conn_handle; u16_t conn_handle;
struct nble_sm_passkey params; struct nble_sm_passkey params;
}; };
@ -306,7 +306,7 @@ void on_nble_sm_common_rsp(const struct nble_sm_common_rsp *rsp);
struct nble_sm_pairing_response_req { struct nble_sm_pairing_response_req {
struct bt_conn *conn; struct bt_conn *conn;
uint16_t conn_handle; u16_t conn_handle;
struct nble_sm_pairing_param params; struct nble_sm_pairing_param params;
}; };
@ -314,22 +314,22 @@ void nble_sm_pairing_response_req(const struct nble_sm_pairing_response_req *req
struct nble_sm_error_req { struct nble_sm_error_req {
struct bt_conn *conn; struct bt_conn *conn;
uint16_t conn_handle; u16_t conn_handle;
uint8_t reason; u8_t reason;
}; };
void nble_sm_error_req(const struct nble_sm_error_req *req); void nble_sm_error_req(const struct nble_sm_error_req *req);
struct nble_gap_set_rssi_report_req { struct nble_gap_set_rssi_report_req {
uint16_t conn_handle; u16_t conn_handle;
/* RSSI operation see NBLE_GAP_RSSI_OPS */ /* RSSI operation see NBLE_GAP_RSSI_OPS */
uint8_t op; u8_t op;
/* Channel for RSSI enabling */ /* Channel for RSSI enabling */
uint8_t channel; u8_t channel;
/* minimum RSSI dBm change to report a new RSSI value */ /* minimum RSSI dBm change to report a new RSSI value */
uint8_t delta_dBm; u8_t delta_dBm;
/* number of delta_dBm changes before sending a new RSSI report */ /* number of delta_dBm changes before sending a new RSSI report */
uint8_t min_count; u8_t min_count;
}; };
void nble_gap_set_rssi_report_req(const struct nble_gap_set_rssi_report_req *req, void nble_gap_set_rssi_report_req(const struct nble_gap_set_rssi_report_req *req,
@ -338,12 +338,12 @@ void nble_gap_set_rssi_report_req(const struct nble_gap_set_rssi_report_req *req
void on_nble_gap_set_rssi_report_rsp(const struct nble_common_rsp *rsp); void on_nble_gap_set_rssi_report_rsp(const struct nble_common_rsp *rsp);
struct nble_scan_param { struct nble_scan_param {
uint16_t interval; u16_t interval;
uint16_t window; u16_t window;
/* Unused for the connection request */ /* Unused for the connection request */
uint8_t scan_type; u8_t scan_type;
/* Unused for the connection request */ /* Unused for the connection request */
uint8_t use_whitelist; u8_t use_whitelist;
}; };
struct nble_gap_start_scan_req { struct nble_gap_start_scan_req {
@ -379,7 +379,7 @@ void nble_uas_rssi_calibrate_req(const struct nble_uas_rssi_calibrate_req *req);
/* Temporary patch: RSSI processing for UAS */ /* Temporary patch: RSSI processing for UAS */
struct nble_uas_bucket_change { struct nble_uas_bucket_change {
uint8_t distance; u8_t distance;
}; };
void on_nble_uas_bucket_change(const struct nble_uas_bucket_change *par); void on_nble_uas_bucket_change(const struct nble_uas_bucket_change *par);
@ -389,7 +389,7 @@ void nble_gap_dtm_init_req(void *user_data);
void on_nble_gap_dtm_init_rsp(void *user_data); void on_nble_gap_dtm_init_rsp(void *user_data);
struct nble_gap_set_tx_power_req { struct nble_gap_set_tx_power_req {
int8_t tx_power; s8_t tx_power;
}; };
void nble_gap_set_tx_power_req(const struct nble_gap_set_tx_power_req *req); void nble_gap_set_tx_power_req(const struct nble_gap_set_tx_power_req *req);
@ -398,18 +398,18 @@ void on_nble_gap_set_tx_power_rsp(const struct nble_common_rsp *rsp);
struct nble_conn_values { struct nble_conn_values {
/* Connection interval (unit 1.25 ms) */ /* Connection interval (unit 1.25 ms) */
uint16_t interval; u16_t interval;
/* Connection latency (unit interval) */ /* Connection latency (unit interval) */
uint16_t latency; u16_t latency;
/* Connection supervision timeout (unit 10ms)*/ /* Connection supervision timeout (unit 10ms)*/
uint16_t supervision_to; u16_t supervision_to;
}; };
struct nble_gap_connect_evt { struct nble_gap_connect_evt {
uint16_t conn_handle; u16_t conn_handle;
struct nble_conn_values conn_values; struct nble_conn_values conn_values;
/* 0 if connected as master, otherwise as slave */ /* 0 if connected as master, otherwise as slave */
uint8_t role_slave; u8_t role_slave;
/* Address of peer device */ /* Address of peer device */
bt_addr_le_t peer_bda; bt_addr_le_t peer_bda;
}; };
@ -417,14 +417,14 @@ struct nble_gap_connect_evt {
void on_nble_gap_connect_evt(const struct nble_gap_connect_evt *evt); void on_nble_gap_connect_evt(const struct nble_gap_connect_evt *evt);
struct nble_gap_disconnect_evt { struct nble_gap_disconnect_evt {
uint16_t conn_handle; u16_t conn_handle;
uint8_t hci_reason; u8_t hci_reason;
}; };
void on_nble_gap_disconnect_evt(const struct nble_gap_disconnect_evt *evt); void on_nble_gap_disconnect_evt(const struct nble_gap_disconnect_evt *evt);
struct nble_gap_conn_update_evt { struct nble_gap_conn_update_evt {
uint16_t conn_handle; u16_t conn_handle;
struct nble_conn_values conn_values; struct nble_conn_values conn_values;
}; };
@ -432,16 +432,16 @@ void on_nble_gap_conn_update_evt(const struct nble_gap_conn_update_evt *evt);
struct nble_gap_adv_report_evt { struct nble_gap_adv_report_evt {
bt_addr_le_t addr; bt_addr_le_t addr;
int8_t rssi; s8_t rssi;
uint8_t adv_type; u8_t adv_type;
}; };
void on_nble_gap_adv_report_evt(const struct nble_gap_adv_report_evt *evt, void on_nble_gap_adv_report_evt(const struct nble_gap_adv_report_evt *evt,
const uint8_t *data, uint8_t len); const u8_t *data, u8_t len);
struct nble_gap_dir_adv_timeout_evt { struct nble_gap_dir_adv_timeout_evt {
uint16_t conn_handle; u16_t conn_handle;
uint16_t error; u16_t error;
}; };
void on_nble_gap_dir_adv_timeout_evt(const struct nble_gap_dir_adv_timeout_evt *evt); void on_nble_gap_dir_adv_timeout_evt(const struct nble_gap_dir_adv_timeout_evt *evt);
@ -449,22 +449,22 @@ void on_nble_gap_dir_adv_timeout_evt(const struct nble_gap_dir_adv_timeout_evt *
#define BLE_GAP_RSSI_EVT_SIZE 32 #define BLE_GAP_RSSI_EVT_SIZE 32
struct nble_gap_rssi_evt { struct nble_gap_rssi_evt {
uint16_t conn_handle; u16_t conn_handle;
int8_t rssi_data[BLE_GAP_RSSI_EVT_SIZE]; s8_t rssi_data[BLE_GAP_RSSI_EVT_SIZE];
}; };
void on_nble_gap_rssi_evt(const struct nble_gap_rssi_evt *evt); void on_nble_gap_rssi_evt(const struct nble_gap_rssi_evt *evt);
struct nble_sm_passkey_req_evt { struct nble_sm_passkey_req_evt {
uint16_t conn_handle; u16_t conn_handle;
uint8_t key_type; u8_t key_type;
}; };
void on_nble_sm_passkey_req_evt(const struct nble_sm_passkey_req_evt *evt); void on_nble_sm_passkey_req_evt(const struct nble_sm_passkey_req_evt *evt);
struct nble_sm_passkey_disp_evt { struct nble_sm_passkey_disp_evt {
uint16_t conn_handle; u16_t conn_handle;
uint32_t passkey; u32_t passkey;
}; };
void on_nble_sm_passkey_disp_evt(const struct nble_sm_passkey_disp_evt *evt); void on_nble_sm_passkey_disp_evt(const struct nble_sm_passkey_disp_evt *evt);
@ -478,12 +478,12 @@ enum NBLE_SM_STATUS_EVT {
struct nble_link_sec { struct nble_link_sec {
bt_security_t sec_level; bt_security_t sec_level;
uint8_t enc_size; u8_t enc_size;
}; };
struct nble_sm_status_evt { struct nble_sm_status_evt {
uint16_t conn_handle; u16_t conn_handle;
uint8_t evt_type; /* see NBLE_SM_STATUS_EVT */ u8_t evt_type; /* see NBLE_SM_STATUS_EVT */
int status; int status;
union { union {
struct nble_link_sec enc_link_sec; struct nble_link_sec enc_link_sec;
@ -494,21 +494,21 @@ struct nble_sm_status_evt {
void on_nble_sm_status_evt(const struct nble_sm_status_evt *evt); void on_nble_sm_status_evt(const struct nble_sm_status_evt *evt);
struct nble_sec_param { struct nble_sec_param {
uint8_t auth; u8_t auth;
uint8_t io_capabilities; u8_t io_capabilities;
uint8_t min_key_size; u8_t min_key_size;
uint8_t max_key_size; u8_t max_key_size;
}; };
struct nble_sm_pairing_request_evt { struct nble_sm_pairing_request_evt {
uint16_t conn_handle; u16_t conn_handle;
struct nble_sec_param sec_param; struct nble_sec_param sec_param;
}; };
void on_nble_sm_pairing_request_evt(const struct nble_sm_pairing_request_evt *evt); void on_nble_sm_pairing_request_evt(const struct nble_sm_pairing_request_evt *evt);
struct nble_sm_security_request_evt { struct nble_sm_security_request_evt {
uint16_t conn_handle; u16_t conn_handle;
struct nble_sec_param sec_param; struct nble_sec_param sec_param;
}; };
@ -516,7 +516,7 @@ void on_nble_sm_security_request_evt(const struct nble_sm_security_request_evt *
struct nble_sm_bond_info; struct nble_sm_bond_info;
typedef void (*ble_bond_info_cb_t)(const struct nble_sm_bond_info *info, typedef void (*ble_bond_info_cb_t)(const struct nble_sm_bond_info *info,
const bt_addr_le_t *addr, uint16_t len, const bt_addr_le_t *addr, u16_t len,
void *user_data); void *user_data);
struct nble_sm_bond_info_req { struct nble_sm_bond_info_req {
@ -529,8 +529,8 @@ void nble_sm_bond_info_req(const struct nble_sm_bond_info_req *req);
struct nble_sm_bond_info { struct nble_sm_bond_info {
int err; int err;
uint8_t addr_count; u8_t addr_count;
uint8_t irk_count; u8_t irk_count;
}; };
struct nble_sm_bond_info_rsp { struct nble_sm_bond_info_rsp {
@ -540,29 +540,29 @@ struct nble_sm_bond_info_rsp {
}; };
void on_nble_sm_bond_info_rsp(const struct nble_sm_bond_info_rsp *rsp, void on_nble_sm_bond_info_rsp(const struct nble_sm_bond_info_rsp *rsp,
const bt_addr_le_t *peer_addr, uint16_t len); const bt_addr_le_t *peer_addr, u16_t len);
struct nble_uart_test_req { struct nble_uart_test_req {
/* Test type: 1 = start peer test, 2 = loopback test */ /* Test type: 1 = start peer test, 2 = loopback test */
uint16_t test_type; u16_t test_type;
/* Test type 1: Number of test events packets sent from peer to host */ /* Test type 1: Number of test events packets sent from peer to host */
uint16_t nb_loops; u16_t nb_loops;
/* Test type 1: The maximum delay between packets (in ms) */ /* Test type 1: The maximum delay between packets (in ms) */
uint16_t max_delay; u16_t max_delay;
/* Test type 1: The maximum length of packets (in bytes) */ /* Test type 1: The maximum length of packets (in bytes) */
uint16_t max_len; u16_t max_len;
}; };
void nble_uart_test_req(const struct nble_uart_test_req *req, void nble_uart_test_req(const struct nble_uart_test_req *req,
const uint8_t *data, uint8_t len); const u8_t *data, u8_t len);
struct nble_uart_test_evt { struct nble_uart_test_evt {
/* Number of loops executed */ /* Number of loops executed */
uint16_t nb_loops; u16_t nb_loops;
}; };
void on_nble_uart_test_evt(const struct nble_uart_test_evt *evt, void on_nble_uart_test_evt(const struct nble_uart_test_evt *evt,
const uint8_t *data, uint8_t len); const u8_t *data, u8_t len);
/* /*
* The following functions are NOT RPC functions * The following functions are NOT RPC functions
@ -580,19 +580,19 @@ enum NBLE_GAP_RSSI_OPS {
NBLE_GAP_RSSI_ENABLE_REPORT NBLE_GAP_RSSI_ENABLE_REPORT
}; };
typedef void (*rssi_report_t)(const int8_t *rssi_data); typedef void (*rssi_report_t)(const s8_t *rssi_data);
typedef void (*rssi_report_resp_t)(int status); typedef void (*rssi_report_resp_t)(int status);
struct ble_rssi_report_params { struct ble_rssi_report_params {
/* RSSI operation see NBLE_GAP_RSSI_OPS */ /* RSSI operation see NBLE_GAP_RSSI_OPS */
uint8_t op; u8_t op;
/* Channel for RSSI enabling */ /* Channel for RSSI enabling */
uint8_t channel; u8_t channel;
/* minimum RSSI dBm change to report a new RSSI value */ /* minimum RSSI dBm change to report a new RSSI value */
uint8_t delta_dBm; u8_t delta_dBm;
/* number of delta_dBm changes before sending a new RSSI report */ /* number of delta_dBm changes before sending a new RSSI report */
uint8_t min_count; u8_t min_count;
}; };
void ble_gap_set_rssi_report(struct ble_rssi_report_params *par, void ble_gap_set_rssi_report(struct ble_rssi_report_params *par,

View file

@ -34,11 +34,11 @@ static K_FIFO_DEFINE(queue);
struct nble_gatt_service { struct nble_gatt_service {
const struct bt_gatt_attr *attrs; const struct bt_gatt_attr *attrs;
uint16_t attr_count; u16_t attr_count;
}; };
static struct nble_gatt_service svc_db[BLE_GATTS_MAX_SERVICES]; static struct nble_gatt_service svc_db[BLE_GATTS_MAX_SERVICES];
static uint8_t svc_count; static u8_t svc_count;
static sys_slist_t subscriptions; static sys_slist_t subscriptions;
@ -48,9 +48,9 @@ static sys_slist_t subscriptions;
* @param uuid Pointer to the UUID to copy * @param uuid Pointer to the UUID to copy
* @return The length required to store the UUID in the memory * @return The length required to store the UUID in the memory
*/ */
static uint8_t bt_gatt_uuid_memcpy(uint8_t *buf, const struct bt_uuid *uuid) static u8_t bt_gatt_uuid_memcpy(u8_t *buf, const struct bt_uuid *uuid)
{ {
uint8_t *ptr = buf; u8_t *ptr = buf;
/* Store the type of the UUID */ /* Store the type of the UUID */
*ptr = uuid->type; *ptr = uuid->type;
@ -58,7 +58,7 @@ static uint8_t bt_gatt_uuid_memcpy(uint8_t *buf, const struct bt_uuid *uuid)
/* Store the UUID data */ /* Store the UUID data */
if (uuid->type == BT_UUID_TYPE_16) { if (uuid->type == BT_UUID_TYPE_16) {
uint16_t le16; u16_t le16;
le16 = sys_cpu_to_le16(BT_UUID_16(uuid)->val); le16 = sys_cpu_to_le16(BT_UUID_16(uuid)->val);
memcpy(ptr, &le16, sizeof(le16)); memcpy(ptr, &le16, sizeof(le16));
@ -85,9 +85,9 @@ static struct bt_uuid *whitelist[] = {
BT_UUID_GAP_PPCP BT_UUID_GAP_PPCP
}; };
static int attr_read(struct bt_gatt_attr *attr, uint8_t *data, size_t len) static int attr_read(struct bt_gatt_attr *attr, u8_t *data, size_t len)
{ {
uint8_t i; u8_t i;
int data_size; int data_size;
if (!data) { if (!data) {
@ -118,8 +118,8 @@ int bt_gatt_register(struct bt_gatt_attr *attrs, size_t count)
struct nble_gatts_register_req param; struct nble_gatts_register_req param;
size_t i; size_t i;
/* TODO: Replace the following with net_buf */ /* TODO: Replace the following with net_buf */
uint8_t attr_table[NBLE_BUF_SIZE]; u8_t attr_table[NBLE_BUF_SIZE];
uint8_t attr_table_size; u8_t attr_table_size;
if (!attrs || !count) { if (!attrs || !count) {
return -EINVAL; return -EINVAL;
@ -174,7 +174,7 @@ int bt_gatt_register(struct bt_gatt_attr *attrs, size_t count)
void on_nble_gatts_register_rsp(const struct nble_gatts_register_rsp *rsp, void on_nble_gatts_register_rsp(const struct nble_gatts_register_rsp *rsp,
const struct nble_gatt_attr_handles *handles, const struct nble_gatt_attr_handles *handles,
uint8_t len) u8_t len)
{ {
int i; int i;
struct bt_gatt_attr *head_svc_attr; struct bt_gatt_attr *head_svc_attr;
@ -217,13 +217,13 @@ void on_nble_gatts_register_rsp(const struct nble_gatts_register_rsp *rsp,
#endif #endif
} }
void bt_gatt_foreach_attr(uint16_t start_handle, uint16_t end_handle, void bt_gatt_foreach_attr(u16_t start_handle, u16_t end_handle,
bt_gatt_attr_func_t func, void *user_data) bt_gatt_attr_func_t func, void *user_data)
{ {
int i; int i;
for (i = 0; i < svc_count; i++) { for (i = 0; i < svc_count; i++) {
uint16_t attr_count = svc_db[i].attr_count; u16_t attr_count = svc_db[i].attr_count;
const struct bt_gatt_attr *attr; const struct bt_gatt_attr *attr;
int j; int j;
@ -245,12 +245,12 @@ void bt_gatt_foreach_attr(uint16_t start_handle, uint16_t end_handle,
struct bt_gatt_attr *bt_gatt_attr_next(const struct bt_gatt_attr *attr) struct bt_gatt_attr *bt_gatt_attr_next(const struct bt_gatt_attr *attr)
{ {
uint16_t i; u16_t i;
for (i = 0; i < svc_count; i++) { for (i = 0; i < svc_count; i++) {
if (attr >= svc_db[i].attrs && if (attr >= svc_db[i].attrs &&
attr < svc_db[i].attrs + svc_db[i].attr_count) { attr < svc_db[i].attrs + svc_db[i].attr_count) {
uint8_t attr_i; u8_t attr_i;
attr_i = (attr - svc_db[i].attrs) + 1; attr_i = (attr - svc_db[i].attrs) + 1;
@ -270,10 +270,10 @@ struct bt_gatt_attr *bt_gatt_attr_next(const struct bt_gatt_attr *attr)
} }
ssize_t bt_gatt_attr_read(struct bt_conn *conn, const struct bt_gatt_attr *attr, ssize_t bt_gatt_attr_read(struct bt_conn *conn, const struct bt_gatt_attr *attr,
void *buf, uint16_t buf_len, uint16_t offset, void *buf, u16_t buf_len, u16_t offset,
const void *value, uint16_t value_len) const void *value, u16_t value_len)
{ {
uint16_t len; u16_t len;
BT_DBG("handle 0x%04x offset %u", attr->handle, offset); BT_DBG("handle 0x%04x offset %u", attr->handle, offset);
@ -295,12 +295,12 @@ ssize_t bt_gatt_attr_read(struct bt_conn *conn, const struct bt_gatt_attr *attr,
ssize_t bt_gatt_attr_read_service(struct bt_conn *conn, ssize_t bt_gatt_attr_read_service(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const struct bt_gatt_attr *attr,
void *buf, uint16_t len, uint16_t offset) void *buf, u16_t len, u16_t offset)
{ {
struct bt_uuid *uuid = attr->user_data; struct bt_uuid *uuid = attr->user_data;
if (uuid->type == BT_UUID_TYPE_16) { if (uuid->type == BT_UUID_TYPE_16) {
uint16_t uuid16 = sys_cpu_to_le16(BT_UUID_16(uuid)->val); u16_t uuid16 = sys_cpu_to_le16(BT_UUID_16(uuid)->val);
return bt_gatt_attr_read(conn, attr, buf, len, offset, return bt_gatt_attr_read(conn, attr, buf, len, offset,
&uuid16, 2); &uuid16, 2);
@ -312,7 +312,7 @@ ssize_t bt_gatt_attr_read_service(struct bt_conn *conn,
ssize_t bt_gatt_attr_read_included(struct bt_conn *conn, ssize_t bt_gatt_attr_read_included(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const struct bt_gatt_attr *attr,
void *buf, uint16_t len, uint16_t offset) void *buf, u16_t len, u16_t offset)
{ {
/* /*
* bt_gatt_attr_read uses memcpy to copy the address of the attr * bt_gatt_attr_read uses memcpy to copy the address of the attr
@ -331,21 +331,21 @@ ssize_t bt_gatt_attr_read_included(struct bt_conn *conn,
} }
struct gatt_chrc { struct gatt_chrc {
uint8_t properties; u8_t properties;
uint16_t value_handle; u16_t value_handle;
union { union {
uint16_t uuid16; u16_t uuid16;
uint8_t uuid[16]; u8_t uuid[16];
}; };
} __packed; } __packed;
ssize_t bt_gatt_attr_read_chrc(struct bt_conn *conn, ssize_t bt_gatt_attr_read_chrc(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf, const struct bt_gatt_attr *attr, void *buf,
uint16_t len, uint16_t offset) u16_t len, u16_t offset)
{ {
struct bt_gatt_chrc *chrc = attr->user_data; struct bt_gatt_chrc *chrc = attr->user_data;
struct gatt_chrc pdu; struct gatt_chrc pdu;
uint8_t value_len; u8_t value_len;
pdu.properties = chrc->properties; pdu.properties = chrc->properties;
@ -367,7 +367,7 @@ ssize_t bt_gatt_attr_read_chrc(struct bt_conn *conn,
ssize_t bt_gatt_attr_read_ccc(struct bt_conn *conn, ssize_t bt_gatt_attr_read_ccc(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf, const struct bt_gatt_attr *attr, void *buf,
uint16_t len, uint16_t offset) u16_t len, u16_t offset)
{ {
return BT_GATT_ERR(BT_ATT_ERR_NOT_SUPPORTED); return BT_GATT_ERR(BT_ATT_ERR_NOT_SUPPORTED);
} }
@ -376,7 +376,7 @@ static void gatt_ccc_changed(const struct bt_gatt_attr *attr,
struct _bt_gatt_ccc *ccc) struct _bt_gatt_ccc *ccc)
{ {
int i; int i;
uint16_t value = 0x0000; u16_t value = 0x0000;
for (i = 0; i < ccc->cfg_len; i++) { for (i = 0; i < ccc->cfg_len; i++) {
if (ccc->cfg[i].value > value) { if (ccc->cfg[i].value > value) {
@ -394,10 +394,10 @@ static void gatt_ccc_changed(const struct bt_gatt_attr *attr,
ssize_t bt_gatt_attr_write_ccc(struct bt_conn *conn, ssize_t bt_gatt_attr_write_ccc(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const void *buf, const struct bt_gatt_attr *attr, const void *buf,
uint16_t len, uint16_t offset, uint8_t flags) u16_t len, u16_t offset, u8_t flags)
{ {
struct _bt_gatt_ccc *ccc = attr->user_data; struct _bt_gatt_ccc *ccc = attr->user_data;
const uint16_t *data = buf; const u16_t *data = buf;
size_t i; size_t i;
if (offset > sizeof(*data)) { if (offset > sizeof(*data)) {
@ -448,10 +448,10 @@ ssize_t bt_gatt_attr_write_ccc(struct bt_conn *conn,
ssize_t bt_gatt_attr_read_cep(struct bt_conn *conn, ssize_t bt_gatt_attr_read_cep(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf, const struct bt_gatt_attr *attr, void *buf,
uint16_t len, uint16_t offset) u16_t len, u16_t offset)
{ {
struct bt_gatt_cep *value = attr->user_data; struct bt_gatt_cep *value = attr->user_data;
uint16_t props = sys_cpu_to_le16(value->properties); u16_t props = sys_cpu_to_le16(value->properties);
return bt_gatt_attr_read(conn, attr, buf, len, offset, &props, return bt_gatt_attr_read(conn, attr, buf, len, offset, &props,
sizeof(props)); sizeof(props));
@ -459,7 +459,7 @@ ssize_t bt_gatt_attr_read_cep(struct bt_conn *conn,
ssize_t bt_gatt_attr_read_cud(struct bt_conn *conn, ssize_t bt_gatt_attr_read_cud(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf, const struct bt_gatt_attr *attr, void *buf,
uint16_t len, uint16_t offset) u16_t len, u16_t offset)
{ {
char *value = attr->user_data; char *value = attr->user_data;
@ -469,7 +469,7 @@ ssize_t bt_gatt_attr_read_cud(struct bt_conn *conn,
ssize_t bt_gatt_attr_read_cpf(struct bt_conn *conn, ssize_t bt_gatt_attr_read_cpf(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf, const struct bt_gatt_attr *attr, void *buf,
uint16_t len, uint16_t offset) u16_t len, u16_t offset)
{ {
struct bt_gatt_cpf *value = attr->user_data; struct bt_gatt_cpf *value = attr->user_data;
@ -491,7 +491,7 @@ static int notify(struct bt_conn *conn, const struct bt_gatt_attr *attr,
notif.params.offset = 0; notif.params.offset = 0;
notif.cback = NULL; notif.cback = NULL;
nble_gatts_notify_req(&notif, (uint8_t *)data, len); nble_gatts_notify_req(&notif, (u8_t *)data, len);
return 0; return 0;
} }
@ -544,14 +544,14 @@ static int indicate(struct bt_conn *conn,
} }
struct notify_data { struct notify_data {
uint16_t type; u16_t type;
const struct bt_gatt_attr *attr; const struct bt_gatt_attr *attr;
const void *data; const void *data;
uint16_t len; u16_t len;
struct bt_gatt_indicate_params *params; struct bt_gatt_indicate_params *params;
}; };
static uint8_t notify_cb(const struct bt_gatt_attr *attr, void *user_data) static u8_t notify_cb(const struct bt_gatt_attr *attr, void *user_data)
{ {
struct notify_data *data = user_data; struct notify_data *data = user_data;
struct _bt_gatt_ccc *ccc; struct _bt_gatt_ccc *ccc;
@ -603,7 +603,7 @@ static uint8_t notify_cb(const struct bt_gatt_attr *attr, void *user_data)
} }
int bt_gatt_notify(struct bt_conn *conn, const struct bt_gatt_attr *attr, int bt_gatt_notify(struct bt_conn *conn, const struct bt_gatt_attr *attr,
const void *data, uint16_t len) const void *data, u16_t len)
{ {
struct notify_data nfy; struct notify_data nfy;
@ -734,11 +734,11 @@ int bt_gatt_discover(struct bt_conn *conn,
return 0; return 0;
} }
static uint16_t parse_include(struct bt_conn *conn, static u16_t parse_include(struct bt_conn *conn,
struct bt_gatt_discover_params *params, struct bt_gatt_discover_params *params,
const uint8_t *data, uint8_t len) const u8_t *data, u8_t len)
{ {
uint16_t end_handle = 0; u16_t end_handle = 0;
int i; int i;
for (i = 0; len > 0; i++) { for (i = 0; len > 0; i++) {
@ -782,11 +782,11 @@ static uint16_t parse_include(struct bt_conn *conn,
return end_handle; return end_handle;
} }
static uint16_t parse_service(struct bt_conn *conn, static u16_t parse_service(struct bt_conn *conn,
struct bt_gatt_discover_params *params, struct bt_gatt_discover_params *params,
const uint8_t *data, uint8_t len) const u8_t *data, u8_t len)
{ {
uint16_t end_handle = 0; u16_t end_handle = 0;
int i; int i;
for (i = 0; len > 0; i++) { for (i = 0; len > 0; i++) {
@ -813,11 +813,11 @@ static uint16_t parse_service(struct bt_conn *conn,
return end_handle; return end_handle;
} }
static uint16_t parse_characteristic(struct bt_conn *conn, static u16_t parse_characteristic(struct bt_conn *conn,
struct bt_gatt_discover_params *params, struct bt_gatt_discover_params *params,
const uint8_t *data, uint8_t len) const u8_t *data, u8_t len)
{ {
uint16_t end_handle = 0; u16_t end_handle = 0;
int i; int i;
for (i = 0; len > 0; i++) { for (i = 0; len > 0; i++) {
@ -846,11 +846,11 @@ static uint16_t parse_characteristic(struct bt_conn *conn,
return end_handle; return end_handle;
} }
static uint16_t parse_descriptor(struct bt_conn *conn, static u16_t parse_descriptor(struct bt_conn *conn,
struct bt_gatt_discover_params *params, struct bt_gatt_discover_params *params,
const uint8_t *data, uint8_t len) const u8_t *data, u8_t len)
{ {
uint16_t end_handle = 0; u16_t end_handle = 0;
int i; int i;
for (i = 0; len > 0; i++) { for (i = 0; len > 0; i++) {
@ -885,9 +885,9 @@ static void *gatt_get_private(struct bt_conn *conn)
} }
void on_nble_gattc_discover_rsp(const struct nble_gattc_discover_rsp *rsp, void on_nble_gattc_discover_rsp(const struct nble_gattc_discover_rsp *rsp,
const uint8_t *data, uint8_t data_len) const u8_t *data, u8_t data_len)
{ {
uint16_t end_handle = 0; u16_t end_handle = 0;
struct bt_gatt_discover_params *params; struct bt_gatt_discover_params *params;
struct bt_conn *conn; struct bt_conn *conn;
int status; int status;
@ -1006,7 +1006,7 @@ int bt_gatt_read(struct bt_conn *conn, struct bt_gatt_read_params *params)
} }
void on_nble_gattc_read_rsp(const struct nble_gattc_read_rsp *rsp, void on_nble_gattc_read_rsp(const struct nble_gattc_read_rsp *rsp,
uint8_t *data, uint8_t len) u8_t *data, u8_t len)
{ {
struct bt_gatt_read_params *params = rsp->user_data; struct bt_gatt_read_params *params = rsp->user_data;
struct bt_conn *conn; struct bt_conn *conn;
@ -1052,7 +1052,7 @@ done:
} }
void on_nble_gattc_read_multi_rsp(const struct nble_gattc_read_rsp *rsp, void on_nble_gattc_read_multi_rsp(const struct nble_gattc_read_rsp *rsp,
uint8_t *data, uint8_t len) u8_t *data, u8_t len)
{ {
struct bt_gatt_read_params *params = rsp->user_data; struct bt_gatt_read_params *params = rsp->user_data;
struct bt_conn *conn; struct bt_conn *conn;
@ -1113,7 +1113,7 @@ int bt_gatt_write(struct bt_conn *conn, struct bt_gatt_write_params *params)
return 0; return 0;
} }
static void gatt_write_ccc_rsp(struct bt_conn *conn, uint8_t err, static void gatt_write_ccc_rsp(struct bt_conn *conn, u8_t err,
struct bt_gatt_write_params *params) struct bt_gatt_write_params *params)
{ {
BT_DBG("conn %p err %u", conn, err); BT_DBG("conn %p err %u", conn, err);
@ -1149,8 +1149,8 @@ void on_nble_gattc_write_rsp(const struct nble_gattc_write_rsp *rsp)
bt_conn_unref(conn); bt_conn_unref(conn);
} }
int bt_gatt_write_without_response(struct bt_conn *conn, uint16_t handle, int bt_gatt_write_without_response(struct bt_conn *conn, u16_t handle,
const void *data, uint16_t length, const void *data, u16_t length,
bool sign) bool sign)
{ {
struct nble_gattc_write_req req; struct nble_gattc_write_req req;
@ -1304,7 +1304,7 @@ int bt_gatt_subscribe(struct bt_conn *conn,
} }
void on_nble_gattc_value_evt(const struct nble_gattc_value_evt *ev, void on_nble_gattc_value_evt(const struct nble_gattc_value_evt *ev,
uint8_t *data, uint8_t length) u8_t *data, u8_t length)
{ {
sys_snode_t *node, *tmp, *prev = NULL; sys_snode_t *node, *tmp, *prev = NULL;
struct bt_conn *conn; struct bt_conn *conn;
@ -1403,8 +1403,8 @@ void bt_gatt_cancel(struct bt_conn *conn, void *params)
BT_DBG(""); BT_DBG("");
} }
static int32_t prep_write_evt(const struct nble_gatts_write_evt *ev, static s32_t prep_write_evt(const struct nble_gatts_write_evt *ev,
const uint8_t *data, uint8_t len) const u8_t *data, u8_t len)
{ {
#if CONFIG_BLUETOOTH_ATT_PREPARE_COUNT > 0 #if CONFIG_BLUETOOTH_ATT_PREPARE_COUNT > 0
const struct bt_gatt_attr *attr = ev->attr; const struct bt_gatt_attr *attr = ev->attr;
@ -1443,11 +1443,11 @@ static int32_t prep_write_evt(const struct nble_gatts_write_evt *ev,
#endif #endif
} }
static int32_t write_evt(struct bt_conn *conn, static s32_t write_evt(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const struct bt_gatt_attr *attr,
uint16_t offset, const uint8_t *data, uint8_t len) u16_t offset, const u8_t *data, u8_t len)
{ {
int32_t status; s32_t status;
status = attr->write(conn, attr, data, len, offset, 0); status = attr->write(conn, attr, data, len, offset, 0);
if (status < 0) { if (status < 0) {
@ -1463,7 +1463,7 @@ static int32_t write_evt(struct bt_conn *conn,
} }
void on_nble_gatts_write_evt(const struct nble_gatts_write_evt *ev, void on_nble_gatts_write_evt(const struct nble_gatts_write_evt *ev,
const uint8_t *buf, uint8_t buflen) const u8_t *buf, u8_t buflen)
{ {
const struct bt_gatt_attr *attr = ev->attr; const struct bt_gatt_attr *attr = ev->attr;
struct bt_conn *conn = bt_conn_lookup_handle(ev->conn_handle); struct bt_conn *conn = bt_conn_lookup_handle(ev->conn_handle);
@ -1548,7 +1548,7 @@ void on_nble_gatts_read_evt(const struct nble_gatts_read_evt *ev)
struct nble_gatts_read_reply_req reply_data; struct nble_gatts_read_reply_req reply_data;
const struct bt_gatt_attr *attr; const struct bt_gatt_attr *attr;
/* TODO: Replace the following with net_buf */ /* TODO: Replace the following with net_buf */
uint8_t data[BLE_GATT_MTU_SIZE] = { 0 }; u8_t data[BLE_GATT_MTU_SIZE] = { 0 };
int len; int len;
attr = ev->attr; attr = ev->attr;

View file

@ -25,39 +25,39 @@ void bt_gatt_init(void);
*/ */
struct nble_gatts_attr { struct nble_gatts_attr {
/* Attribute permissions */ /* Attribute permissions */
uint16_t perm; u16_t perm;
/* Attribute variable data size */ /* Attribute variable data size */
uint16_t data_size; u16_t data_size;
/* Attribute variable data: always starts with the UUID and data follows */ /* Attribute variable data: always starts with the UUID and data follows */
uint8_t data[]; u8_t data[];
}; };
struct nble_gatts_register_req { struct nble_gatts_register_req {
/* Base address of the attribute table in the Quark mem space */ /* Base address of the attribute table in the Quark mem space */
struct bt_gatt_attr *attr_base; struct bt_gatt_attr *attr_base;
/* Number of of attributes in this service */ /* Number of of attributes in this service */
uint8_t attr_count; u8_t attr_count;
/* Size of struct bt_gatt_attr */ /* Size of struct bt_gatt_attr */
uint8_t attr_size; u8_t attr_size;
}; };
void nble_gatts_register_req(const struct nble_gatts_register_req *req, void nble_gatts_register_req(const struct nble_gatts_register_req *req,
uint8_t *data, uint16_t len); u8_t *data, u16_t len);
struct nble_gatts_register_rsp { struct nble_gatts_register_rsp {
int status; int status;
struct bt_gatt_attr *attr_base; struct bt_gatt_attr *attr_base;
/* Number of attributes successfully added */ /* Number of attributes successfully added */
uint8_t attr_count; u8_t attr_count;
}; };
struct nble_gatt_attr_handles { struct nble_gatt_attr_handles {
uint16_t handle; u16_t handle;
}; };
void on_nble_gatts_register_rsp(const struct nble_gatts_register_rsp *rsp, void on_nble_gatts_register_rsp(const struct nble_gatts_register_rsp *rsp,
const struct nble_gatt_attr_handles *attrs, const struct nble_gatt_attr_handles *attrs,
uint8_t len); u8_t len);
enum nble_gatt_wr_flag { enum nble_gatt_wr_flag {
NBLE_GATT_WR_FLAG_REPLY = 1, NBLE_GATT_WR_FLAG_REPLY = 1,
@ -66,52 +66,52 @@ enum nble_gatt_wr_flag {
struct nble_gatts_write_evt { struct nble_gatts_write_evt {
struct bt_gatt_attr *attr; struct bt_gatt_attr *attr;
uint16_t conn_handle; u16_t conn_handle;
uint16_t offset; u16_t offset;
/* see nble_gatt_wr_flag */ /* see nble_gatt_wr_flag */
uint8_t flag; u8_t flag;
}; };
void on_nble_gatts_write_evt(const struct nble_gatts_write_evt *evt, void on_nble_gatts_write_evt(const struct nble_gatts_write_evt *evt,
const uint8_t *data, uint8_t len); const u8_t *data, u8_t len);
struct nble_gatts_write_reply_req { struct nble_gatts_write_reply_req {
uint16_t conn_handle; u16_t conn_handle;
uint16_t offset; u16_t offset;
int32_t status; s32_t status;
}; };
void nble_gatts_write_reply_req(const struct nble_gatts_write_reply_req *req, void nble_gatts_write_reply_req(const struct nble_gatts_write_reply_req *req,
const uint8_t *data, uint8_t len); const u8_t *data, u8_t len);
struct nble_gatts_write_exec_evt { struct nble_gatts_write_exec_evt {
uint16_t conn_handle; u16_t conn_handle;
uint8_t flag; u8_t flag;
}; };
void on_nble_gatts_write_exec_evt(const struct nble_gatts_write_exec_evt *evt); void on_nble_gatts_write_exec_evt(const struct nble_gatts_write_exec_evt *evt);
struct nble_gatts_read_evt { struct nble_gatts_read_evt {
struct bt_gatt_attr *attr; struct bt_gatt_attr *attr;
uint16_t conn_handle; u16_t conn_handle;
uint16_t offset; u16_t offset;
}; };
void on_nble_gatts_read_evt(const struct nble_gatts_read_evt *evt); void on_nble_gatts_read_evt(const struct nble_gatts_read_evt *evt);
struct nble_gatts_read_reply_req { struct nble_gatts_read_reply_req {
uint16_t conn_handle; u16_t conn_handle;
uint16_t offset; u16_t offset;
int32_t status; s32_t status;
}; };
void nble_gatts_read_reply_req(const struct nble_gatts_read_reply_req *req, void nble_gatts_read_reply_req(const struct nble_gatts_read_reply_req *req,
uint8_t *data, uint16_t len); u8_t *data, u16_t len);
struct nble_gatts_value_change_param { struct nble_gatts_value_change_param {
const struct bt_gatt_attr *attr; const struct bt_gatt_attr *attr;
uint16_t conn_handle; u16_t conn_handle;
uint16_t offset; u16_t offset;
}; };
struct nble_gatts_notify_req { struct nble_gatts_notify_req {
@ -121,12 +121,12 @@ struct nble_gatts_notify_req {
}; };
void nble_gatts_notify_req(const struct nble_gatts_notify_req *req, void nble_gatts_notify_req(const struct nble_gatts_notify_req *req,
const uint8_t *data, uint16_t len); const u8_t *data, u16_t len);
struct nble_gatts_notify_tx_evt { struct nble_gatts_notify_tx_evt {
bt_gatt_notify_func_t cback; bt_gatt_notify_func_t cback;
int status; int status;
uint16_t conn_handle; u16_t conn_handle;
struct bt_gatt_attr *attr; struct bt_gatt_attr *attr;
}; };
@ -139,13 +139,13 @@ struct nble_gatts_indicate_req {
}; };
void nble_gatts_indicate_req(const struct nble_gatts_indicate_req *req, void nble_gatts_indicate_req(const struct nble_gatts_indicate_req *req,
const uint8_t *data, uint8_t len); const u8_t *data, u8_t len);
struct nble_gatts_indicate_rsp { struct nble_gatts_indicate_rsp {
bt_gatt_indicate_func_t cback; bt_gatt_indicate_func_t cback;
struct bt_gatt_attr *attr; struct bt_gatt_attr *attr;
int status; int status;
uint16_t conn_handle; u16_t conn_handle;
}; };
void on_nble_gatts_indicate_rsp(const struct nble_gatts_indicate_rsp *rsp); void on_nble_gatts_indicate_rsp(const struct nble_gatts_indicate_rsp *rsp);
@ -153,60 +153,60 @@ void on_nble_gatts_indicate_rsp(const struct nble_gatts_indicate_rsp *rsp);
#define DISCOVER_FLAGS_UUID_PRESENT 1 #define DISCOVER_FLAGS_UUID_PRESENT 1
struct nble_gatt_handle_range { struct nble_gatt_handle_range {
uint16_t start_handle; u16_t start_handle;
uint16_t end_handle; u16_t end_handle;
}; };
struct nble_gattc_discover_req { struct nble_gattc_discover_req {
void *user_data; void *user_data;
struct bt_uuid_128 uuid; struct bt_uuid_128 uuid;
struct nble_gatt_handle_range handle_range; struct nble_gatt_handle_range handle_range;
uint16_t conn_handle; u16_t conn_handle;
uint8_t type; u8_t type;
uint8_t flags; u8_t flags;
}; };
void nble_gattc_discover_req(const struct nble_gattc_discover_req *req); void nble_gattc_discover_req(const struct nble_gattc_discover_req *req);
struct nble_gattc_primary { struct nble_gattc_primary {
uint16_t handle; u16_t handle;
struct nble_gatt_handle_range range; struct nble_gatt_handle_range range;
struct bt_uuid_128 uuid; struct bt_uuid_128 uuid;
}; };
struct nble_gattc_included { struct nble_gattc_included {
uint16_t handle; u16_t handle;
struct nble_gatt_handle_range range; struct nble_gatt_handle_range range;
struct bt_uuid_128 uuid; struct bt_uuid_128 uuid;
}; };
struct nble_gattc_characteristic { struct nble_gattc_characteristic {
uint16_t handle; u16_t handle;
uint8_t prop; u8_t prop;
uint16_t value_handle; u16_t value_handle;
struct bt_uuid_128 uuid; struct bt_uuid_128 uuid;
}; };
struct nble_gattc_descriptor { struct nble_gattc_descriptor {
uint16_t handle; u16_t handle;
struct bt_uuid_128 uuid; struct bt_uuid_128 uuid;
}; };
struct nble_gattc_discover_rsp { struct nble_gattc_discover_rsp {
int32_t status; s32_t status;
void *user_data; void *user_data;
uint16_t conn_handle; u16_t conn_handle;
uint8_t type; u8_t type;
}; };
void on_nble_gattc_discover_rsp(const struct nble_gattc_discover_rsp *rsp, void on_nble_gattc_discover_rsp(const struct nble_gattc_discover_rsp *rsp,
const uint8_t *data, uint8_t len); const u8_t *data, u8_t len);
struct nble_gattc_read_req { struct nble_gattc_read_req {
void *user_data; void *user_data;
uint16_t conn_handle; u16_t conn_handle;
uint16_t handle; u16_t handle;
uint16_t offset; u16_t offset;
}; };
void nble_gattc_read_req(const struct nble_gattc_read_req *req); void nble_gattc_read_req(const struct nble_gattc_read_req *req);
@ -214,28 +214,28 @@ void nble_gattc_read_req(const struct nble_gattc_read_req *req);
struct nble_gattc_read_rsp { struct nble_gattc_read_rsp {
int status; int status;
void *user_data; void *user_data;
uint16_t conn_handle; u16_t conn_handle;
uint16_t handle; u16_t handle;
uint16_t offset; u16_t offset;
}; };
void on_nble_gattc_read_rsp(const struct nble_gattc_read_rsp *rsp, void on_nble_gattc_read_rsp(const struct nble_gattc_read_rsp *rsp,
uint8_t *data, uint8_t len); u8_t *data, u8_t len);
struct nble_gattc_read_multi_req { struct nble_gattc_read_multi_req {
void *user_data; void *user_data;
uint16_t conn_handle; u16_t conn_handle;
}; };
void nble_gattc_read_multi_req(const struct nble_gattc_read_multi_req *req, void nble_gattc_read_multi_req(const struct nble_gattc_read_multi_req *req,
const uint16_t *handles, uint16_t len); const u16_t *handles, u16_t len);
void on_nble_gattc_read_multi_rsp(const struct nble_gattc_read_rsp *rsp, void on_nble_gattc_read_multi_rsp(const struct nble_gattc_read_rsp *rsp,
uint8_t *data, uint8_t len); u8_t *data, u8_t len);
struct nble_gattc_write_param; struct nble_gattc_write_param;
typedef void (*nble_att_func_t)(struct bt_conn *conn, uint8_t err, typedef void (*nble_att_func_t)(struct bt_conn *conn, u8_t err,
const struct nble_gattc_write_param *par); const struct nble_gattc_write_param *par);
struct nble_gattc_write_param { struct nble_gattc_write_param {
@ -246,21 +246,21 @@ struct nble_gattc_write_param {
}; };
struct nble_gattc_write_req { struct nble_gattc_write_req {
uint16_t conn_handle; u16_t conn_handle;
uint16_t handle; u16_t handle;
uint16_t offset; u16_t offset;
/* different than 0 if response required */ /* different than 0 if response required */
uint8_t with_resp; u8_t with_resp;
struct nble_gattc_write_param wr_params; struct nble_gattc_write_param wr_params;
}; };
void nble_gattc_write_req(const struct nble_gattc_write_req *req, void nble_gattc_write_req(const struct nble_gattc_write_req *req,
const uint8_t *data, uint16_t len); const u8_t *data, u16_t len);
struct nble_gattc_write_rsp { struct nble_gattc_write_rsp {
int status; int status;
uint16_t conn_handle; u16_t conn_handle;
uint16_t handle; u16_t handle;
struct nble_gattc_write_param wr_params; struct nble_gattc_write_param wr_params;
}; };
@ -276,11 +276,11 @@ enum NBLE_GATTC_EVT {
struct nble_gattc_value_evt { struct nble_gattc_value_evt {
int status; int status;
uint16_t conn_handle; u16_t conn_handle;
uint16_t handle; u16_t handle;
/* see NBLE_GATTC_VALUE_EVT */ /* see NBLE_GATTC_VALUE_EVT */
uint8_t type; u8_t type;
}; };
void on_nble_gattc_value_evt(const struct nble_gattc_value_evt *evt, void on_nble_gattc_value_evt(const struct nble_gattc_value_evt *evt,
uint8_t *data, uint8_t len); u8_t *data, u8_t len);

View file

@ -31,7 +31,7 @@ enum {
* @return Pointer to the allocated buffer, the allocation shall not fail, * @return Pointer to the allocated buffer, the allocation shall not fail,
* error must be handled internally * error must be handled internally
*/ */
struct net_buf *rpc_alloc_cb(uint16_t length); struct net_buf *rpc_alloc_cb(u16_t length);
/** /**
* RPC transmission function, must be implemented by the user of the RPC. * RPC transmission function, must be implemented by the user of the RPC.
@ -48,7 +48,7 @@ void rpc_transmit_cb(struct net_buf *buf);
* *
* @param version Local version to send to the peer. * @param version Local version to send to the peer.
*/ */
void rpc_init(uint32_t version); void rpc_init(u32_t version);
/** /**
* RPC initialization packet reception function, can optionally be implemented * RPC initialization packet reception function, can optionally be implemented
@ -61,13 +61,13 @@ void rpc_init(uint32_t version);
* @param version Peer advertised version. * @param version Peer advertised version.
* @param compatible True if the peer runs a compatible RPC framework. * @param compatible True if the peer runs a compatible RPC framework.
*/ */
void rpc_init_cb(uint32_t version, bool compatible); void rpc_init_cb(u32_t version, bool compatible);
/** RPC serialize hash number generation. /** RPC serialize hash number generation.
* *
* @return The unique identifier of the RPC deserialization. * @return The unique identifier of the RPC deserialization.
*/ */
uint32_t rpc_serialize_hash(void); u32_t rpc_serialize_hash(void);
/** /**
* RPC serialization function to serialize a function that does not require any * RPC serialization function to serialize a function that does not require any
@ -75,7 +75,7 @@ uint32_t rpc_serialize_hash(void);
* *
* @param fn_index Index of the function * @param fn_index Index of the function
*/ */
void rpc_serialize_none(uint8_t fn_index); void rpc_serialize_none(u8_t fn_index);
/** /**
* RPC serialization function to serialize a function that expects a structure * RPC serialization function to serialize a function that expects a structure
@ -85,8 +85,8 @@ void rpc_serialize_none(uint8_t fn_index);
* @param struct_data Pointer to the structure to serialize * @param struct_data Pointer to the structure to serialize
* @param struct_length Length of the structure to serialize * @param struct_length Length of the structure to serialize
*/ */
void rpc_serialize_s(uint8_t fn_index, const void *struct_data, void rpc_serialize_s(u8_t fn_index, const void *struct_data,
uint8_t struct_length); u8_t struct_length);
/** /**
* RPC serialization function to serialize a function that expects a structure * RPC serialization function to serialize a function that expects a structure
@ -97,8 +97,8 @@ void rpc_serialize_s(uint8_t fn_index, const void *struct_data,
* @param struct_length Length of the structure to serialize * @param struct_length Length of the structure to serialize
* @param p_priv Pointer to serialize * @param p_priv Pointer to serialize
*/ */
void rpc_serialize_s_p(uint8_t fn_index, const void *struct_data, void rpc_serialize_s_p(u8_t fn_index, const void *struct_data,
uint8_t struct_length, void *p_priv); u8_t struct_length, void *p_priv);
/** /**
* RPC serialization function to serialize a function that expects a pointer as * RPC serialization function to serialize a function that expects a pointer as
@ -107,7 +107,7 @@ void rpc_serialize_s_p(uint8_t fn_index, const void *struct_data,
* @param fn_index Index of the function * @param fn_index Index of the function
* @param p_priv Pointer to serialize * @param p_priv Pointer to serialize
*/ */
void rpc_serialize_p(uint8_t fn_index, void *p_priv); void rpc_serialize_p(u8_t fn_index, void *p_priv);
/** /**
* RPC serialization function to serialize a function that expects a structure * RPC serialization function to serialize a function that expects a structure
@ -119,9 +119,9 @@ void rpc_serialize_p(uint8_t fn_index, void *p_priv);
* @param vbuf Pointer to the buffer to serialize * @param vbuf Pointer to the buffer to serialize
* @param vbuf_length Length of the buffer to serialize * @param vbuf_length Length of the buffer to serialize
*/ */
void rpc_serialize_s_b(uint8_t fn_index, const void *struct_data, void rpc_serialize_s_b(u8_t fn_index, const void *struct_data,
uint8_t struct_length, const void *vbuf, u8_t struct_length, const void *vbuf,
uint16_t vbuf_length); u16_t vbuf_length);
/** /**
* RPC serialization function to serialize a function that expects a structure * RPC serialization function to serialize a function that expects a structure
@ -134,9 +134,9 @@ void rpc_serialize_s_b(uint8_t fn_index, const void *struct_data,
* @param vbuf2_length Length of the buffer2 to serialize * @param vbuf2_length Length of the buffer2 to serialize
* @param p_priv Pointer to serialize * @param p_priv Pointer to serialize
*/ */
void rpc_serialize_b_b_p(uint8_t fn_index, const void *vbuf1, void rpc_serialize_b_b_p(u8_t fn_index, const void *vbuf1,
uint16_t vbuf1_length, const void *vbuf2, u16_t vbuf1_length, const void *vbuf2,
uint16_t vbuf2_length, void *p_priv); u16_t vbuf2_length, void *p_priv);
/** /**
* RPC serialization function to serialize a function that expects a structure * RPC serialization function to serialize a function that expects a structure
@ -149,9 +149,9 @@ void rpc_serialize_b_b_p(uint8_t fn_index, const void *vbuf1,
* @param vbuf_length Length of the buffer to serialize * @param vbuf_length Length of the buffer to serialize
* @param p_priv Pointer to serialize * @param p_priv Pointer to serialize
*/ */
void rpc_serialize_s_b_p(uint8_t fn_index, const void *struct_data, void rpc_serialize_s_b_p(u8_t fn_index, const void *struct_data,
uint8_t struct_length, const void *vbuf, u8_t struct_length, const void *vbuf,
uint16_t vbuf_length, void *p_priv); u16_t vbuf_length, void *p_priv);
/** /**
* RPC serialization function to serialize a function that expects a structure * RPC serialization function to serialize a function that expects a structure
@ -166,10 +166,10 @@ void rpc_serialize_s_b_p(uint8_t fn_index, const void *struct_data,
* @param vbuf2_length2 Length of the buffer2 to serialize * @param vbuf2_length2 Length of the buffer2 to serialize
* @param p_priv Pointer to serialize * @param p_priv Pointer to serialize
*/ */
void rpc_serialize_s_b_b_p(uint8_t fn_index, const void *struct_data, void rpc_serialize_s_b_b_p(u8_t fn_index, const void *struct_data,
uint8_t struct_length, const void *vbuf1, u8_t struct_length, const void *vbuf1,
uint16_t vbuf1_length, const void *vbuf2, u16_t vbuf1_length, const void *vbuf2,
uint16_t vbuf2_length, void *p_priv); u16_t vbuf2_length, void *p_priv);
/** /**
* RPC deserialization function, shall be invoked when a buffer is received * RPC deserialization function, shall be invoked when a buffer is received
@ -183,5 +183,5 @@ void rpc_deserialize(struct net_buf *buf);
* *
* @return The unique identifier of the RPC deserialization. * @return The unique identifier of the RPC deserialization.
*/ */
uint32_t rpc_deserialize_hash(void); u32_t rpc_deserialize_hash(void);

View file

@ -90,11 +90,11 @@ LIST_FN_SIG_S_B_B_P
#define FN_SIG_S_B_B_P(__fn, __s, __type1, __length1, __type2, \ #define FN_SIG_S_B_B_P(__fn, __s, __type1, __length1, __type2, \
__length2, __type3) sizeof(*((__s)0)), __length2, __type3) sizeof(*((__s)0)),
static uint8_t m_size_s[] = { LIST_FN_SIG_S }; static u8_t m_size_s[] = { LIST_FN_SIG_S };
static uint8_t m_size_s_b[] = { LIST_FN_SIG_S_B }; static u8_t m_size_s_b[] = { LIST_FN_SIG_S_B };
static uint8_t m_size_s_p[] = { LIST_FN_SIG_S_P }; static u8_t m_size_s_p[] = { LIST_FN_SIG_S_P };
static uint8_t m_size_s_b_p[] = { LIST_FN_SIG_S_B_P }; static u8_t m_size_s_b_p[] = { LIST_FN_SIG_S_B_P };
static uint8_t m_size_s_b_b_p[] = { LIST_FN_SIG_S_B_B_P }; static u8_t m_size_s_b_b_p[] = { LIST_FN_SIG_S_B_B_P };
#undef FN_SIG_NONE #undef FN_SIG_NONE
#undef FN_SIG_S #undef FN_SIG_S
@ -156,16 +156,16 @@ static void (*m_fct_none[])(void) = { LIST_FN_SIG_NONE };
static void (*m_fct_s[])(void *structure) = { LIST_FN_SIG_S }; static void (*m_fct_s[])(void *structure) = { LIST_FN_SIG_S };
static void (*m_fct_p[])(void *pointer) = { LIST_FN_SIG_P }; static void (*m_fct_p[])(void *pointer) = { LIST_FN_SIG_P };
static void (*m_fct_s_b[])(void *structure, void *buffer, static void (*m_fct_s_b[])(void *structure, void *buffer,
uint8_t length) = { LIST_FN_SIG_S_B }; u8_t length) = { LIST_FN_SIG_S_B };
static void (*m_fct_b_b_p[])(void *buffer1, uint8_t length1, static void (*m_fct_b_b_p[])(void *buffer1, u8_t length1,
void *buffer2, uint8_t length2, void *buffer2, u8_t length2,
void *pointer) = { LIST_FN_SIG_B_B_P }; void *pointer) = { LIST_FN_SIG_B_B_P };
static void (*m_fct_s_p[])(void *structure, static void (*m_fct_s_p[])(void *structure,
void *pointer) = { LIST_FN_SIG_S_P }; void *pointer) = { LIST_FN_SIG_S_P };
static void (*m_fct_s_b_p[])(void *structure, void *buffer, uint8_t length, static void (*m_fct_s_b_p[])(void *structure, void *buffer, u8_t length,
void *pointer) = { LIST_FN_SIG_S_B_P }; void *pointer) = { LIST_FN_SIG_S_B_P };
static void (*m_fct_s_b_b_p[])(void *structure, void *buffer1, uint8_t length1, static void (*m_fct_s_b_b_p[])(void *structure, void *buffer1, u8_t length1,
void *buffer2, uint8_t length2, void *buffer2, u8_t length2,
void *pointer) = { LIST_FN_SIG_S_B_B_P }; void *pointer) = { LIST_FN_SIG_S_B_B_P };
/* Build debug table to help development with this "robust" macro stuff */ /* Build debug table to help development with this "robust" macro stuff */
@ -263,9 +263,9 @@ static char *debug_func_s_b_b_p[] = { LIST_FN_SIG_S_B_B_P};
hash = DJB2_HASH(hash, sizeof(*((__s)0))); \ hash = DJB2_HASH(hash, sizeof(*((__s)0))); \
} while (0); } while (0);
uint32_t rpc_deserialize_hash(void) u32_t rpc_deserialize_hash(void)
{ {
uint32_t hash = 5381; u32_t hash = 5381;
LIST_FN_SIG_NONE; LIST_FN_SIG_NONE;
LIST_FN_SIG_S; LIST_FN_SIG_S;
@ -287,18 +287,18 @@ static void panic(int err)
} }
} }
static void deserialize_struct(struct net_buf *buf, const uint8_t **struct_ptr, static void deserialize_struct(struct net_buf *buf, const u8_t **struct_ptr,
uint8_t *struct_length) u8_t *struct_length)
{ {
*struct_length = net_buf_pull_u8(buf); *struct_length = net_buf_pull_u8(buf);
*struct_ptr = buf->data; *struct_ptr = buf->data;
net_buf_pull(buf, *struct_length); net_buf_pull(buf, *struct_length);
} }
static void deserialize_buf(struct net_buf *buf, const uint8_t **buf_ptr, static void deserialize_buf(struct net_buf *buf, const u8_t **buf_ptr,
uint16_t *buf_len) u16_t *buf_len)
{ {
uint8_t b; u8_t b;
/* Get the current byte */ /* Get the current byte */
b = net_buf_pull_u8(buf); b = net_buf_pull_u8(buf);
@ -306,7 +306,7 @@ static void deserialize_buf(struct net_buf *buf, const uint8_t **buf_ptr,
if (b & 0x80) { if (b & 0x80) {
/* Get the current byte */ /* Get the current byte */
b = net_buf_pull_u8(buf); b = net_buf_pull_u8(buf);
*buf_len += (uint16_t)b << 7; *buf_len += (u16_t)b << 7;
} }
/* Return the values */ /* Return the values */
@ -321,7 +321,7 @@ static void deserialize_ptr(struct net_buf *buf, uintptr_t *priv)
net_buf_pull(buf, sizeof(*priv)); net_buf_pull(buf, sizeof(*priv));
} }
static void deserialize_none(uint8_t fn_index, struct net_buf *buf) static void deserialize_none(u8_t fn_index, struct net_buf *buf)
{ {
(void)buf; (void)buf;
@ -332,10 +332,10 @@ static void deserialize_none(uint8_t fn_index, struct net_buf *buf)
m_fct_none[fn_index](); m_fct_none[fn_index]();
} }
static void deserialize_s(uint8_t fn_index, struct net_buf *buf) static void deserialize_s(u8_t fn_index, struct net_buf *buf)
{ {
const uint8_t *struct_ptr; const u8_t *struct_ptr;
uint8_t struct_length; u8_t struct_length;
deserialize_struct(buf, &struct_ptr, &struct_length); deserialize_struct(buf, &struct_ptr, &struct_length);
@ -352,7 +352,7 @@ static void deserialize_s(uint8_t fn_index, struct net_buf *buf)
} }
} }
static void deserialize_p(uint8_t fn_index, struct net_buf *buf) static void deserialize_p(u8_t fn_index, struct net_buf *buf)
{ {
uintptr_t priv; uintptr_t priv;
@ -365,12 +365,12 @@ static void deserialize_p(uint8_t fn_index, struct net_buf *buf)
m_fct_p[fn_index]((void *)priv); m_fct_p[fn_index]((void *)priv);
} }
static void deserialize_s_b(uint8_t fn_index, struct net_buf *buf) static void deserialize_s_b(u8_t fn_index, struct net_buf *buf)
{ {
const uint8_t *p_struct_data; const u8_t *p_struct_data;
uint8_t struct_length; u8_t struct_length;
const uint8_t *p_vbuf; const u8_t *p_vbuf;
uint16_t vbuf_length; u16_t vbuf_length;
deserialize_struct(buf, &p_struct_data, &struct_length); deserialize_struct(buf, &p_struct_data, &struct_length);
deserialize_buf(buf, &p_vbuf, &vbuf_length); deserialize_buf(buf, &p_vbuf, &vbuf_length);
@ -396,12 +396,12 @@ static void deserialize_s_b(uint8_t fn_index, struct net_buf *buf)
} }
} }
static void deserialize_b_b_p(uint8_t fn_index, struct net_buf *buf) static void deserialize_b_b_p(u8_t fn_index, struct net_buf *buf)
{ {
const uint8_t *p_vbuf1; const u8_t *p_vbuf1;
uint16_t vbuf1_length; u16_t vbuf1_length;
const uint8_t *p_vbuf2; const u8_t *p_vbuf2;
uint16_t vbuf2_length; u16_t vbuf2_length;
uintptr_t priv; uintptr_t priv;
deserialize_buf(buf, &p_vbuf1, &vbuf1_length); deserialize_buf(buf, &p_vbuf1, &vbuf1_length);
@ -432,10 +432,10 @@ static void deserialize_b_b_p(uint8_t fn_index, struct net_buf *buf)
} }
} }
static void deserialize_s_p(uint8_t fn_index, struct net_buf *buf) static void deserialize_s_p(u8_t fn_index, struct net_buf *buf)
{ {
const uint8_t *p_struct_data; const u8_t *p_struct_data;
uint8_t struct_length; u8_t struct_length;
uintptr_t priv; uintptr_t priv;
deserialize_struct(buf, &p_struct_data, &struct_length); deserialize_struct(buf, &p_struct_data, &struct_length);
@ -454,12 +454,12 @@ static void deserialize_s_p(uint8_t fn_index, struct net_buf *buf)
} }
} }
static void deserialize_s_b_p(uint8_t fn_index, struct net_buf *buf) static void deserialize_s_b_p(u8_t fn_index, struct net_buf *buf)
{ {
const uint8_t *p_struct_data; const u8_t *p_struct_data;
uint8_t struct_length; u8_t struct_length;
const uint8_t *p_vbuf; const u8_t *p_vbuf;
uint16_t vbuf_length; u16_t vbuf_length;
uintptr_t priv; uintptr_t priv;
deserialize_struct(buf, &p_struct_data, &struct_length); deserialize_struct(buf, &p_struct_data, &struct_length);
@ -488,14 +488,14 @@ static void deserialize_s_b_p(uint8_t fn_index, struct net_buf *buf)
} }
} }
static void deserialize_s_b_b_p(uint8_t fn_index, struct net_buf *buf) static void deserialize_s_b_b_p(u8_t fn_index, struct net_buf *buf)
{ {
const uint8_t *p_struct_data; const u8_t *p_struct_data;
uint8_t struct_length; u8_t struct_length;
const uint8_t *p_vbuf1; const u8_t *p_vbuf1;
uint16_t vbuf1_length; u16_t vbuf1_length;
const uint8_t *p_vbuf2; const u8_t *p_vbuf2;
uint16_t vbuf2_length; u16_t vbuf2_length;
uintptr_t priv; uintptr_t priv;
deserialize_struct(buf, &p_struct_data, &struct_length); deserialize_struct(buf, &p_struct_data, &struct_length);
@ -533,14 +533,14 @@ static void deserialize_s_b_b_p(uint8_t fn_index, struct net_buf *buf)
} }
} }
static void deserialize_control(uint8_t fn_index, struct net_buf *buf) static void deserialize_control(u8_t fn_index, struct net_buf *buf)
{ {
const uint8_t *p_struct_data; const u8_t *p_struct_data;
uint8_t struct_length; u8_t struct_length;
struct { struct {
uint32_t version; u32_t version;
uint32_t ser_hash; u32_t ser_hash;
uint32_t des_hash; u32_t des_hash;
} struct_data; } struct_data;
switch (fn_index) { switch (fn_index) {
@ -566,8 +566,8 @@ static void deserialize_control(uint8_t fn_index, struct net_buf *buf)
void rpc_deserialize(struct net_buf *buf) void rpc_deserialize(struct net_buf *buf)
{ {
uint8_t fn_index; u8_t fn_index;
uint8_t sig_type; u8_t sig_type;
sig_type = buf->data[0]; sig_type = buf->data[0];
fn_index = buf->data[1]; fn_index = buf->data[1];
@ -633,6 +633,6 @@ void rpc_deserialize(struct net_buf *buf)
} }
__weak __weak
void rpc_init_cb(uint32_t version, bool compatible) void rpc_init_cb(u32_t version, bool compatible)
{ {
} }

View file

@ -57,28 +57,28 @@
#define LIST_FN_SIG_S_B \ #define LIST_FN_SIG_S_B \
FN_SIG_S_B(nble_gatts_register_req, \ FN_SIG_S_B(nble_gatts_register_req, \
const struct nble_gatts_register_req *, \ const struct nble_gatts_register_req *, \
uint8_t *, uint16_t) \ u8_t *, u16_t) \
FN_SIG_S_B(nble_gatts_notify_req, \ FN_SIG_S_B(nble_gatts_notify_req, \
const struct nble_gatts_notify_req *, \ const struct nble_gatts_notify_req *, \
const uint8_t *, uint16_t) \ const u8_t *, u16_t) \
FN_SIG_S_B(nble_gatts_indicate_req, \ FN_SIG_S_B(nble_gatts_indicate_req, \
const struct nble_gatts_indicate_req *, \ const struct nble_gatts_indicate_req *, \
const uint8_t *, uint8_t) \ const u8_t *, u8_t) \
FN_SIG_S_B(nble_gatts_read_reply_req, \ FN_SIG_S_B(nble_gatts_read_reply_req, \
const struct nble_gatts_read_reply_req *, \ const struct nble_gatts_read_reply_req *, \
uint8_t *, uint16_t) \ u8_t *, u16_t) \
FN_SIG_S_B(nble_gattc_write_req, \ FN_SIG_S_B(nble_gattc_write_req, \
const struct nble_gattc_write_req *, \ const struct nble_gattc_write_req *, \
const uint8_t *, uint16_t) \ const u8_t *, u16_t) \
FN_SIG_S_B(nble_gattc_read_multi_req, \ FN_SIG_S_B(nble_gattc_read_multi_req, \
const struct nble_gattc_read_multi_req *, \ const struct nble_gattc_read_multi_req *, \
const uint16_t *, uint16_t) \ const u16_t *, u16_t) \
FN_SIG_S_B(nble_uart_test_req, \ FN_SIG_S_B(nble_uart_test_req, \
const struct nble_uart_test_req *, \ const struct nble_uart_test_req *, \
const uint8_t *, uint8_t) \ const u8_t *, u8_t) \
FN_SIG_S_B(nble_gatts_write_reply_req, \ FN_SIG_S_B(nble_gatts_write_reply_req, \
const struct nble_gatts_write_reply_req *, \ const struct nble_gatts_write_reply_req *, \
const uint8_t *, uint8_t) const u8_t *, u8_t)
#define LIST_FN_SIG_B_B_P #define LIST_FN_SIG_B_B_P

View file

@ -73,35 +73,35 @@
#define LIST_FN_SIG_S_B \ #define LIST_FN_SIG_S_B \
FN_SIG_S_B(nble_log, const struct nble_log_s *, char *, \ FN_SIG_S_B(nble_log, const struct nble_log_s *, char *, \
uint8_t) \ u8_t) \
FN_SIG_S_B(on_nble_gattc_value_evt, \ FN_SIG_S_B(on_nble_gattc_value_evt, \
const struct nble_gattc_value_evt *, \ const struct nble_gattc_value_evt *, \
uint8_t *, uint8_t) \ u8_t *, u8_t) \
FN_SIG_S_B(on_nble_gatts_write_evt, \ FN_SIG_S_B(on_nble_gatts_write_evt, \
const struct nble_gatts_write_evt *, \ const struct nble_gatts_write_evt *, \
const uint8_t *, uint8_t) \ const u8_t *, u8_t) \
FN_SIG_S_B(on_nble_gatts_register_rsp, \ FN_SIG_S_B(on_nble_gatts_register_rsp, \
const struct nble_gatts_register_rsp *, \ const struct nble_gatts_register_rsp *, \
const struct nble_gatt_attr_handles *, \ const struct nble_gatt_attr_handles *, \
uint8_t) \ u8_t) \
FN_SIG_S_B(on_nble_gattc_discover_rsp, \ FN_SIG_S_B(on_nble_gattc_discover_rsp, \
const struct nble_gattc_discover_rsp *, \ const struct nble_gattc_discover_rsp *, \
const uint8_t *, uint8_t) \ const u8_t *, u8_t) \
FN_SIG_S_B(on_nble_gap_adv_report_evt, \ FN_SIG_S_B(on_nble_gap_adv_report_evt, \
const struct nble_gap_adv_report_evt *, \ const struct nble_gap_adv_report_evt *, \
const uint8_t *, uint8_t) \ const u8_t *, u8_t) \
FN_SIG_S_B(on_nble_sm_bond_info_rsp, \ FN_SIG_S_B(on_nble_sm_bond_info_rsp, \
const struct nble_sm_bond_info_rsp *, \ const struct nble_sm_bond_info_rsp *, \
const bt_addr_le_t *, uint16_t) \ const bt_addr_le_t *, u16_t) \
FN_SIG_S_B(on_nble_gattc_read_rsp, \ FN_SIG_S_B(on_nble_gattc_read_rsp, \
const struct nble_gattc_read_rsp *, \ const struct nble_gattc_read_rsp *, \
uint8_t *, uint8_t) \ u8_t *, u8_t) \
FN_SIG_S_B(on_nble_gattc_read_multi_rsp, \ FN_SIG_S_B(on_nble_gattc_read_multi_rsp, \
const struct nble_gattc_read_rsp *, \ const struct nble_gattc_read_rsp *, \
uint8_t *, uint8_t) \ u8_t *, u8_t) \
FN_SIG_S_B(on_nble_uart_test_evt, \ FN_SIG_S_B(on_nble_uart_test_evt, \
const struct nble_uart_test_evt *, \ const struct nble_uart_test_evt *, \
const uint8_t *, uint8_t) const u8_t *, u8_t)
#define LIST_FN_SIG_B_B_P #define LIST_FN_SIG_B_B_P

View file

@ -177,9 +177,9 @@ LIST_FN_SIG_S_B_B_P
hash = DJB2_HASH(hash, sizeof(*((__s)0))); \ hash = DJB2_HASH(hash, sizeof(*((__s)0))); \
} while (0); } while (0);
uint32_t rpc_serialize_hash(void) u32_t rpc_serialize_hash(void)
{ {
uint32_t hash = 5381; u32_t hash = 5381;
LIST_FN_SIG_NONE; LIST_FN_SIG_NONE;
LIST_FN_SIG_S; LIST_FN_SIG_S;
@ -202,19 +202,19 @@ static void _send(struct net_buf *buf)
rpc_transmit_cb(buf); rpc_transmit_cb(buf);
} }
static uint16_t encoded_structlen(uint8_t structlen) static u16_t encoded_structlen(u8_t structlen)
{ {
return 1 + structlen; return 1 + structlen;
} }
static void serialize_struct(struct net_buf *buf, const uint8_t *struct_data, static void serialize_struct(struct net_buf *buf, const u8_t *struct_data,
uint8_t struct_length) u8_t struct_length)
{ {
net_buf_add_u8(buf, struct_length); net_buf_add_u8(buf, struct_length);
net_buf_add_mem(buf, struct_data, struct_length); net_buf_add_mem(buf, struct_data, struct_length);
} }
static uint16_t encoded_buflen(const uint8_t *buf, uint16_t buflen) static u16_t encoded_buflen(const u8_t *buf, u16_t buflen)
{ {
if (!buf) { if (!buf) {
return 1; return 1;
@ -227,11 +227,11 @@ static uint16_t encoded_buflen(const uint8_t *buf, uint16_t buflen)
} }
} }
static void serialize_buf(struct net_buf *buf, const uint8_t *data, static void serialize_buf(struct net_buf *buf, const u8_t *data,
uint16_t len) u16_t len)
{ {
uint16_t varint; u16_t varint;
uint8_t *p; u8_t *p;
if (!data) { if (!data) {
len = 0; len = 0;
@ -255,7 +255,7 @@ static void serialize_p(struct net_buf *buf, void *ptr)
net_buf_add_mem(buf, &val, sizeof(val)); net_buf_add_mem(buf, &val, sizeof(val));
} }
void rpc_serialize_none(uint8_t fn_index) void rpc_serialize_none(u8_t fn_index)
{ {
struct net_buf *buf; struct net_buf *buf;
@ -267,8 +267,8 @@ void rpc_serialize_none(uint8_t fn_index)
_send(buf); _send(buf);
} }
void rpc_serialize_s(uint8_t fn_index, const void *struct_data, void rpc_serialize_s(u8_t fn_index, const void *struct_data,
uint8_t struct_length) u8_t struct_length)
{ {
struct net_buf *buf; struct net_buf *buf;
@ -283,7 +283,7 @@ void rpc_serialize_s(uint8_t fn_index, const void *struct_data,
_send(buf); _send(buf);
} }
void rpc_serialize_p(uint8_t fn_index, void *priv) void rpc_serialize_p(u8_t fn_index, void *priv)
{ {
struct net_buf *buf; struct net_buf *buf;
@ -296,9 +296,9 @@ void rpc_serialize_p(uint8_t fn_index, void *priv)
_send(buf); _send(buf);
} }
void rpc_serialize_s_b(uint8_t fn_index, const void *struct_data, void rpc_serialize_s_b(u8_t fn_index, const void *struct_data,
uint8_t struct_length, const void *vbuf, u8_t struct_length, const void *vbuf,
uint16_t vbuf_length) u16_t vbuf_length)
{ {
struct net_buf *buf; struct net_buf *buf;
@ -315,9 +315,9 @@ void rpc_serialize_s_b(uint8_t fn_index, const void *struct_data,
_send(buf); _send(buf);
} }
void rpc_serialize_b_b_p(uint8_t fn_index, const void *vbuf1, void rpc_serialize_b_b_p(u8_t fn_index, const void *vbuf1,
uint16_t vbuf1_length, const void *vbuf2, u16_t vbuf1_length, const void *vbuf2,
uint16_t vbuf2_length, void *priv) u16_t vbuf2_length, void *priv)
{ {
struct net_buf *buf; struct net_buf *buf;
@ -335,8 +335,8 @@ void rpc_serialize_b_b_p(uint8_t fn_index, const void *vbuf1,
_send(buf); _send(buf);
} }
void rpc_serialize_s_p(uint8_t fn_index, const void *struct_data, void rpc_serialize_s_p(u8_t fn_index, const void *struct_data,
uint8_t struct_length, void *priv) u8_t struct_length, void *priv)
{ {
struct net_buf *buf; struct net_buf *buf;
@ -352,9 +352,9 @@ void rpc_serialize_s_p(uint8_t fn_index, const void *struct_data,
_send(buf); _send(buf);
} }
void rpc_serialize_s_b_p(uint8_t fn_index, const void *struct_data, void rpc_serialize_s_b_p(u8_t fn_index, const void *struct_data,
uint8_t struct_length, const void *vbuf, u8_t struct_length, const void *vbuf,
uint16_t vbuf_length, void *priv) u16_t vbuf_length, void *priv)
{ {
struct net_buf *buf; struct net_buf *buf;
@ -372,10 +372,10 @@ void rpc_serialize_s_b_p(uint8_t fn_index, const void *struct_data,
_send(buf); _send(buf);
} }
void rpc_serialize_s_b_b_p(uint8_t fn_index, const void *struct_data, void rpc_serialize_s_b_b_p(u8_t fn_index, const void *struct_data,
uint8_t struct_length, const void *vbuf1, u8_t struct_length, const void *vbuf1,
uint16_t vbuf1_length, const void *vbuf2, u16_t vbuf1_length, const void *vbuf2,
uint16_t vbuf2_length, void *priv) u16_t vbuf2_length, void *priv)
{ {
struct net_buf *buf; struct net_buf *buf;
@ -395,13 +395,13 @@ void rpc_serialize_s_b_b_p(uint8_t fn_index, const void *struct_data,
_send(buf); _send(buf);
} }
void rpc_init(uint32_t version) void rpc_init(u32_t version)
{ {
struct net_buf *buf; struct net_buf *buf;
struct { struct {
uint32_t version; u32_t version;
uint32_t ser_hash; u32_t ser_hash;
uint32_t des_hash; u32_t des_hash;
} struct_data; } struct_data;
struct_data.version = version; struct_data.version = version;
@ -412,6 +412,6 @@ void rpc_init(uint32_t version)
net_buf_add_u8(buf, SIG_TYPE_CONTROL); net_buf_add_u8(buf, SIG_TYPE_CONTROL);
net_buf_add_u8(buf, 0); net_buf_add_u8(buf, 0);
serialize_struct(buf, (uint8_t *)&struct_data, sizeof(struct_data)); serialize_struct(buf, (u8_t *)&struct_data, sizeof(struct_data));
_send(buf); _send(buf);
} }

View file

@ -65,7 +65,7 @@ struct bt_smp {
atomic_t flags; atomic_t flags;
/* Type of method used for pairing */ /* Type of method used for pairing */
uint8_t method; u8_t method;
}; };
static struct bt_smp bt_smp_pool[CONFIG_BLUETOOTH_MAX_CONN]; static struct bt_smp bt_smp_pool[CONFIG_BLUETOOTH_MAX_CONN];
@ -121,7 +121,7 @@ void bt_smp_disconnected(struct bt_conn *conn)
} }
/* based on table 2.8 Core Spec 2.3.5.1 Vol. 3 Part H */ /* based on table 2.8 Core Spec 2.3.5.1 Vol. 3 Part H */
static const uint8_t gen_method_legacy[5 /* remote */][5 /* local */] = { static const u8_t gen_method_legacy[5 /* remote */][5 /* local */] = {
{ JUST_WORKS, JUST_WORKS, PASSKEY_INPUT, JUST_WORKS, PASSKEY_INPUT }, { JUST_WORKS, JUST_WORKS, PASSKEY_INPUT, JUST_WORKS, PASSKEY_INPUT },
{ JUST_WORKS, JUST_WORKS, PASSKEY_INPUT, JUST_WORKS, PASSKEY_INPUT }, { JUST_WORKS, JUST_WORKS, PASSKEY_INPUT, JUST_WORKS, PASSKEY_INPUT },
{ PASSKEY_DISPLAY, PASSKEY_DISPLAY, PASSKEY_INPUT, JUST_WORKS, { PASSKEY_DISPLAY, PASSKEY_DISPLAY, PASSKEY_INPUT, JUST_WORKS,
@ -131,7 +131,7 @@ static const uint8_t gen_method_legacy[5 /* remote */][5 /* local */] = {
PASSKEY_ROLE }, PASSKEY_ROLE },
}; };
static uint8_t get_io_capa(void) static u8_t get_io_capa(void)
{ {
if (!nble.auth) { if (!nble.auth) {
return BT_SMP_IO_NO_INPUT_OUTPUT; return BT_SMP_IO_NO_INPUT_OUTPUT;
@ -160,10 +160,10 @@ static uint8_t get_io_capa(void)
return BT_SMP_IO_NO_INPUT_OUTPUT; return BT_SMP_IO_NO_INPUT_OUTPUT;
} }
static uint8_t legacy_get_pair_method(struct bt_smp *smp, uint8_t remote_io) static u8_t legacy_get_pair_method(struct bt_smp *smp, u8_t remote_io)
{ {
uint8_t local_io = get_io_capa(); u8_t local_io = get_io_capa();
uint8_t method; u8_t method;
if (remote_io > BT_SMP_IO_KEYBOARD_DISPLAY) if (remote_io > BT_SMP_IO_KEYBOARD_DISPLAY)
return JUST_WORKS; return JUST_WORKS;
@ -187,7 +187,7 @@ static uint8_t legacy_get_pair_method(struct bt_smp *smp, uint8_t remote_io)
return method; return method;
} }
static uint8_t get_auth(uint8_t auth) static u8_t get_auth(u8_t auth)
{ {
if (get_io_capa() == BT_SMP_IO_NO_INPUT_OUTPUT) { if (get_io_capa() == BT_SMP_IO_NO_INPUT_OUTPUT) {
auth &= ~(BT_SMP_AUTH_MITM); auth &= ~(BT_SMP_AUTH_MITM);
@ -198,7 +198,7 @@ static uint8_t get_auth(uint8_t auth)
return auth; return auth;
} }
static uint8_t legacy_pairing_req(struct bt_smp *smp, static u8_t legacy_pairing_req(struct bt_smp *smp,
const struct nble_sec_param *par) const struct nble_sec_param *par)
{ {
struct nble_sm_pairing_response_req req; struct nble_sm_pairing_response_req req;
@ -490,7 +490,7 @@ static void nble_security_reply(struct bt_conn *conn,
nble_sm_passkey_reply_req(&rsp); nble_sm_passkey_reply_req(&rsp);
} }
static int sm_error(struct bt_conn *conn, uint8_t reason) static int sm_error(struct bt_conn *conn, u8_t reason)
{ {
struct nble_sm_passkey params; struct nble_sm_passkey params;

View file

@ -33,9 +33,9 @@
* @note this structure must be self-aligned and self-packed * @note this structure must be self-aligned and self-packed
*/ */
struct ipc_uart_header { struct ipc_uart_header {
uint16_t len; /**< Length of IPC message. */ u16_t len; /**< Length of IPC message. */
uint8_t channel; /**< Channel number of IPC message. */ u8_t channel; /**< Channel number of IPC message. */
uint8_t src_cpu_id; /**< CPU id of IPC sender. */ u8_t src_cpu_id; /**< CPU id of IPC sender. */
} __packed; } __packed;
/* TODO: check size */ /* TODO: check size */
@ -73,7 +73,7 @@ static void rx_thread(void)
} }
} }
struct net_buf *rpc_alloc_cb(uint16_t length) struct net_buf *rpc_alloc_cb(u16_t length)
{ {
struct net_buf *buf; struct net_buf *buf;
@ -125,7 +125,7 @@ void rpc_transmit_cb(struct net_buf *buf)
static size_t nble_discard(struct device *uart, size_t len) static size_t nble_discard(struct device *uart, size_t len)
{ {
/* FIXME: correct size for nble */ /* FIXME: correct size for nble */
uint8_t buf[33]; u8_t buf[33];
return uart_fifo_read(uart, buf, min(len, sizeof(buf))); return uart_fifo_read(uart, buf, min(len, sizeof(buf)));
} }
@ -138,7 +138,7 @@ static void bt_uart_isr(struct device *unused)
while (uart_irq_update(nble_dev) && uart_irq_is_pending(nble_dev)) { while (uart_irq_update(nble_dev) && uart_irq_is_pending(nble_dev)) {
static struct ipc_uart_header hdr; static struct ipc_uart_header hdr;
static uint8_t hdr_bytes; static u8_t hdr_bytes;
int read; int read;
if (!uart_irq_rx_ready(nble_dev)) { if (!uart_irq_rx_ready(nble_dev)) {
@ -160,7 +160,7 @@ static void bt_uart_isr(struct device *unused)
if (hdr_bytes < sizeof(hdr)) { if (hdr_bytes < sizeof(hdr)) {
/* Get packet type */ /* Get packet type */
hdr_bytes += uart_fifo_read(nble_dev, hdr_bytes += uart_fifo_read(nble_dev,
(uint8_t *)&hdr + hdr_bytes, (u8_t *)&hdr + hdr_bytes,
sizeof(hdr) - hdr_bytes); sizeof(hdr) - hdr_bytes);
if (hdr_bytes < sizeof(hdr)) { if (hdr_bytes < sizeof(hdr)) {
continue; continue;

View file

@ -32,7 +32,7 @@ int nrf51_allow_sleep(void)
int nrf51_init(struct device *dev) int nrf51_init(struct device *dev)
{ {
uint8_t c; u8_t c;
int ret; int ret;
nrf51_gpio = device_get_binding("GPIO_0"); nrf51_gpio = device_get_binding("GPIO_0");

View file

@ -8,7 +8,7 @@
static inline void bt_uart_drain(struct device *dev) static inline void bt_uart_drain(struct device *dev)
{ {
uint8_t c; u8_t c;
while (uart_fifo_read(dev, &c, 1)) { while (uart_fifo_read(dev, &c, 1)) {
continue; continue;

View file

@ -59,11 +59,11 @@ extern "C" {
/** @brief SBC Codec */ /** @brief SBC Codec */
struct bt_a2dp_codec_sbc_params { struct bt_a2dp_codec_sbc_params {
/** First two octets of configuration */ /** First two octets of configuration */
uint8_t config[2]; u8_t config[2];
/** Minimum Bitpool Value */ /** Minimum Bitpool Value */
uint8_t min_bitpool; u8_t min_bitpool;
/** Maximum Bitpool Value */ /** Maximum Bitpool Value */
uint8_t max_bitpool; u8_t max_bitpool;
} __packed; } __packed;
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -38,15 +38,15 @@ enum bt_a2dp_codec_id {
/** @brief Preset for the endpoint */ /** @brief Preset for the endpoint */
struct bt_a2dp_preset { struct bt_a2dp_preset {
/** Length of preset */ /** Length of preset */
uint8_t len; u8_t len;
/** Preset */ /** Preset */
uint8_t preset[0]; u8_t preset[0];
}; };
/** @brief Stream End Point */ /** @brief Stream End Point */
struct bt_a2dp_endpoint { struct bt_a2dp_endpoint {
/** Code ID */ /** Code ID */
uint8_t codec_id; u8_t codec_id;
/** Stream End Point Information */ /** Stream End Point Information */
struct bt_avdtp_seid_lsep info; struct bt_avdtp_seid_lsep info;
/** Pointer to preset codec chosen */ /** Pointer to preset codec chosen */
@ -102,7 +102,7 @@ struct bt_a2dp *bt_a2dp_connect(struct bt_conn *conn);
* @return 0 in case of success and error code in case of error. * @return 0 in case of success and error code in case of error.
*/ */
int bt_a2dp_register_endpoint(struct bt_a2dp_endpoint *endpoint, int bt_a2dp_register_endpoint(struct bt_a2dp_endpoint *endpoint,
uint8_t media_type, uint8_t role); u8_t media_type, u8_t role);
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -41,8 +41,8 @@ extern "C" {
#define BT_ATT_ERR_PROCEDURE_IN_PROGRESS 0xfe #define BT_ATT_ERR_PROCEDURE_IN_PROGRESS 0xfe
#define BT_ATT_ERR_OUT_OF_RANGE 0xff #define BT_ATT_ERR_OUT_OF_RANGE 0xff
typedef void (*bt_att_func_t)(struct bt_conn *conn, uint8_t err, typedef void (*bt_att_func_t)(struct bt_conn *conn, u8_t err,
const void *pdu, uint16_t length, const void *pdu, u16_t length,
void *user_data); void *user_data);
typedef void (*bt_att_destroy_t)(void *user_data); typedef void (*bt_att_destroy_t)(void *user_data);

View file

@ -17,17 +17,17 @@ extern "C" {
/** @brief AVDTP SEID Information */ /** @brief AVDTP SEID Information */
struct bt_avdtp_seid_info { struct bt_avdtp_seid_info {
/** Stream End Point ID */ /** Stream End Point ID */
uint8_t id:6; u8_t id:6;
/** End Point usage status */ /** End Point usage status */
uint8_t inuse:1; u8_t inuse:1;
/** Reserved */ /** Reserved */
uint8_t rfa0:1; u8_t rfa0:1;
/** Media-type of the End Point */ /** Media-type of the End Point */
uint8_t media_type:4; u8_t media_type:4;
/** TSEP of the End Point */ /** TSEP of the End Point */
uint8_t tsep:1; u8_t tsep:1;
/** Reserved */ /** Reserved */
uint8_t rfa1:3; u8_t rfa1:3;
} __packed; } __packed;
/** @brief AVDTP Local SEP*/ /** @brief AVDTP Local SEP*/
@ -43,7 +43,7 @@ struct bt_avdtp_stream {
struct bt_l2cap_br_chan chan; /* Transport Channel*/ struct bt_l2cap_br_chan chan; /* Transport Channel*/
struct bt_avdtp_seid_info lsep; /* Configured Local SEP */ struct bt_avdtp_seid_info lsep; /* Configured Local SEP */
struct bt_avdtp_seid_info rsep; /* Configured Remote SEP*/ struct bt_avdtp_seid_info rsep; /* Configured Remote SEP*/
uint8_t state; /* current state of the stream */ u8_t state; /* current state of the stream */
struct bt_avdtp_stream *next; struct bt_avdtp_stream *next;
}; };

View file

@ -63,9 +63,9 @@ int bt_enable(bt_ready_cb_t cb);
* bt_le_adv_start() function. * bt_le_adv_start() function.
*/ */
struct bt_data { struct bt_data {
uint8_t type; u8_t type;
uint8_t data_len; u8_t data_len;
const uint8_t *data; const u8_t *data;
}; };
/** @brief Helper to declare elements of bt_data arrays /** @brief Helper to declare elements of bt_data arrays
@ -81,7 +81,7 @@ struct bt_data {
{ \ { \
.type = (_type), \ .type = (_type), \
.data_len = (_data_len), \ .data_len = (_data_len), \
.data = (const uint8_t *)(_data), \ .data = (const u8_t *)(_data), \
} }
/** @brief Helper to declare elements of bt_data arrays /** @brief Helper to declare elements of bt_data arrays
@ -93,8 +93,8 @@ struct bt_data {
* @param _bytes Variable number of single-byte parameters * @param _bytes Variable number of single-byte parameters
*/ */
#define BT_DATA_BYTES(_type, _bytes...) \ #define BT_DATA_BYTES(_type, _bytes...) \
BT_DATA(_type, ((uint8_t []) { _bytes }), \ BT_DATA(_type, ((u8_t []) { _bytes }), \
sizeof((uint8_t []) { _bytes })) sizeof((u8_t []) { _bytes }))
/** Advertising options */ /** Advertising options */
enum { enum {
@ -110,13 +110,13 @@ enum {
/** LE Advertising Parameters. */ /** LE Advertising Parameters. */
struct bt_le_adv_param { struct bt_le_adv_param {
/** Bit-field of advertising options */ /** Bit-field of advertising options */
uint8_t options; u8_t options;
/** Minimum Advertising Interval (N * 0.625) */ /** Minimum Advertising Interval (N * 0.625) */
uint16_t interval_min; u16_t interval_min;
/** Maximum Advertising Interval (N * 0.625) */ /** Maximum Advertising Interval (N * 0.625) */
uint16_t interval_max; u16_t interval_max;
/** Optional pre-defined (random) own address. Currently /** Optional pre-defined (random) own address. Currently
* the only permitted use of this is for NRPA with * the only permitted use of this is for NRPA with
@ -181,24 +181,24 @@ int bt_le_adv_stop(void);
* @param adv_type Type of advertising response from advertiser. * @param adv_type Type of advertising response from advertiser.
* @param data Buffer containig advertiser data. * @param data Buffer containig advertiser data.
*/ */
typedef void bt_le_scan_cb_t(const bt_addr_le_t *addr, int8_t rssi, typedef void bt_le_scan_cb_t(const bt_addr_le_t *addr, s8_t rssi,
uint8_t adv_type, struct net_buf_simple *buf); u8_t adv_type, struct net_buf_simple *buf);
/** LE scan parameters */ /** LE scan parameters */
struct bt_le_scan_param { struct bt_le_scan_param {
/** Scan type (BT_HCI_LE_SCAN_ACTIVE or BT_HCI_LE_SCAN_PASSIVE) */ /** Scan type (BT_HCI_LE_SCAN_ACTIVE or BT_HCI_LE_SCAN_PASSIVE) */
uint8_t type; u8_t type;
/** Duplicate filtering (BT_HCI_LE_SCAN_FILTER_DUP_ENABLE or /** Duplicate filtering (BT_HCI_LE_SCAN_FILTER_DUP_ENABLE or
* BT_HCI_LE_SCAN_FILTER_DUP_DISABLE) * BT_HCI_LE_SCAN_FILTER_DUP_DISABLE)
*/ */
uint8_t filter_dup; u8_t filter_dup;
/** Scan interval (N * 0.625 ms) */ /** Scan interval (N * 0.625 ms) */
uint16_t interval; u16_t interval;
/** Scan window (N * 0.625 ms) */ /** Scan window (N * 0.625 ms) */
uint16_t window; u16_t window;
}; };
/** Helper to declare scan parameters inline /** Helper to declare scan parameters inline
@ -278,19 +278,19 @@ int bt_le_oob_get_local(struct bt_le_oob *oob);
/** @brief BR/EDR discovery result structure */ /** @brief BR/EDR discovery result structure */
struct bt_br_discovery_result { struct bt_br_discovery_result {
/** private */ /** private */
uint8_t _priv[4]; u8_t _priv[4];
/** Remote device address */ /** Remote device address */
bt_addr_t addr; bt_addr_t addr;
/** RSSI from inquiry */ /** RSSI from inquiry */
int8_t rssi; s8_t rssi;
/** Class of Device */ /** Class of Device */
uint8_t cod[3]; u8_t cod[3];
/** Extended Inquiry Response */ /** Extended Inquiry Response */
uint8_t eir[240]; u8_t eir[240];
}; };
/** @typedef bt_br_discovery_cb_t /** @typedef bt_br_discovery_cb_t
@ -312,7 +312,7 @@ struct bt_br_discovery_param {
/** Maximum length of the discovery in units of 1.28 seconds. /** Maximum length of the discovery in units of 1.28 seconds.
* Valid range is 0x01 - 0x30. * Valid range is 0x01 - 0x30.
*/ */
uint8_t length; u8_t length;
/** True if limited discovery procedure is to be used. */ /** True if limited discovery procedure is to be used. */
bool limited; bool limited;

View file

@ -50,7 +50,7 @@ enum bt_buf_type {
* K_NO_WAIT and K_FOREVER. * K_NO_WAIT and K_FOREVER.
* @return A new buffer. * @return A new buffer.
*/ */
struct net_buf *bt_buf_get_rx(int32_t timeout); struct net_buf *bt_buf_get_rx(s32_t timeout);
/** Allocate a buffer for an HCI Command Complete/Status Event /** Allocate a buffer for an HCI Command Complete/Status Event
* *
@ -61,7 +61,7 @@ struct net_buf *bt_buf_get_rx(int32_t timeout);
* K_NO_WAIT and K_FOREVER. * K_NO_WAIT and K_FOREVER.
* @return A new buffer. * @return A new buffer.
*/ */
struct net_buf *bt_buf_get_cmd_complete(int32_t timeout); struct net_buf *bt_buf_get_cmd_complete(s32_t timeout);
/** Set the buffer type /** Set the buffer type
* *
@ -70,7 +70,7 @@ struct net_buf *bt_buf_get_cmd_complete(int32_t timeout);
*/ */
static inline void bt_buf_set_type(struct net_buf *buf, enum bt_buf_type type) static inline void bt_buf_set_type(struct net_buf *buf, enum bt_buf_type type)
{ {
*(uint8_t *)net_buf_user_data(buf) = type; *(u8_t *)net_buf_user_data(buf) = type;
} }
/** Get the buffer type /** Get the buffer type
@ -81,7 +81,7 @@ static inline void bt_buf_set_type(struct net_buf *buf, enum bt_buf_type type)
*/ */
static inline enum bt_buf_type bt_buf_get_type(struct net_buf *buf) static inline enum bt_buf_type bt_buf_get_type(struct net_buf *buf)
{ {
return *(uint8_t *)net_buf_user_data(buf); return *(u8_t *)net_buf_user_data(buf);
} }
/** /**

View file

@ -31,10 +31,10 @@ struct bt_conn;
/** Connection parameters for LE connections */ /** Connection parameters for LE connections */
struct bt_le_conn_param { struct bt_le_conn_param {
uint16_t interval_min; u16_t interval_min;
uint16_t interval_max; u16_t interval_max;
uint16_t latency; u16_t latency;
uint16_t timeout; u16_t timeout;
}; };
/** Helper to declare connection parameters inline /** Helper to declare connection parameters inline
@ -113,9 +113,9 @@ enum {
struct bt_conn_le_info { struct bt_conn_le_info {
const bt_addr_le_t *src; /** Source Address */ const bt_addr_le_t *src; /** Source Address */
const bt_addr_le_t *dst; /** Destination Address */ const bt_addr_le_t *dst; /** Destination Address */
uint16_t interval; /** Connection interval */ u16_t interval; /** Connection interval */
uint16_t latency; /** Connection slave latency */ u16_t latency; /** Connection slave latency */
uint16_t timeout; /** Connection supervision timeout */ u16_t timeout; /** Connection supervision timeout */
}; };
/** BR/EDR Connection Info Structure */ /** BR/EDR Connection Info Structure */
@ -138,9 +138,9 @@ enum {
* @param br BR/EDR Connection specific Info * @param br BR/EDR Connection specific Info
*/ */
struct bt_conn_info { struct bt_conn_info {
uint8_t type; u8_t type;
uint8_t role; u8_t role;
union { union {
struct bt_conn_le_info le; struct bt_conn_le_info le;
@ -178,7 +178,7 @@ int bt_conn_le_param_update(struct bt_conn *conn,
* *
* @return Zero on success or (negative) error code on failure. * @return Zero on success or (negative) error code on failure.
*/ */
int bt_conn_disconnect(struct bt_conn *conn, uint8_t reason); int bt_conn_disconnect(struct bt_conn *conn, u8_t reason);
/** @brief Initiate an LE connection to a remote device. /** @brief Initiate an LE connection to a remote device.
* *
@ -276,7 +276,7 @@ int bt_conn_security(struct bt_conn *conn, bt_security_t sec);
* *
* @return Encryption key size. * @return Encryption key size.
*/ */
uint8_t bt_conn_enc_key_size(struct bt_conn *conn); u8_t bt_conn_enc_key_size(struct bt_conn *conn);
/** @brief Connection callback structure. /** @brief Connection callback structure.
* *
@ -298,7 +298,7 @@ struct bt_conn_cb {
* @param conn New connection object. * @param conn New connection object.
* @param err HCI error. Zero for success, non-zero otherwise. * @param err HCI error. Zero for success, non-zero otherwise.
*/ */
void (*connected)(struct bt_conn *conn, uint8_t err); void (*connected)(struct bt_conn *conn, u8_t err);
/** @brief A connection has been disconnected. /** @brief A connection has been disconnected.
* *
@ -308,7 +308,7 @@ struct bt_conn_cb {
* @param conn Connection object. * @param conn Connection object.
* @param reason HCI reason for the disconnection. * @param reason HCI reason for the disconnection.
*/ */
void (*disconnected)(struct bt_conn *conn, uint8_t reason); void (*disconnected)(struct bt_conn *conn, u8_t reason);
/** @brief LE connection parameter update request. /** @brief LE connection parameter update request.
* *
@ -344,8 +344,8 @@ struct bt_conn_cb {
* @param latency Connection latency. * @param latency Connection latency.
* @param timeout Connection supervision timeout. * @param timeout Connection supervision timeout.
*/ */
void (*le_param_updated)(struct bt_conn *conn, uint16_t interval, void (*le_param_updated)(struct bt_conn *conn, u16_t interval,
uint16_t latency, uint16_t timeout); u16_t latency, u16_t timeout);
#if defined(CONFIG_BLUETOOTH_SMP) #if defined(CONFIG_BLUETOOTH_SMP)
/** @brief Remote Identity Address has been resolved. /** @brief Remote Identity Address has been resolved.
* *

View file

@ -49,8 +49,8 @@ int bt_rand(void *buf, size_t len);
* *
* @return Zero on success or error code otherwise. * @return Zero on success or error code otherwise.
*/ */
int bt_encrypt_le(const uint8_t key[16], const uint8_t plaintext[16], int bt_encrypt_le(const u8_t key[16], const u8_t plaintext[16],
uint8_t enc_data[16]); u8_t enc_data[16]);
/** @brief AES encrypt big-endian data. /** @brief AES encrypt big-endian data.
* *
@ -64,8 +64,8 @@ int bt_encrypt_le(const uint8_t key[16], const uint8_t plaintext[16],
* *
* @return Zero on success or error code otherwise. * @return Zero on success or error code otherwise.
*/ */
int bt_encrypt_be(const uint8_t key[16], const uint8_t plaintext[16], int bt_encrypt_be(const u8_t key[16], const u8_t plaintext[16],
uint8_t enc_data[16]); u8_t enc_data[16]);
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -111,8 +111,8 @@ struct bt_gatt_attr {
*/ */
ssize_t (*read)(struct bt_conn *conn, ssize_t (*read)(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const struct bt_gatt_attr *attr,
void *buf, uint16_t len, void *buf, u16_t len,
uint16_t offset); u16_t offset);
/** Attribute write callback /** Attribute write callback
* *
@ -128,15 +128,15 @@ struct bt_gatt_attr {
*/ */
ssize_t (*write)(struct bt_conn *conn, ssize_t (*write)(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const struct bt_gatt_attr *attr,
const void *buf, uint16_t len, const void *buf, u16_t len,
uint16_t offset, uint8_t flags); u16_t offset, u8_t flags);
/** Attribute user data */ /** Attribute user data */
void *user_data; void *user_data;
/** Attribute handle */ /** Attribute handle */
uint16_t handle; u16_t handle;
/** Attribute permissions */ /** Attribute permissions */
uint8_t perm; u8_t perm;
#if defined(CONFIG_BLUETOOTH_GATT_DYNAMIC_DB) #if defined(CONFIG_BLUETOOTH_GATT_DYNAMIC_DB)
sys_snode_t node; sys_snode_t node;
#endif /* CONFIG_BLUETOOTH_GATT_DYNAMIC_DB */ #endif /* CONFIG_BLUETOOTH_GATT_DYNAMIC_DB */
@ -147,7 +147,7 @@ struct bt_gatt_service {
/** Service UUID. */ /** Service UUID. */
const struct bt_uuid *uuid; const struct bt_uuid *uuid;
/** Service end handle. */ /** Service end handle. */
uint16_t end_handle; u16_t end_handle;
}; };
/** @brief Include Attribute Value. */ /** @brief Include Attribute Value. */
@ -155,9 +155,9 @@ struct bt_gatt_include {
/** Service UUID. */ /** Service UUID. */
const struct bt_uuid *uuid; const struct bt_uuid *uuid;
/** Service start handle. */ /** Service start handle. */
uint16_t start_handle; u16_t start_handle;
/** Service end handle. */ /** Service end handle. */
uint16_t end_handle; u16_t end_handle;
}; };
/* Characteristic Properties Bit field values */ /* Characteristic Properties Bit field values */
@ -219,7 +219,7 @@ struct bt_gatt_chrc {
/** Characteristic UUID. */ /** Characteristic UUID. */
const struct bt_uuid *uuid; const struct bt_uuid *uuid;
/** Characteristic properties. */ /** Characteristic properties. */
uint8_t properties; u8_t properties;
}; };
/* Characteristic Extended Properties Bit field values */ /* Characteristic Extended Properties Bit field values */
@ -229,7 +229,7 @@ struct bt_gatt_chrc {
/** @brief Characteristic Extended Properties Attribute Value. */ /** @brief Characteristic Extended Properties Attribute Value. */
struct bt_gatt_cep { struct bt_gatt_cep {
/** Characteristic Extended properties */ /** Characteristic Extended properties */
uint16_t properties; u16_t properties;
}; };
/* Client Characteristic Configuration Values */ /* Client Characteristic Configuration Values */
@ -250,21 +250,21 @@ struct bt_gatt_cep {
/* Client Characteristic Configuration Attribute Value */ /* Client Characteristic Configuration Attribute Value */
struct bt_gatt_ccc { struct bt_gatt_ccc {
/** Client Characteristic Configuration flags */ /** Client Characteristic Configuration flags */
uint16_t flags; u16_t flags;
}; };
/** @brief GATT Characteristic Presentation Format Attribute Value. */ /** @brief GATT Characteristic Presentation Format Attribute Value. */
struct bt_gatt_cpf { struct bt_gatt_cpf {
/** Format of the value of the characteristic */ /** Format of the value of the characteristic */
uint8_t format; u8_t format;
/** Exponent field to determine how the value of this characteristic is further formatted */ /** Exponent field to determine how the value of this characteristic is further formatted */
int8_t exponent; s8_t exponent;
/** Unit of the characteristic */ /** Unit of the characteristic */
uint16_t unit; u16_t unit;
/** Name space of the description */ /** Name space of the description */
uint8_t name_space; u8_t name_space;
/** Description of the characteristic as defined in a higher layer profile */ /** Description of the characteristic as defined in a higher layer profile */
uint16_t description; u16_t description;
} __packed; } __packed;
/* Server API */ /* Server API */
@ -296,7 +296,7 @@ enum {
* @return BT_GATT_ITER_CONTINUE if should continue to the next attribute * @return BT_GATT_ITER_CONTINUE if should continue to the next attribute
* or BT_GATT_ITER_STOP to stop. * or BT_GATT_ITER_STOP to stop.
*/ */
typedef uint8_t (*bt_gatt_attr_func_t)(const struct bt_gatt_attr *attr, typedef u8_t (*bt_gatt_attr_func_t)(const struct bt_gatt_attr *attr,
void *user_data); void *user_data);
/** @brief Attribute iterator. /** @brief Attribute iterator.
@ -308,7 +308,7 @@ typedef uint8_t (*bt_gatt_attr_func_t)(const struct bt_gatt_attr *attr,
* @param func Callback function. * @param func Callback function.
* @param user_data Data to pass to the callback. * @param user_data Data to pass to the callback.
*/ */
void bt_gatt_foreach_attr(uint16_t start_handle, uint16_t end_handle, void bt_gatt_foreach_attr(u16_t start_handle, u16_t end_handle,
bt_gatt_attr_func_t func, void *user_data); bt_gatt_attr_func_t func, void *user_data);
/** @brief Iterate to the next attribute /** @brief Iterate to the next attribute
@ -337,8 +337,8 @@ struct bt_gatt_attr *bt_gatt_attr_next(const struct bt_gatt_attr *attr);
* case of error. * case of error.
*/ */
ssize_t bt_gatt_attr_read(struct bt_conn *conn, const struct bt_gatt_attr *attr, ssize_t bt_gatt_attr_read(struct bt_conn *conn, const struct bt_gatt_attr *attr,
void *buf, uint16_t buf_len, uint16_t offset, void *buf, u16_t buf_len, u16_t offset,
const void *value, uint16_t value_len); const void *value, u16_t value_len);
/** @brief Read Service Attribute helper. /** @brief Read Service Attribute helper.
* *
@ -357,7 +357,7 @@ ssize_t bt_gatt_attr_read(struct bt_conn *conn, const struct bt_gatt_attr *attr,
*/ */
ssize_t bt_gatt_attr_read_service(struct bt_conn *conn, ssize_t bt_gatt_attr_read_service(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const struct bt_gatt_attr *attr,
void *buf, uint16_t len, uint16_t offset); void *buf, u16_t len, u16_t offset);
/** @def BT_GATT_SERVICE /** @def BT_GATT_SERVICE
* @brief Generic Service Declaration Macro. * @brief Generic Service Declaration Macro.
@ -422,7 +422,7 @@ ssize_t bt_gatt_attr_read_service(struct bt_conn *conn,
*/ */
ssize_t bt_gatt_attr_read_included(struct bt_conn *conn, ssize_t bt_gatt_attr_read_included(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const struct bt_gatt_attr *attr,
void *buf, uint16_t len, uint16_t offset); void *buf, u16_t len, u16_t offset);
/** @def BT_GATT_INCLUDE_SERVICE /** @def BT_GATT_INCLUDE_SERVICE
* @brief Include Service Declaration Macro. * @brief Include Service Declaration Macro.
@ -456,7 +456,7 @@ ssize_t bt_gatt_attr_read_included(struct bt_conn *conn,
*/ */
ssize_t bt_gatt_attr_read_chrc(struct bt_conn *conn, ssize_t bt_gatt_attr_read_chrc(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf, const struct bt_gatt_attr *attr, void *buf,
uint16_t len, uint16_t offset); u16_t len, u16_t offset);
/** @def BT_GATT_CHARACTERISTIC /** @def BT_GATT_CHARACTERISTIC
* @brief Characteristic Declaration Macro. * @brief Characteristic Declaration Macro.
@ -480,18 +480,18 @@ struct bt_gatt_ccc_cfg {
/** Config peer address. */ /** Config peer address. */
bt_addr_le_t peer; bt_addr_le_t peer;
/** Config peer value. */ /** Config peer value. */
uint16_t value; u16_t value;
/** Config valid flag. */ /** Config valid flag. */
uint8_t valid; u8_t valid;
}; };
/* Internal representation of CCC value */ /* Internal representation of CCC value */
struct _bt_gatt_ccc { struct _bt_gatt_ccc {
struct bt_gatt_ccc_cfg *cfg; struct bt_gatt_ccc_cfg *cfg;
size_t cfg_len; size_t cfg_len;
uint16_t value; u16_t value;
void (*cfg_changed)(const struct bt_gatt_attr *attr, void (*cfg_changed)(const struct bt_gatt_attr *attr,
uint16_t value); u16_t value);
}; };
/** @brief Read Client Characteristic Configuration Attribute helper. /** @brief Read Client Characteristic Configuration Attribute helper.
@ -511,7 +511,7 @@ struct _bt_gatt_ccc {
*/ */
ssize_t bt_gatt_attr_read_ccc(struct bt_conn *conn, ssize_t bt_gatt_attr_read_ccc(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf, const struct bt_gatt_attr *attr, void *buf,
uint16_t len, uint16_t offset); u16_t len, u16_t offset);
/** @brief Write Client Characteristic Configuration Attribute helper. /** @brief Write Client Characteristic Configuration Attribute helper.
* *
@ -530,7 +530,7 @@ ssize_t bt_gatt_attr_read_ccc(struct bt_conn *conn,
*/ */
ssize_t bt_gatt_attr_write_ccc(struct bt_conn *conn, ssize_t bt_gatt_attr_write_ccc(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const void *buf, const struct bt_gatt_attr *attr, const void *buf,
uint16_t len, uint16_t offset, uint8_t flags); u16_t len, u16_t offset, u8_t flags);
/** @def BT_GATT_CCC /** @def BT_GATT_CCC
* @brief Client Characteristic Configuration Declaration Macro. * @brief Client Characteristic Configuration Declaration Macro.
@ -568,7 +568,7 @@ ssize_t bt_gatt_attr_write_ccc(struct bt_conn *conn,
*/ */
ssize_t bt_gatt_attr_read_cep(struct bt_conn *conn, ssize_t bt_gatt_attr_read_cep(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf, const struct bt_gatt_attr *attr, void *buf,
uint16_t len, uint16_t offset); u16_t len, u16_t offset);
/** @def BT_GATT_CEP /** @def BT_GATT_CEP
* @brief Characteristic Extended Properties Declaration Macro. * @brief Characteristic Extended Properties Declaration Macro.
@ -602,7 +602,7 @@ ssize_t bt_gatt_attr_read_cep(struct bt_conn *conn,
*/ */
ssize_t bt_gatt_attr_read_cud(struct bt_conn *conn, ssize_t bt_gatt_attr_read_cud(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf, const struct bt_gatt_attr *attr, void *buf,
uint16_t len, uint16_t offset); u16_t len, u16_t offset);
/** @def BT_GATT_CUD /** @def BT_GATT_CUD
* @brief Characteristic User Format Descriptor Declaration Macro. * @brief Characteristic User Format Descriptor Declaration Macro.
@ -637,7 +637,7 @@ ssize_t bt_gatt_attr_read_cud(struct bt_conn *conn,
*/ */
ssize_t bt_gatt_attr_read_cpf(struct bt_conn *conn, ssize_t bt_gatt_attr_read_cpf(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf, const struct bt_gatt_attr *attr, void *buf,
uint16_t len, uint16_t offset); u16_t len, u16_t offset);
/** @def BT_GATT_CPF /** @def BT_GATT_CPF
* @brief Characteristic Presentation Format Descriptor Declaration Macro. * @brief Characteristic Presentation Format Descriptor Declaration Macro.
@ -686,7 +686,7 @@ ssize_t bt_gatt_attr_read_cpf(struct bt_conn *conn,
* @param len Attribute value length. * @param len Attribute value length.
*/ */
int bt_gatt_notify(struct bt_conn *conn, const struct bt_gatt_attr *attr, int bt_gatt_notify(struct bt_conn *conn, const struct bt_gatt_attr *attr,
const void *data, uint16_t len); const void *data, u16_t len);
/** @typedef bt_gatt_indicate_func_t /** @typedef bt_gatt_indicate_func_t
* @brief Indication complete result callback. * @brief Indication complete result callback.
@ -697,7 +697,7 @@ int bt_gatt_notify(struct bt_conn *conn, const struct bt_gatt_attr *attr,
*/ */
typedef void (*bt_gatt_indicate_func_t)(struct bt_conn *conn, typedef void (*bt_gatt_indicate_func_t)(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const struct bt_gatt_attr *attr,
uint8_t err); u8_t err);
/** @brief GATT Indicate Value parameters */ /** @brief GATT Indicate Value parameters */
struct bt_gatt_indicate_params { struct bt_gatt_indicate_params {
@ -709,7 +709,7 @@ struct bt_gatt_indicate_params {
/** Indicate Value data*/ /** Indicate Value data*/
const void *data; const void *data;
/** Indicate Value length*/ /** Indicate Value length*/
uint16_t len; u16_t len;
}; };
/** @brief Indicate attribute value change. /** @brief Indicate attribute value change.
@ -738,7 +738,7 @@ int bt_gatt_indicate(struct bt_conn *conn,
* *
* @return MTU in bytes * @return MTU in bytes
*/ */
uint16_t bt_gatt_get_mtu(struct bt_conn *conn); u16_t bt_gatt_get_mtu(struct bt_conn *conn);
/* Client API */ /* Client API */
@ -746,7 +746,7 @@ uint16_t bt_gatt_get_mtu(struct bt_conn *conn);
struct bt_gatt_exchange_params { struct bt_gatt_exchange_params {
struct bt_att_req _req; struct bt_att_req _req;
/** Response callback */ /** Response callback */
void (*func)(struct bt_conn *conn, uint8_t err, void (*func)(struct bt_conn *conn, u8_t err,
struct bt_gatt_exchange_params *params); struct bt_gatt_exchange_params *params);
}; };
@ -782,7 +782,7 @@ struct bt_gatt_discover_params;
* @return BT_GATT_ITER_CONTINUE if should continue attribute discovery * @return BT_GATT_ITER_CONTINUE if should continue attribute discovery
* or BT_GATT_ITER_STOP to stop discovery procedure. * or BT_GATT_ITER_STOP to stop discovery procedure.
*/ */
typedef uint8_t (*bt_gatt_discover_func_t)(struct bt_conn *conn, typedef u8_t (*bt_gatt_discover_func_t)(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const struct bt_gatt_attr *attr,
struct bt_gatt_discover_params *params); struct bt_gatt_discover_params *params);
@ -804,19 +804,19 @@ struct bt_gatt_discover_params {
union { union {
struct { struct {
/** Include service attribute declaration handle */ /** Include service attribute declaration handle */
uint16_t attr_handle; u16_t attr_handle;
/** Included service start handle */ /** Included service start handle */
uint16_t start_handle; u16_t start_handle;
/** Included service end handle */ /** Included service end handle */
uint16_t end_handle; u16_t end_handle;
} _included; } _included;
/** Discover start handle */ /** Discover start handle */
uint16_t start_handle; u16_t start_handle;
}; };
/** Discover end handle */ /** Discover end handle */
uint16_t end_handle; u16_t end_handle;
/** Discover type */ /** Discover type */
uint8_t type; u8_t type;
}; };
/** @brief GATT Discover function /** @brief GATT Discover function
@ -858,9 +858,9 @@ struct bt_gatt_read_params;
* @param data Attribute value data. NULL means read has completed. * @param data Attribute value data. NULL means read has completed.
* @param length Attribute value length. * @param length Attribute value length.
*/ */
typedef uint8_t (*bt_gatt_read_func_t)(struct bt_conn *conn, uint8_t err, typedef u8_t (*bt_gatt_read_func_t)(struct bt_conn *conn, u8_t err,
struct bt_gatt_read_params *params, struct bt_gatt_read_params *params,
const void *data, uint16_t length); const void *data, u16_t length);
/** @brief GATT Read parameters /** @brief GATT Read parameters
* @param func Read attribute callback * @param func Read attribute callback
@ -877,10 +877,10 @@ struct bt_gatt_read_params {
size_t handle_count; size_t handle_count;
union { union {
struct __single { struct __single {
uint16_t handle; u16_t handle;
uint16_t offset; u16_t offset;
} single; } single;
uint16_t *handles; u16_t *handles;
}; };
}; };
@ -907,7 +907,7 @@ struct bt_gatt_write_params;
* @param err ATT error code. * @param err ATT error code.
* @param params Write parameters used. * @param params Write parameters used.
*/ */
typedef void (*bt_gatt_write_func_t)(struct bt_conn *conn, uint8_t err, typedef void (*bt_gatt_write_func_t)(struct bt_conn *conn, u8_t err,
struct bt_gatt_write_params *params); struct bt_gatt_write_params *params);
/** @brief GATT Write parameters */ /** @brief GATT Write parameters */
@ -916,13 +916,13 @@ struct bt_gatt_write_params {
/** Response callback */ /** Response callback */
bt_gatt_write_func_t func; bt_gatt_write_func_t func;
/** Attribute handle */ /** Attribute handle */
uint16_t handle; u16_t handle;
/** Attribute data offset */ /** Attribute data offset */
uint16_t offset; u16_t offset;
/** Data to be written */ /** Data to be written */
const void *data; const void *data;
/** Length of the data */ /** Length of the data */
uint16_t length; u16_t length;
}; };
/** @brief Write Attribute Value by handle /** @brief Write Attribute Value by handle
@ -953,8 +953,8 @@ int bt_gatt_write(struct bt_conn *conn, struct bt_gatt_write_params *params);
* *
* @return 0 in case of success or negative value in case of error. * @return 0 in case of success or negative value in case of error.
*/ */
int bt_gatt_write_without_response(struct bt_conn *conn, uint16_t handle, int bt_gatt_write_without_response(struct bt_conn *conn, u16_t handle,
const void *data, uint16_t length, const void *data, u16_t length,
bool sign); bool sign);
struct bt_gatt_subscribe_params; struct bt_gatt_subscribe_params;
@ -967,9 +967,9 @@ struct bt_gatt_subscribe_params;
* @param data Attribute value data. If NULL then subscription was removed. * @param data Attribute value data. If NULL then subscription was removed.
* @param length Attribute value length. * @param length Attribute value length.
*/ */
typedef uint8_t (*bt_gatt_notify_func_t)(struct bt_conn *conn, typedef u8_t (*bt_gatt_notify_func_t)(struct bt_conn *conn,
struct bt_gatt_subscribe_params *params, struct bt_gatt_subscribe_params *params,
const void *data, uint16_t length); const void *data, u16_t length);
/* Subscription flags */ /* Subscription flags */
enum { enum {
@ -992,13 +992,13 @@ struct bt_gatt_subscribe_params {
/** Notification value callback */ /** Notification value callback */
bt_gatt_notify_func_t notify; bt_gatt_notify_func_t notify;
/** Subscribe value handle */ /** Subscribe value handle */
uint16_t value_handle; u16_t value_handle;
/** Subscribe CCC handle */ /** Subscribe CCC handle */
uint16_t ccc_handle; u16_t ccc_handle;
/** Subscribe value */ /** Subscribe value */
uint16_t value; u16_t value;
/** Subscription flags */ /** Subscription flags */
uint8_t flags; u8_t flags;
sys_snode_t node; sys_snode_t node;
}; };

File diff suppressed because it is too large Load diff

View file

@ -40,9 +40,9 @@ enum bt_hfp_hf_at_cmd {
/** @brief HFP HF Command completion field */ /** @brief HFP HF Command completion field */
struct bt_hfp_hf_cmd_complete { struct bt_hfp_hf_cmd_complete {
/* Command complete status */ /* Command complete status */
uint8_t type; u8_t type;
/* CME error number to be added */ /* CME error number to be added */
uint8_t cme; u8_t cme;
}; };
/** @brief HFP profile application callback */ /** @brief HFP profile application callback */
@ -71,7 +71,7 @@ struct bt_hfp_hf_cb {
* @param conn Connection object. * @param conn Connection object.
* @param value service indicator value received from the AG. * @param value service indicator value received from the AG.
*/ */
void (*service)(struct bt_conn *conn, uint32_t value); void (*service)(struct bt_conn *conn, u32_t value);
/** HF indicator Callback /** HF indicator Callback
* *
* This callback provides call indicator value to the application * This callback provides call indicator value to the application
@ -79,7 +79,7 @@ struct bt_hfp_hf_cb {
* @param conn Connection object. * @param conn Connection object.
* @param value call indicator value received from the AG. * @param value call indicator value received from the AG.
*/ */
void (*call)(struct bt_conn *conn, uint32_t value); void (*call)(struct bt_conn *conn, u32_t value);
/** HF indicator Callback /** HF indicator Callback
* *
* This callback provides call setup indicator value to the application * This callback provides call setup indicator value to the application
@ -87,7 +87,7 @@ struct bt_hfp_hf_cb {
* @param conn Connection object. * @param conn Connection object.
* @param value call setup indicator value received from the AG. * @param value call setup indicator value received from the AG.
*/ */
void (*call_setup)(struct bt_conn *conn, uint32_t value); void (*call_setup)(struct bt_conn *conn, u32_t value);
/** HF indicator Callback /** HF indicator Callback
* *
* This callback provides call held indicator value to the application * This callback provides call held indicator value to the application
@ -95,7 +95,7 @@ struct bt_hfp_hf_cb {
* @param conn Connection object. * @param conn Connection object.
* @param value call held indicator value received from the AG. * @param value call held indicator value received from the AG.
*/ */
void (*call_held)(struct bt_conn *conn, uint32_t value); void (*call_held)(struct bt_conn *conn, u32_t value);
/** HF indicator Callback /** HF indicator Callback
* *
* This callback provides signal indicator value to the application * This callback provides signal indicator value to the application
@ -103,7 +103,7 @@ struct bt_hfp_hf_cb {
* @param conn Connection object. * @param conn Connection object.
* @param value signal indicator value received from the AG. * @param value signal indicator value received from the AG.
*/ */
void (*signal)(struct bt_conn *conn, uint32_t value); void (*signal)(struct bt_conn *conn, u32_t value);
/** HF indicator Callback /** HF indicator Callback
* *
* This callback provides roaming indicator value to the application * This callback provides roaming indicator value to the application
@ -111,7 +111,7 @@ struct bt_hfp_hf_cb {
* @param conn Connection object. * @param conn Connection object.
* @param value roaming indicator value received from the AG. * @param value roaming indicator value received from the AG.
*/ */
void (*roam)(struct bt_conn *conn, uint32_t value); void (*roam)(struct bt_conn *conn, u32_t value);
/** HF indicator Callback /** HF indicator Callback
* *
* This callback battery service indicator value to the application * This callback battery service indicator value to the application
@ -119,7 +119,7 @@ struct bt_hfp_hf_cb {
* @param conn Connection object. * @param conn Connection object.
* @param value battery indicator value received from the AG. * @param value battery indicator value received from the AG.
*/ */
void (*battery)(struct bt_conn *conn, uint32_t value); void (*battery)(struct bt_conn *conn, u32_t value);
/** HF incoming call Ring indication callback to application /** HF incoming call Ring indication callback to application
* *
* If this callback is provided it will be called whenever there * If this callback is provided it will be called whenever there

View file

@ -81,9 +81,9 @@ struct bt_l2cap_chan {
#if defined(CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL) #if defined(CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL)
bt_l2cap_chan_state_t state; bt_l2cap_chan_state_t state;
/** Remote PSM to be connected */ /** Remote PSM to be connected */
uint16_t psm; u16_t psm;
/** Helps match request context during CoC */ /** Helps match request context during CoC */
uint8_t ident; u8_t ident;
bt_security_t required_sec_level; bt_security_t required_sec_level;
#endif /* CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL */ #endif /* CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL */
}; };
@ -91,13 +91,13 @@ struct bt_l2cap_chan {
/** @brief LE L2CAP Endpoint structure. */ /** @brief LE L2CAP Endpoint structure. */
struct bt_l2cap_le_endpoint { struct bt_l2cap_le_endpoint {
/** Endpoint CID */ /** Endpoint CID */
uint16_t cid; u16_t cid;
/** Endpoint Maximum Transmission Unit */ /** Endpoint Maximum Transmission Unit */
uint16_t mtu; u16_t mtu;
/** Endpoint Maximum PDU payload Size */ /** Endpoint Maximum PDU payload Size */
uint16_t mps; u16_t mps;
/** Endpoint initial credits */ /** Endpoint initial credits */
uint16_t init_credits; u16_t init_credits;
/** Endpoint credits */ /** Endpoint credits */
struct k_sem credits; struct k_sem credits;
}; };
@ -116,7 +116,7 @@ struct bt_l2cap_le_chan {
struct net_buf *tx_buf; struct net_buf *tx_buf;
/** Segment SDU packet from upper layer */ /** Segment SDU packet from upper layer */
struct net_buf *_sdu; struct net_buf *_sdu;
uint16_t _sdu_len; u16_t _sdu_len;
}; };
/** @def BT_L2CAP_LE_CHAN(_ch) /** @def BT_L2CAP_LE_CHAN(_ch)
@ -133,9 +133,9 @@ struct bt_l2cap_le_chan {
/** @brief BREDR L2CAP Endpoint structure. */ /** @brief BREDR L2CAP Endpoint structure. */
struct bt_l2cap_br_endpoint { struct bt_l2cap_br_endpoint {
/** Endpoint CID */ /** Endpoint CID */
uint16_t cid; u16_t cid;
/** Endpoint Maximum Transmission Unit */ /** Endpoint Maximum Transmission Unit */
uint16_t mtu; u16_t mtu;
}; };
/** @brief BREDR L2CAP Channel structure. */ /** @brief BREDR L2CAP Channel structure. */
@ -186,7 +186,7 @@ struct bt_l2cap_chan_ops {
* by HCI layer and set to 0 when success and to non-zero (reference to * by HCI layer and set to 0 when success and to non-zero (reference to
* HCI Error Codes) when security/authentication failed. * HCI Error Codes) when security/authentication failed.
*/ */
void (*encrypt_change)(struct bt_l2cap_chan *chan, uint8_t hci_status); void (*encrypt_change)(struct bt_l2cap_chan *chan, u8_t hci_status);
/** Channel alloc_buf callback /** Channel alloc_buf callback
* *
@ -215,7 +215,7 @@ struct bt_l2cap_chan_ops {
/** @brief L2CAP Server structure. */ /** @brief L2CAP Server structure. */
struct bt_l2cap_server { struct bt_l2cap_server {
/** Server PSM */ /** Server PSM */
uint16_t psm; u16_t psm;
/** Required minimim security level */ /** Required minimim security level */
bt_security_t sec_level; bt_security_t sec_level;
@ -278,7 +278,7 @@ int bt_l2cap_br_server_register(struct bt_l2cap_server *server);
* @return 0 in case of success or negative value in case of error. * @return 0 in case of success or negative value in case of error.
*/ */
int bt_l2cap_chan_connect(struct bt_conn *conn, struct bt_l2cap_chan *chan, int bt_l2cap_chan_connect(struct bt_conn *conn, struct bt_l2cap_chan *chan,
uint16_t psm); u16_t psm);
/** @brief Disconnect L2CAP channel /** @brief Disconnect L2CAP channel
* *

View file

@ -90,10 +90,10 @@ struct bt_rfcomm_dlc {
bt_security_t required_sec_level; bt_security_t required_sec_level;
bt_rfcomm_role_t role; bt_rfcomm_role_t role;
uint16_t mtu; u16_t mtu;
uint8_t dlci; u8_t dlci;
uint8_t state; u8_t state;
uint8_t rx_credit; u8_t rx_credit;
/* Stack for TX fiber */ /* Stack for TX fiber */
BT_STACK(stack, 256); BT_STACK(stack, 256);
@ -101,7 +101,7 @@ struct bt_rfcomm_dlc {
struct bt_rfcomm_server { struct bt_rfcomm_server {
/** Server Channel */ /** Server Channel */
uint8_t channel; u8_t channel;
/** Server accept callback /** Server accept callback
* *
@ -143,7 +143,7 @@ int bt_rfcomm_server_register(struct bt_rfcomm_server *server);
* @return 0 in case of success or negative value in case of error. * @return 0 in case of success or negative value in case of error.
*/ */
int bt_rfcomm_dlc_connect(struct bt_conn *conn, struct bt_rfcomm_dlc *dlc, int bt_rfcomm_dlc_connect(struct bt_conn *conn, struct bt_rfcomm_dlc *dlc,
uint8_t channel); u8_t channel);
/** @brief Send data to RFCOMM /** @brief Send data to RFCOMM
* *

View file

@ -271,24 +271,24 @@ extern "C" {
/** @brief SDP Generic Data Element Value. */ /** @brief SDP Generic Data Element Value. */
struct bt_sdp_data_elem { struct bt_sdp_data_elem {
uint8_t type; u8_t type;
uint32_t data_size; u32_t data_size;
uint32_t total_size; u32_t total_size;
const void *data; const void *data;
}; };
/** @brief SDP Attribute Value. */ /** @brief SDP Attribute Value. */
struct bt_sdp_attribute { struct bt_sdp_attribute {
uint16_t id; /* Attribute ID */ u16_t id; /* Attribute ID */
struct bt_sdp_data_elem val; /* Attribute data */ struct bt_sdp_data_elem val; /* Attribute data */
}; };
/** @brief SDP Service Record Value. */ /** @brief SDP Service Record Value. */
struct bt_sdp_record { struct bt_sdp_record {
uint32_t handle; /* Redundant, for quick ref */ u32_t handle; /* Redundant, for quick ref */
struct bt_sdp_attribute *attrs; /* Base addr of attr array */ struct bt_sdp_attribute *attrs; /* Base addr of attr array */
size_t attr_count; /* Number of attributes */ size_t attr_count; /* Number of attributes */
uint8_t index; /* Index of the record in LL */ u8_t index; /* Index of the record in LL */
struct bt_sdp_record *next; struct bt_sdp_record *next;
}; };
@ -301,17 +301,17 @@ struct bt_sdp_record {
/** @def BT_SDP_ARRAY_8 /** @def BT_SDP_ARRAY_8
* @brief Declare an array of 8-bit elements in an attribute. * @brief Declare an array of 8-bit elements in an attribute.
*/ */
#define BT_SDP_ARRAY_8(...) ((uint8_t[]) {__VA_ARGS__}) #define BT_SDP_ARRAY_8(...) ((u8_t[]) {__VA_ARGS__})
/** @def BT_SDP_ARRAY_16 /** @def BT_SDP_ARRAY_16
* @brief Declare an array of 16-bit elements in an attribute. * @brief Declare an array of 16-bit elements in an attribute.
*/ */
#define BT_SDP_ARRAY_16(...) ((uint16_t[]) {__VA_ARGS__}) #define BT_SDP_ARRAY_16(...) ((u16_t[]) {__VA_ARGS__})
/** @def BT_SDP_ARRAY_32 /** @def BT_SDP_ARRAY_32
* @brief Declare an array of 32-bit elements in an attribute. * @brief Declare an array of 32-bit elements in an attribute.
*/ */
#define BT_SDP_ARRAY_32(...) ((uint32_t[]) {__VA_ARGS__}) #define BT_SDP_ARRAY_32(...) ((u32_t[]) {__VA_ARGS__})
/** @def BT_SDP_TYPE_SIZE /** @def BT_SDP_TYPE_SIZE
* @brief Declare a fixed-size data element header. * @brief Declare a fixed-size data element header.
@ -506,7 +506,7 @@ enum {
* record data and continue discovery for given UUID. By returning * record data and continue discovery for given UUID. By returning
* BT_SDP_DISCOVER_UUID_CONTINUE user allows this discovery continuation. * BT_SDP_DISCOVER_UUID_CONTINUE user allows this discovery continuation.
*/ */
typedef uint8_t (*bt_sdp_discover_func_t) typedef u8_t (*bt_sdp_discover_func_t)
(struct bt_conn *conn, struct bt_sdp_client_result *result); (struct bt_conn *conn, struct bt_sdp_client_result *result);
/** @brief Main user structure used in SDP discovery of remote. */ /** @brief Main user structure used in SDP discovery of remote. */
@ -573,7 +573,7 @@ enum bt_sdp_proto {
* value is found, or negative if error occurred during processing. * value is found, or negative if error occurred during processing.
*/ */
int bt_sdp_get_proto_param(const struct net_buf *buf, enum bt_sdp_proto proto, int bt_sdp_get_proto_param(const struct net_buf *buf, enum bt_sdp_proto proto,
uint16_t *param); u16_t *param);
/** @brief Get profile version. /** @brief Get profile version.
* *
@ -587,8 +587,8 @@ int bt_sdp_get_proto_param(const struct net_buf *buf, enum bt_sdp_proto proto,
* *
* @return 0 on success, negative value if error occurred during processing. * @return 0 on success, negative value if error occurred during processing.
*/ */
int bt_sdp_get_profile_version(const struct net_buf *buf, uint16_t profile, int bt_sdp_get_profile_version(const struct net_buf *buf, u16_t profile,
uint16_t *version); u16_t *version);
/** @brief Get SupportedFeatures attribute value /** @brief Get SupportedFeatures attribute value
* *
@ -600,7 +600,7 @@ int bt_sdp_get_profile_version(const struct net_buf *buf, uint16_t profile,
* *
* @return 0 on success if feature found and valid, negative in case any error * @return 0 on success if feature found and valid, negative in case any error
*/ */
int bt_sdp_get_features(const struct net_buf *buf, uint16_t *features); int bt_sdp_get_features(const struct net_buf *buf, u16_t *features);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -34,7 +34,7 @@ enum {
BT_STORAGE_ID_ADDR, BT_STORAGE_ID_ADDR,
/** Local Identity Resolving Key. /** Local Identity Resolving Key.
* Type: uint8_t key[16] * Type: u8_t key[16]
*/ */
BT_STORAGE_LOCAL_IRK, BT_STORAGE_LOCAL_IRK,
@ -59,7 +59,7 @@ enum {
BT_STORAGE_LTK, BT_STORAGE_LTK,
/** Identity Resolving Key /** Identity Resolving Key
* Type: uint8_t key[16] * Type: u8_t key[16]
*/ */
BT_STORAGE_IRK, BT_STORAGE_IRK,
}; };
@ -74,12 +74,12 @@ enum {
}; };
struct bt_storage_ltk { struct bt_storage_ltk {
uint8_t flags; u8_t flags;
/* Encryption key size used to generate key */ /* Encryption key size used to generate key */
uint8_t size; u8_t size;
uint16_t ediv; u16_t ediv;
uint8_t rand[8]; u8_t rand[8];
uint8_t val[16]; u8_t val[16];
}; };
struct bt_storage { struct bt_storage {
@ -93,7 +93,7 @@ struct bt_storage {
* @return Number of bytes read or negative error value on * @return Number of bytes read or negative error value on
* failure. * failure.
*/ */
ssize_t (*read)(const bt_addr_le_t *addr, uint16_t key, ssize_t (*read)(const bt_addr_le_t *addr, u16_t key,
void *data, size_t length); void *data, size_t length);
/** Write the value of a key to storage. /** Write the value of a key to storage.
@ -106,7 +106,7 @@ struct bt_storage {
* @return Number of bytes written or negative error value on * @return Number of bytes written or negative error value on
* failure. * failure.
*/ */
ssize_t (*write)(const bt_addr_le_t *addr, uint16_t key, ssize_t (*write)(const bt_addr_le_t *addr, u16_t key,
const void *data, size_t length); const void *data, size_t length);
/** Clear all keys for a specific address /** Clear all keys for a specific address

View file

@ -32,22 +32,22 @@ enum {
/** @brief This is a 'tentative' type and should be used as a pointer only */ /** @brief This is a 'tentative' type and should be used as a pointer only */
struct bt_uuid { struct bt_uuid {
uint8_t type; u8_t type;
}; };
struct bt_uuid_16 { struct bt_uuid_16 {
struct bt_uuid uuid; struct bt_uuid uuid;
uint16_t val; u16_t val;
}; };
struct bt_uuid_32 { struct bt_uuid_32 {
struct bt_uuid uuid; struct bt_uuid uuid;
uint32_t val; u32_t val;
}; };
struct bt_uuid_128 { struct bt_uuid_128 {
struct bt_uuid uuid; struct bt_uuid uuid;
uint8_t val[16]; u8_t val[16];
}; };
#define BT_UUID_INIT_16(value) \ #define BT_UUID_INIT_16(value) \

View file

@ -39,7 +39,7 @@ extern "C" {
* @return true if the event can be processed in the RX thread, false * @return true if the event can be processed in the RX thread, false
* if it cannot. * if it cannot.
*/ */
static inline bool bt_hci_evt_is_prio(uint8_t evt) static inline bool bt_hci_evt_is_prio(u8_t evt)
{ {
switch (evt) { switch (evt) {
case BT_HCI_EVT_CMD_COMPLETE: case BT_HCI_EVT_CMD_COMPLETE:

View file

@ -68,7 +68,7 @@ config BLUETOOTH_CONTROLLER_TX_BUFFER_SIZE
then controller will perform fragmentation before transmitting on the then controller will perform fragmentation before transmitting on the
the packet on air. the packet on air.
Maximum is set to 16384 due to implementation limitations (use of Maximum is set to 16384 due to implementation limitations (use of
uint16_t for size/length variables). u16_t for size/length variables).
config BLUETOOTH_CONTROLLER_COMPANY_ID config BLUETOOTH_CONTROLLER_COMPANY_ID
prompt "Company Id" prompt "Company Id"

View file

@ -9,11 +9,11 @@
#define _CCM_H_ #define _CCM_H_
struct ccm { struct ccm {
uint8_t key[16]; u8_t key[16];
uint64_t counter; u64_t counter;
uint8_t direction:1; u8_t direction:1;
uint8_t resv1:7; u8_t resv1:7;
uint8_t iv[8]; u8_t iv[8];
} __packed; } __packed;
#endif /* _CCM_H_ */ #endif /* _CCM_H_ */

View file

@ -9,9 +9,9 @@
#define _CNTR_H_ #define _CNTR_H_
void cntr_init(void); void cntr_init(void);
uint32_t cntr_start(void); u32_t cntr_start(void);
uint32_t cntr_stop(void); u32_t cntr_stop(void);
uint32_t cntr_cnt_get(void); u32_t cntr_cnt_get(void);
void cntr_cmp_set(uint8_t cmp, uint32_t value); void cntr_cmp_set(u8_t cmp, u32_t value);
#endif /* _CNTR_H_ */ #endif /* _CNTR_H_ */

View file

@ -9,7 +9,7 @@
#define _HAL_DEBUG_H_ #define _HAL_DEBUG_H_
#ifdef CONFIG_BLUETOOTH_CONTROLLER_ASSERT_HANDLER #ifdef CONFIG_BLUETOOTH_CONTROLLER_ASSERT_HANDLER
void bt_controller_assert_handle(char *file, uint32_t line); void bt_controller_assert_handle(char *file, u32_t line);
#define LL_ASSERT(cond) if (!(cond)) { \ #define LL_ASSERT(cond) if (!(cond)) { \
bt_controller_assert_handle(__FILE__, \ bt_controller_assert_handle(__FILE__, \
__LINE__); \ __LINE__); \

View file

@ -8,31 +8,31 @@
#ifndef _ECB_H_ #ifndef _ECB_H_
#define _ECB_H_ #define _ECB_H_
typedef void (*ecb_fp) (uint32_t status, uint8_t *cipher_be, typedef void (*ecb_fp) (u32_t status, u8_t *cipher_be,
void *context); void *context);
struct ecb { struct ecb {
uint8_t in_key_be[16]; u8_t in_key_be[16];
uint8_t in_clear_text_be[16]; u8_t in_clear_text_be[16];
uint8_t out_cipher_text_be[16]; u8_t out_cipher_text_be[16];
/* if not null reverse copy into in_key_be */ /* if not null reverse copy into in_key_be */
uint8_t *in_key_le; u8_t *in_key_le;
/* if not null reverse copy into in_clear_text_be */ /* if not null reverse copy into in_clear_text_be */
uint8_t *in_clear_text_le; u8_t *in_clear_text_le;
ecb_fp fp_ecb; ecb_fp fp_ecb;
void *context; void *context;
}; };
void ecb_encrypt_be(uint8_t const *const key_be, void ecb_encrypt_be(u8_t const *const key_be,
uint8_t const *const clear_text_be, u8_t const *const clear_text_be,
uint8_t * const cipher_text_be); u8_t * const cipher_text_be);
void ecb_encrypt(uint8_t const *const key_le, void ecb_encrypt(u8_t const *const key_le,
uint8_t const *const clear_text_le, u8_t const *const clear_text_le,
uint8_t * const cipher_text_le, u8_t * const cipher_text_le,
uint8_t * const cipher_text_be); u8_t * const cipher_text_be);
uint32_t ecb_encrypt_nonblocking(struct ecb *ecb); u32_t ecb_encrypt_nonblocking(struct ecb *ecb);
void isr_ecb(void *param); void isr_ecb(void *param);
uint32_t ecb_ut(void); u32_t ecb_ut(void);
#endif /* _ECB_H_ */ #endif /* _ECB_H_ */

View file

@ -15,7 +15,7 @@
#define NRF_RTC NRF_RTC0 #define NRF_RTC NRF_RTC0
#endif #endif
static uint8_t _refcount; static u8_t _refcount;
void cntr_init(void) void cntr_init(void)
{ {
@ -26,7 +26,7 @@ void cntr_init(void)
RTC_INTENSET_COMPARE1_Msk); RTC_INTENSET_COMPARE1_Msk);
} }
uint32_t cntr_start(void) u32_t cntr_start(void)
{ {
if (_refcount++) { if (_refcount++) {
return 1; return 1;
@ -37,7 +37,7 @@ uint32_t cntr_start(void)
return 0; return 0;
} }
uint32_t cntr_stop(void) u32_t cntr_stop(void)
{ {
LL_ASSERT(_refcount); LL_ASSERT(_refcount);
@ -50,12 +50,12 @@ uint32_t cntr_stop(void)
return 0; return 0;
} }
uint32_t cntr_cnt_get(void) u32_t cntr_cnt_get(void)
{ {
return NRF_RTC->COUNTER; return NRF_RTC->COUNTER;
} }
void cntr_cmp_set(uint8_t cmp, uint32_t value) void cntr_cmp_set(u8_t cmp, u32_t value)
{ {
NRF_RTC->CC[cmp] = value; NRF_RTC->CC[cmp] = value;
} }

View file

@ -16,16 +16,16 @@
#include "hal/debug.h" #include "hal/debug.h"
struct ecb_param { struct ecb_param {
uint8_t key[16]; u8_t key[16];
uint8_t clear_text[16]; u8_t clear_text[16];
uint8_t cipher_text[16]; u8_t cipher_text[16];
} __packed; } __packed;
static void do_ecb(struct ecb_param *ecb) static void do_ecb(struct ecb_param *ecb)
{ {
do { do {
NRF_ECB->TASKS_STOPECB = 1; NRF_ECB->TASKS_STOPECB = 1;
NRF_ECB->ECBDATAPTR = (uint32_t)ecb; NRF_ECB->ECBDATAPTR = (u32_t)ecb;
NRF_ECB->EVENTS_ENDECB = 0; NRF_ECB->EVENTS_ENDECB = 0;
NRF_ECB->EVENTS_ERRORECB = 0; NRF_ECB->EVENTS_ERRORECB = 0;
NRF_ECB->TASKS_STARTECB = 1; NRF_ECB->TASKS_STARTECB = 1;
@ -40,9 +40,9 @@ static void do_ecb(struct ecb_param *ecb)
NRF_ECB->ECBDATAPTR = 0; NRF_ECB->ECBDATAPTR = 0;
} }
void ecb_encrypt_be(uint8_t const *const key_be, void ecb_encrypt_be(u8_t const *const key_be,
uint8_t const *const clear_text_be, u8_t const *const clear_text_be,
uint8_t * const cipher_text_be) u8_t * const cipher_text_be)
{ {
struct ecb_param ecb; struct ecb_param ecb;
@ -54,10 +54,10 @@ void ecb_encrypt_be(uint8_t const *const key_be,
memcpy(cipher_text_be, &ecb.cipher_text[0], sizeof(ecb.cipher_text)); memcpy(cipher_text_be, &ecb.cipher_text[0], sizeof(ecb.cipher_text));
} }
void ecb_encrypt(uint8_t const *const key_le, void ecb_encrypt(u8_t const *const key_le,
uint8_t const *const clear_text_le, u8_t const *const clear_text_le,
uint8_t * const cipher_text_le, u8_t * const cipher_text_le,
uint8_t * const cipher_text_be) u8_t * const cipher_text_be)
{ {
struct ecb_param ecb; struct ecb_param ecb;
@ -77,7 +77,7 @@ void ecb_encrypt(uint8_t const *const key_le,
} }
} }
uint32_t ecb_encrypt_nonblocking(struct ecb *ecb) u32_t ecb_encrypt_nonblocking(struct ecb *ecb)
{ {
/* prepare to be used in a BE AES h/w */ /* prepare to be used in a BE AES h/w */
if (ecb->in_key_le) { if (ecb->in_key_le) {
@ -91,7 +91,7 @@ uint32_t ecb_encrypt_nonblocking(struct ecb *ecb)
} }
/* setup the encryption h/w */ /* setup the encryption h/w */
NRF_ECB->ECBDATAPTR = (uint32_t)ecb; NRF_ECB->ECBDATAPTR = (u32_t)ecb;
NRF_ECB->EVENTS_ENDECB = 0; NRF_ECB->EVENTS_ENDECB = 0;
NRF_ECB->EVENTS_ERRORECB = 0; NRF_ECB->EVENTS_ERRORECB = 0;
NRF_ECB->INTENSET = ECB_INTENSET_ERRORECB_Msk | ECB_INTENSET_ENDECB_Msk; NRF_ECB->INTENSET = ECB_INTENSET_ERRORECB_Msk | ECB_INTENSET_ENDECB_Msk;
@ -142,12 +142,12 @@ void isr_ecb(void *param)
} }
struct ecb_ut_context { struct ecb_ut_context {
uint32_t volatile done; u32_t volatile done;
uint32_t status; u32_t status;
uint8_t cipher_text[16]; u8_t cipher_text[16];
}; };
static void ecb_cb(uint32_t status, uint8_t *cipher_be, void *context) static void ecb_cb(u32_t status, u8_t *cipher_be, void *context)
{ {
struct ecb_ut_context *ecb_ut_context = struct ecb_ut_context *ecb_ut_context =
(struct ecb_ut_context *)context; (struct ecb_ut_context *)context;
@ -160,16 +160,16 @@ static void ecb_cb(uint32_t status, uint8_t *cipher_be, void *context)
} }
} }
uint32_t ecb_ut(void) u32_t ecb_ut(void)
{ {
uint8_t key[16] = { u8_t key[16] = {
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00,
0x11, 0x22, 0x33, 0x44, 0x55 }; 0x11, 0x22, 0x33, 0x44, 0x55 };
uint8_t clear_text[16] = { u8_t clear_text[16] = {
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00,
0x11, 0x22, 0x33, 0x44, 0x55 }; 0x11, 0x22, 0x33, 0x44, 0x55 };
uint8_t cipher_text[16]; u8_t cipher_text[16];
uint32_t status = 0; u32_t status = 0;
struct ecb ecb; struct ecb ecb;
struct ecb_ut_context context; struct ecb_ut_context context;

View file

@ -60,30 +60,30 @@ void radio_reset(void)
RADIO_POWER_POWER_Msk); RADIO_POWER_POWER_Msk);
} }
void radio_phy_set(uint8_t phy) void radio_phy_set(u8_t phy)
{ {
NRF_RADIO->MODE = NRF_RADIO->MODE =
(((phy) ? (uint32_t)phy : RADIO_MODE_MODE_Ble_1Mbit) << (((phy) ? (u32_t)phy : RADIO_MODE_MODE_Ble_1Mbit) <<
RADIO_MODE_MODE_Pos) & RADIO_MODE_MODE_Msk; RADIO_MODE_MODE_Pos) & RADIO_MODE_MODE_Msk;
} }
void radio_tx_power_set(uint32_t power) void radio_tx_power_set(u32_t power)
{ {
/* TODO map power to h/w values. */ /* TODO map power to h/w values. */
NRF_RADIO->TXPOWER = power; NRF_RADIO->TXPOWER = power;
} }
void radio_freq_chan_set(uint32_t chan) void radio_freq_chan_set(u32_t chan)
{ {
NRF_RADIO->FREQUENCY = chan; NRF_RADIO->FREQUENCY = chan;
} }
void radio_whiten_iv_set(uint32_t iv) void radio_whiten_iv_set(u32_t iv)
{ {
NRF_RADIO->DATAWHITEIV = iv; NRF_RADIO->DATAWHITEIV = iv;
} }
void radio_aa_set(uint8_t *aa) void radio_aa_set(u8_t *aa)
{ {
NRF_RADIO->TXADDRESS = NRF_RADIO->TXADDRESS =
(((0UL) << RADIO_TXADDRESS_TXADDRESS_Pos) & (((0UL) << RADIO_TXADDRESS_TXADDRESS_Pos) &
@ -94,7 +94,7 @@ void radio_aa_set(uint8_t *aa)
NRF_RADIO->BASE0 = (aa[2] << 24) | (aa[1] << 16) | (aa[0] << 8); NRF_RADIO->BASE0 = (aa[2] << 24) | (aa[1] << 16) | (aa[0] << 8);
} }
void radio_pkt_configure(uint8_t preamble16, uint8_t bits_len, uint8_t max_len) void radio_pkt_configure(u8_t preamble16, u8_t bits_len, u8_t max_len)
{ {
#if defined(CONFIG_SOC_SERIES_NRF51X) #if defined(CONFIG_SOC_SERIES_NRF51X)
ARG_UNUSED(preamble16); ARG_UNUSED(preamble16);
@ -106,7 +106,7 @@ void radio_pkt_configure(uint8_t preamble16, uint8_t bits_len, uint8_t max_len)
NRF_RADIO->PCNF0 = ((((1UL) << RADIO_PCNF0_S0LEN_Pos) & NRF_RADIO->PCNF0 = ((((1UL) << RADIO_PCNF0_S0LEN_Pos) &
RADIO_PCNF0_S0LEN_Msk) | RADIO_PCNF0_S0LEN_Msk) |
((((uint32_t)bits_len) << RADIO_PCNF0_LFLEN_Pos) & ((((u32_t)bits_len) << RADIO_PCNF0_LFLEN_Pos) &
RADIO_PCNF0_LFLEN_Msk) | RADIO_PCNF0_LFLEN_Msk) |
#if !defined(CONFIG_SOC_SERIES_NRF51X) #if !defined(CONFIG_SOC_SERIES_NRF51X)
(((RADIO_PCNF0_S1INCL_Include) << (((RADIO_PCNF0_S1INCL_Include) <<
@ -116,11 +116,11 @@ void radio_pkt_configure(uint8_t preamble16, uint8_t bits_len, uint8_t max_len)
RADIO_PCNF0_PLEN_8bit) << RADIO_PCNF0_PLEN_Pos) & RADIO_PCNF0_PLEN_8bit) << RADIO_PCNF0_PLEN_Pos) &
RADIO_PCNF0_PLEN_Msk) | RADIO_PCNF0_PLEN_Msk) |
#endif #endif
((((uint32_t)8-bits_len) << ((((u32_t)8-bits_len) <<
RADIO_PCNF0_S1LEN_Pos) & RADIO_PCNF0_S1LEN_Pos) &
RADIO_PCNF0_S1LEN_Msk)); RADIO_PCNF0_S1LEN_Msk));
NRF_RADIO->PCNF1 = (((((uint32_t)max_len) << RADIO_PCNF1_MAXLEN_Pos) & NRF_RADIO->PCNF1 = (((((u32_t)max_len) << RADIO_PCNF1_MAXLEN_Pos) &
RADIO_PCNF1_MAXLEN_Msk) | RADIO_PCNF1_MAXLEN_Msk) |
(((0UL) << RADIO_PCNF1_STATLEN_Pos) & (((0UL) << RADIO_PCNF1_STATLEN_Pos) &
RADIO_PCNF1_STATLEN_Msk) | RADIO_PCNF1_STATLEN_Msk) |
@ -135,12 +135,12 @@ void radio_pkt_configure(uint8_t preamble16, uint8_t bits_len, uint8_t max_len)
void radio_pkt_rx_set(void *rx_packet) void radio_pkt_rx_set(void *rx_packet)
{ {
NRF_RADIO->PACKETPTR = (uint32_t)rx_packet; NRF_RADIO->PACKETPTR = (u32_t)rx_packet;
} }
void radio_pkt_tx_set(void *tx_packet) void radio_pkt_tx_set(void *tx_packet)
{ {
NRF_RADIO->PACKETPTR = (uint32_t)tx_packet; NRF_RADIO->PACKETPTR = (u32_t)tx_packet;
} }
void radio_rx_enable(void) void radio_rx_enable(void)
@ -168,27 +168,27 @@ void radio_status_reset(void)
NRF_RADIO->EVENTS_DISABLED = 0; NRF_RADIO->EVENTS_DISABLED = 0;
} }
uint32_t radio_is_ready(void) u32_t radio_is_ready(void)
{ {
return NRF_RADIO->EVENTS_READY; return NRF_RADIO->EVENTS_READY;
} }
uint32_t radio_is_done(void) u32_t radio_is_done(void)
{ {
return NRF_RADIO->EVENTS_END; return NRF_RADIO->EVENTS_END;
} }
uint32_t radio_has_disabled(void) u32_t radio_has_disabled(void)
{ {
return NRF_RADIO->EVENTS_DISABLED; return NRF_RADIO->EVENTS_DISABLED;
} }
uint32_t radio_is_idle(void) u32_t radio_is_idle(void)
{ {
return (NRF_RADIO->STATE == 0); return (NRF_RADIO->STATE == 0);
} }
void radio_crc_configure(uint32_t polynomial, uint32_t iv) void radio_crc_configure(u32_t polynomial, u32_t iv)
{ {
NRF_RADIO->CRCCNF = NRF_RADIO->CRCCNF =
(((RADIO_CRCCNF_SKIPADDR_Skip) << RADIO_CRCCNF_SKIPADDR_Pos) & (((RADIO_CRCCNF_SKIPADDR_Skip) << RADIO_CRCCNF_SKIPADDR_Pos) &
@ -199,13 +199,13 @@ void radio_crc_configure(uint32_t polynomial, uint32_t iv)
NRF_RADIO->CRCINIT = iv; NRF_RADIO->CRCINIT = iv;
} }
uint32_t radio_crc_is_valid(void) u32_t radio_crc_is_valid(void)
{ {
return NRF_RADIO->CRCSTATUS; return NRF_RADIO->CRCSTATUS;
} }
static uint8_t MALIGN(4) _pkt_empty[PDU_EM_SIZE_MAX]; static u8_t MALIGN(4) _pkt_empty[PDU_EM_SIZE_MAX];
static uint8_t MALIGN(4) _pkt_scratch[ static u8_t MALIGN(4) _pkt_scratch[
((RADIO_PDU_LEN_MAX + 3) > PDU_AC_SIZE_MAX) ? ((RADIO_PDU_LEN_MAX + 3) > PDU_AC_SIZE_MAX) ?
(RADIO_PDU_LEN_MAX + 3) : PDU_AC_SIZE_MAX]; (RADIO_PDU_LEN_MAX + 3) : PDU_AC_SIZE_MAX];
@ -246,7 +246,7 @@ void radio_rssi_measure(void)
RADIO_SHORTS_DISABLED_RSSISTOP_Msk); RADIO_SHORTS_DISABLED_RSSISTOP_Msk);
} }
uint32_t radio_rssi_get(void) u32_t radio_rssi_get(void)
{ {
return NRF_RADIO->RSSISAMPLE; return NRF_RADIO->RSSISAMPLE;
} }
@ -256,27 +256,27 @@ void radio_rssi_status_reset(void)
NRF_RADIO->EVENTS_RSSIEND = 0; NRF_RADIO->EVENTS_RSSIEND = 0;
} }
uint32_t radio_rssi_is_ready(void) u32_t radio_rssi_is_ready(void)
{ {
return NRF_RADIO->EVENTS_RSSIEND; return NRF_RADIO->EVENTS_RSSIEND;
} }
void radio_filter_configure(uint8_t bitmask_enable, void radio_filter_configure(u8_t bitmask_enable,
uint8_t bitmask_addr_type, u8_t bitmask_addr_type,
uint8_t *bdaddr) u8_t *bdaddr)
{ {
uint8_t index; u8_t index;
for (index = 0; index < 8; index++) { for (index = 0; index < 8; index++) {
NRF_RADIO->DAB[index] = ((uint32_t)bdaddr[3] << 24) | NRF_RADIO->DAB[index] = ((u32_t)bdaddr[3] << 24) |
((uint32_t)bdaddr[2] << 16) | ((u32_t)bdaddr[2] << 16) |
((uint32_t)bdaddr[1] << 8) | ((u32_t)bdaddr[1] << 8) |
bdaddr[0]; bdaddr[0];
NRF_RADIO->DAP[index] = ((uint32_t)bdaddr[5] << 8) | bdaddr[4]; NRF_RADIO->DAP[index] = ((u32_t)bdaddr[5] << 8) | bdaddr[4];
bdaddr += 6; bdaddr += 6;
} }
NRF_RADIO->DACNF = ((uint32_t)bitmask_addr_type << 8) | bitmask_enable; NRF_RADIO->DACNF = ((u32_t)bitmask_addr_type << 8) | bitmask_enable;
} }
void radio_filter_disable(void) void radio_filter_disable(void)
@ -290,12 +290,12 @@ void radio_filter_status_reset(void)
NRF_RADIO->EVENTS_DEVMISS = 0; NRF_RADIO->EVENTS_DEVMISS = 0;
} }
uint32_t radio_filter_has_match(void) u32_t radio_filter_has_match(void)
{ {
return NRF_RADIO->EVENTS_DEVMATCH; return NRF_RADIO->EVENTS_DEVMATCH;
} }
void radio_bc_configure(uint32_t n) void radio_bc_configure(u32_t n)
{ {
NRF_RADIO->BCC = n; NRF_RADIO->BCC = n;
NRF_RADIO->SHORTS |= RADIO_SHORTS_ADDRESS_BCSTART_Msk; NRF_RADIO->SHORTS |= RADIO_SHORTS_ADDRESS_BCSTART_Msk;
@ -306,7 +306,7 @@ void radio_bc_status_reset(void)
NRF_RADIO->EVENTS_BCMATCH = 0; NRF_RADIO->EVENTS_BCMATCH = 0;
} }
uint32_t radio_bc_has_match(void) u32_t radio_bc_has_match(void)
{ {
return NRF_RADIO->EVENTS_BCMATCH; return NRF_RADIO->EVENTS_BCMATCH;
} }
@ -320,12 +320,12 @@ void radio_tmr_status_reset(void)
PPI_CHEN_CH6_Msk | PPI_CHEN_CH7_Msk); PPI_CHEN_CH6_Msk | PPI_CHEN_CH7_Msk);
} }
void radio_tmr_tifs_set(uint32_t tifs) void radio_tmr_tifs_set(u32_t tifs)
{ {
NRF_RADIO->TIFS = tifs; NRF_RADIO->TIFS = tifs;
} }
uint32_t radio_tmr_start(uint8_t trx, uint32_t ticks_start, uint32_t remainder) u32_t radio_tmr_start(u8_t trx, u32_t ticks_start, u32_t remainder)
{ {
if ((!(remainder / 1000000UL)) || (remainder & 0x80000000)) { if ((!(remainder / 1000000UL)) || (remainder & 0x80000000)) {
ticks_start--; ticks_start--;
@ -345,21 +345,21 @@ uint32_t radio_tmr_start(uint8_t trx, uint32_t ticks_start, uint32_t remainder)
NRF_RTC0->EVTENSET = RTC_EVTENSET_COMPARE2_Msk; NRF_RTC0->EVTENSET = RTC_EVTENSET_COMPARE2_Msk;
NRF_RTC0->EVENTS_COMPARE[2] = 0; NRF_RTC0->EVENTS_COMPARE[2] = 0;
NRF_PPI->CH[1].EEP = (uint32_t)&(NRF_RTC0->EVENTS_COMPARE[2]); NRF_PPI->CH[1].EEP = (u32_t)&(NRF_RTC0->EVENTS_COMPARE[2]);
NRF_PPI->CH[1].TEP = (uint32_t)&(NRF_TIMER0->TASKS_START); NRF_PPI->CH[1].TEP = (u32_t)&(NRF_TIMER0->TASKS_START);
NRF_PPI->CHENSET = PPI_CHEN_CH1_Msk; NRF_PPI->CHENSET = PPI_CHEN_CH1_Msk;
if (trx) { if (trx) {
NRF_PPI->CH[0].EEP = NRF_PPI->CH[0].EEP =
(uint32_t)&(NRF_TIMER0->EVENTS_COMPARE[0]); (u32_t)&(NRF_TIMER0->EVENTS_COMPARE[0]);
NRF_PPI->CH[0].TEP = NRF_PPI->CH[0].TEP =
(uint32_t)&(NRF_RADIO->TASKS_TXEN); (u32_t)&(NRF_RADIO->TASKS_TXEN);
NRF_PPI->CHENSET = PPI_CHEN_CH0_Msk; NRF_PPI->CHENSET = PPI_CHEN_CH0_Msk;
} else { } else {
NRF_PPI->CH[0].EEP = NRF_PPI->CH[0].EEP =
(uint32_t)&(NRF_TIMER0->EVENTS_COMPARE[0]); (u32_t)&(NRF_TIMER0->EVENTS_COMPARE[0]);
NRF_PPI->CH[0].TEP = NRF_PPI->CH[0].TEP =
(uint32_t)&(NRF_RADIO->TASKS_RXEN); (u32_t)&(NRF_RADIO->TASKS_RXEN);
NRF_PPI->CHENSET = PPI_CHEN_CH0_Msk; NRF_PPI->CHENSET = PPI_CHEN_CH0_Msk;
} }
@ -372,40 +372,40 @@ void radio_tmr_stop(void)
NRF_TIMER0->TASKS_SHUTDOWN = 1; NRF_TIMER0->TASKS_SHUTDOWN = 1;
} }
void radio_tmr_hcto_configure(uint32_t hcto) void radio_tmr_hcto_configure(u32_t hcto)
{ {
NRF_TIMER0->CC[2] = hcto; NRF_TIMER0->CC[2] = hcto;
NRF_TIMER0->EVENTS_COMPARE[2] = 0; NRF_TIMER0->EVENTS_COMPARE[2] = 0;
NRF_PPI->CH[4].EEP = (uint32_t)&(NRF_RADIO->EVENTS_ADDRESS); NRF_PPI->CH[4].EEP = (u32_t)&(NRF_RADIO->EVENTS_ADDRESS);
NRF_PPI->CH[4].TEP = (uint32_t)&(NRF_TIMER0->TASKS_CAPTURE[2]); NRF_PPI->CH[4].TEP = (u32_t)&(NRF_TIMER0->TASKS_CAPTURE[2]);
NRF_PPI->CH[5].EEP = (uint32_t)&(NRF_TIMER0->EVENTS_COMPARE[2]); NRF_PPI->CH[5].EEP = (u32_t)&(NRF_TIMER0->EVENTS_COMPARE[2]);
NRF_PPI->CH[5].TEP = (uint32_t)&(NRF_RADIO->TASKS_DISABLE); NRF_PPI->CH[5].TEP = (u32_t)&(NRF_RADIO->TASKS_DISABLE);
NRF_PPI->CHENSET = (PPI_CHEN_CH4_Msk | PPI_CHEN_CH5_Msk); NRF_PPI->CHENSET = (PPI_CHEN_CH4_Msk | PPI_CHEN_CH5_Msk);
} }
void radio_tmr_aa_capture(void) void radio_tmr_aa_capture(void)
{ {
NRF_PPI->CH[2].EEP = (uint32_t)&(NRF_RADIO->EVENTS_READY); NRF_PPI->CH[2].EEP = (u32_t)&(NRF_RADIO->EVENTS_READY);
NRF_PPI->CH[2].TEP = (uint32_t)&(NRF_TIMER0->TASKS_CAPTURE[0]); NRF_PPI->CH[2].TEP = (u32_t)&(NRF_TIMER0->TASKS_CAPTURE[0]);
NRF_PPI->CH[3].EEP = (uint32_t)&(NRF_RADIO->EVENTS_ADDRESS); NRF_PPI->CH[3].EEP = (u32_t)&(NRF_RADIO->EVENTS_ADDRESS);
NRF_PPI->CH[3].TEP = (uint32_t)&(NRF_TIMER0->TASKS_CAPTURE[1]); NRF_PPI->CH[3].TEP = (u32_t)&(NRF_TIMER0->TASKS_CAPTURE[1]);
NRF_PPI->CHENSET = (PPI_CHEN_CH2_Msk | PPI_CHEN_CH3_Msk); NRF_PPI->CHENSET = (PPI_CHEN_CH2_Msk | PPI_CHEN_CH3_Msk);
} }
uint32_t radio_tmr_aa_get(void) u32_t radio_tmr_aa_get(void)
{ {
return (NRF_TIMER0->CC[1] - NRF_TIMER0->CC[0]); return (NRF_TIMER0->CC[1] - NRF_TIMER0->CC[0]);
} }
void radio_tmr_end_capture(void) void radio_tmr_end_capture(void)
{ {
NRF_PPI->CH[7].EEP = (uint32_t)&(NRF_RADIO->EVENTS_END); NRF_PPI->CH[7].EEP = (u32_t)&(NRF_RADIO->EVENTS_END);
NRF_PPI->CH[7].TEP = (uint32_t)&(NRF_TIMER0->TASKS_CAPTURE[2]); NRF_PPI->CH[7].TEP = (u32_t)&(NRF_TIMER0->TASKS_CAPTURE[2]);
NRF_PPI->CHENSET = PPI_CHEN_CH7_Msk; NRF_PPI->CHENSET = PPI_CHEN_CH7_Msk;
} }
uint32_t radio_tmr_end_get(void) u32_t radio_tmr_end_get(void)
{ {
return NRF_TIMER0->CC[2]; return NRF_TIMER0->CC[2];
} }
@ -415,12 +415,12 @@ void radio_tmr_sample(void)
NRF_TIMER0->TASKS_CAPTURE[3] = 1; NRF_TIMER0->TASKS_CAPTURE[3] = 1;
} }
uint32_t radio_tmr_sample_get(void) u32_t radio_tmr_sample_get(void)
{ {
return NRF_TIMER0->CC[3]; return NRF_TIMER0->CC[3];
} }
static uint8_t MALIGN(4) _ccm_scratch[(RADIO_PDU_LEN_MAX - 4) + 16]; static u8_t MALIGN(4) _ccm_scratch[(RADIO_PDU_LEN_MAX - 4) + 16];
void *radio_ccm_rx_pkt_set(struct ccm *ccm, void *pkt) void *radio_ccm_rx_pkt_set(struct ccm *ccm, void *pkt)
{ {
@ -433,17 +433,17 @@ void *radio_ccm_rx_pkt_set(struct ccm *ccm, void *pkt)
#endif #endif
((CCM_MODE_MODE_Decryption << CCM_MODE_MODE_Pos) & ((CCM_MODE_MODE_Decryption << CCM_MODE_MODE_Pos) &
CCM_MODE_MODE_Msk); CCM_MODE_MODE_Msk);
NRF_CCM->CNFPTR = (uint32_t)ccm; NRF_CCM->CNFPTR = (u32_t)ccm;
NRF_CCM->INPTR = (uint32_t)_pkt_scratch; NRF_CCM->INPTR = (u32_t)_pkt_scratch;
NRF_CCM->OUTPTR = (uint32_t)pkt; NRF_CCM->OUTPTR = (u32_t)pkt;
NRF_CCM->SCRATCHPTR = (uint32_t)_ccm_scratch; NRF_CCM->SCRATCHPTR = (u32_t)_ccm_scratch;
NRF_CCM->SHORTS = 0; NRF_CCM->SHORTS = 0;
NRF_CCM->EVENTS_ENDKSGEN = 0; NRF_CCM->EVENTS_ENDKSGEN = 0;
NRF_CCM->EVENTS_ENDCRYPT = 0; NRF_CCM->EVENTS_ENDCRYPT = 0;
NRF_CCM->EVENTS_ERROR = 0; NRF_CCM->EVENTS_ERROR = 0;
NRF_PPI->CH[6].EEP = (uint32_t)&(NRF_RADIO->EVENTS_ADDRESS); NRF_PPI->CH[6].EEP = (u32_t)&(NRF_RADIO->EVENTS_ADDRESS);
NRF_PPI->CH[6].TEP = (uint32_t)&(NRF_CCM->TASKS_CRYPT); NRF_PPI->CH[6].TEP = (u32_t)&(NRF_CCM->TASKS_CRYPT);
NRF_PPI->CHENSET = PPI_CHEN_CH6_Msk; NRF_PPI->CHENSET = PPI_CHEN_CH6_Msk;
NRF_CCM->TASKS_KSGEN = 1; NRF_CCM->TASKS_KSGEN = 1;
@ -462,10 +462,10 @@ void *radio_ccm_tx_pkt_set(struct ccm *ccm, void *pkt)
#endif #endif
((CCM_MODE_MODE_Encryption << CCM_MODE_MODE_Pos) & ((CCM_MODE_MODE_Encryption << CCM_MODE_MODE_Pos) &
CCM_MODE_MODE_Msk); CCM_MODE_MODE_Msk);
NRF_CCM->CNFPTR = (uint32_t)ccm; NRF_CCM->CNFPTR = (u32_t)ccm;
NRF_CCM->INPTR = (uint32_t)pkt; NRF_CCM->INPTR = (u32_t)pkt;
NRF_CCM->OUTPTR = (uint32_t)_pkt_scratch; NRF_CCM->OUTPTR = (u32_t)_pkt_scratch;
NRF_CCM->SCRATCHPTR = (uint32_t)_ccm_scratch; NRF_CCM->SCRATCHPTR = (u32_t)_ccm_scratch;
NRF_CCM->SHORTS = CCM_SHORTS_ENDKSGEN_CRYPT_Msk; NRF_CCM->SHORTS = CCM_SHORTS_ENDKSGEN_CRYPT_Msk;
NRF_CCM->EVENTS_ENDKSGEN = 0; NRF_CCM->EVENTS_ENDKSGEN = 0;
NRF_CCM->EVENTS_ENDCRYPT = 0; NRF_CCM->EVENTS_ENDCRYPT = 0;
@ -473,8 +473,8 @@ void *radio_ccm_tx_pkt_set(struct ccm *ccm, void *pkt)
#if defined(CONFIG_SOC_SERIES_NRF51X) #if defined(CONFIG_SOC_SERIES_NRF51X)
/* set up PPI to enable CCM */ /* set up PPI to enable CCM */
NRF_PPI->CH[6].EEP = (uint32_t)&(NRF_RADIO->EVENTS_READY); NRF_PPI->CH[6].EEP = (u32_t)&(NRF_RADIO->EVENTS_READY);
NRF_PPI->CH[6].TEP = (uint32_t)&(NRF_CCM->TASKS_KSGEN); NRF_PPI->CH[6].TEP = (u32_t)&(NRF_CCM->TASKS_KSGEN);
NRF_PPI->CHENSET = PPI_CHEN_CH6_Msk; NRF_PPI->CHENSET = PPI_CHEN_CH6_Msk;
#elif 0 #elif 0
/* encrypt tx packet */ /* encrypt tx packet */
@ -497,7 +497,7 @@ void *radio_ccm_tx_pkt_set(struct ccm *ccm, void *pkt)
return _pkt_scratch; return _pkt_scratch;
} }
uint32_t radio_ccm_is_done(void) u32_t radio_ccm_is_done(void)
{ {
NRF_CCM->INTENSET = CCM_INTENSET_ENDCRYPT_Msk; NRF_CCM->INTENSET = CCM_INTENSET_ENDCRYPT_Msk;
while (NRF_CCM->EVENTS_ENDCRYPT == 0) { while (NRF_CCM->EVENTS_ENDCRYPT == 0) {
@ -511,29 +511,29 @@ uint32_t radio_ccm_is_done(void)
return (NRF_CCM->EVENTS_ERROR == 0); return (NRF_CCM->EVENTS_ERROR == 0);
} }
uint32_t radio_ccm_mic_is_valid(void) u32_t radio_ccm_mic_is_valid(void)
{ {
return NRF_CCM->MICSTATUS; return NRF_CCM->MICSTATUS;
} }
static uint8_t MALIGN(4) _aar_scratch[3]; static u8_t MALIGN(4) _aar_scratch[3];
void radio_ar_configure(uint32_t nirk, void *irk) void radio_ar_configure(u32_t nirk, void *irk)
{ {
NRF_AAR->ENABLE = 1; NRF_AAR->ENABLE = 1;
NRF_AAR->NIRK = nirk; NRF_AAR->NIRK = nirk;
NRF_AAR->IRKPTR = (uint32_t)irk; NRF_AAR->IRKPTR = (u32_t)irk;
NRF_AAR->ADDRPTR = (uint32_t)NRF_RADIO->PACKETPTR; NRF_AAR->ADDRPTR = (u32_t)NRF_RADIO->PACKETPTR;
NRF_AAR->SCRATCHPTR = (uint32_t)_aar_scratch[0]; NRF_AAR->SCRATCHPTR = (u32_t)_aar_scratch[0];
radio_bc_configure(64); radio_bc_configure(64);
NRF_PPI->CH[6].EEP = (uint32_t)&(NRF_RADIO->EVENTS_BCMATCH); NRF_PPI->CH[6].EEP = (u32_t)&(NRF_RADIO->EVENTS_BCMATCH);
NRF_PPI->CH[6].TEP = (uint32_t)&(NRF_AAR->TASKS_START); NRF_PPI->CH[6].TEP = (u32_t)&(NRF_AAR->TASKS_START);
NRF_PPI->CHENSET = PPI_CHEN_CH6_Msk; NRF_PPI->CHENSET = PPI_CHEN_CH6_Msk;
} }
uint32_t radio_ar_match_get(void) u32_t radio_ar_match_get(void)
{ {
return NRF_AAR->STATUS; return NRF_AAR->STATUS;
} }
@ -549,7 +549,7 @@ void radio_ar_status_reset(void)
radio_bc_status_reset(); radio_bc_status_reset();
} }
uint32_t radio_ar_has_match(void) u32_t radio_ar_has_match(void)
{ {
return (radio_bc_has_match() && return (radio_bc_has_match() &&
(NRF_AAR->EVENTS_END) && (NRF_AAR->EVENTS_END) &&

View file

@ -15,15 +15,15 @@
#define RAND_RESERVED (4) #define RAND_RESERVED (4)
struct rand { struct rand {
uint8_t count; u8_t count;
uint8_t first; u8_t first;
uint8_t last; u8_t last;
uint8_t rand[1]; u8_t rand[1];
}; };
static struct rand *rng; static struct rand *rng;
void rand_init(uint8_t *context, uint8_t context_len) void rand_init(u8_t *context, u8_t context_len)
{ {
LL_ASSERT(context_len > sizeof(struct rand)); LL_ASSERT(context_len > sizeof(struct rand));
@ -38,10 +38,10 @@ void rand_init(uint8_t *context, uint8_t context_len)
NRF_RNG->TASKS_START = 1; NRF_RNG->TASKS_START = 1;
} }
size_t rand_get(size_t octets, uint8_t *rand) size_t rand_get(size_t octets, u8_t *rand)
{ {
uint8_t reserved; u8_t reserved;
uint8_t first; u8_t first;
while (octets) { while (octets) {
if (rng->first == rng->last) { if (rng->first == rng->last) {
@ -80,7 +80,7 @@ void isr_rand(void *param)
ARG_UNUSED(param); ARG_UNUSED(param);
if (NRF_RNG->EVENTS_VALRDY) { if (NRF_RNG->EVENTS_VALRDY) {
uint8_t last; u8_t last;
last = rng->last + 1; last = rng->last + 1;
if (last == rng->count) { if (last == rng->count) {

View file

@ -26,12 +26,12 @@ void isr_radio(void);
void radio_isr_set(radio_isr_fp fp_radio_isr); void radio_isr_set(radio_isr_fp fp_radio_isr);
void radio_reset(void); void radio_reset(void);
void radio_phy_set(uint8_t phy); void radio_phy_set(u8_t phy);
void radio_tx_power_set(uint32_t power); void radio_tx_power_set(u32_t power);
void radio_freq_chan_set(uint32_t chan); void radio_freq_chan_set(u32_t chan);
void radio_whiten_iv_set(uint32_t iv); void radio_whiten_iv_set(u32_t iv);
void radio_aa_set(uint8_t *aa); void radio_aa_set(u8_t *aa);
void radio_pkt_configure(uint8_t preamble16, uint8_t bits_len, uint8_t max_len); void radio_pkt_configure(u8_t preamble16, u8_t bits_len, u8_t max_len);
void radio_pkt_rx_set(void *rx_packet); void radio_pkt_rx_set(void *rx_packet);
void radio_pkt_tx_set(void *tx_packet); void radio_pkt_tx_set(void *tx_packet);
void radio_rx_enable(void); void radio_rx_enable(void);
@ -39,13 +39,13 @@ void radio_tx_enable(void);
void radio_disable(void); void radio_disable(void);
void radio_status_reset(void); void radio_status_reset(void);
uint32_t radio_is_ready(void); u32_t radio_is_ready(void);
uint32_t radio_is_done(void); u32_t radio_is_done(void);
uint32_t radio_has_disabled(void); u32_t radio_has_disabled(void);
uint32_t radio_is_idle(void); u32_t radio_is_idle(void);
void radio_crc_configure(uint32_t polynomial, uint32_t iv); void radio_crc_configure(u32_t polynomial, u32_t iv);
uint32_t radio_crc_is_valid(void); u32_t radio_crc_is_valid(void);
void *radio_pkt_empty_get(void); void *radio_pkt_empty_get(void);
void *radio_pkt_scratch_get(void); void *radio_pkt_scratch_get(void);
@ -55,41 +55,41 @@ void radio_switch_complete_and_tx(void);
void radio_switch_complete_and_disable(void); void radio_switch_complete_and_disable(void);
void radio_rssi_measure(void); void radio_rssi_measure(void);
uint32_t radio_rssi_get(void); u32_t radio_rssi_get(void);
void radio_rssi_status_reset(void); void radio_rssi_status_reset(void);
uint32_t radio_rssi_is_ready(void); u32_t radio_rssi_is_ready(void);
void radio_filter_configure(uint8_t bitmask_enable, void radio_filter_configure(u8_t bitmask_enable,
uint8_t bitmask_addr_type, u8_t bitmask_addr_type,
uint8_t *bdaddr); u8_t *bdaddr);
void radio_filter_disable(void); void radio_filter_disable(void);
void radio_filter_status_reset(void); void radio_filter_status_reset(void);
uint32_t radio_filter_has_match(void); u32_t radio_filter_has_match(void);
void radio_bc_configure(uint32_t n); void radio_bc_configure(u32_t n);
void radio_bc_status_reset(void); void radio_bc_status_reset(void);
uint32_t radio_bc_has_match(void); u32_t radio_bc_has_match(void);
void radio_tmr_status_reset(void); void radio_tmr_status_reset(void);
void radio_tmr_tifs_set(uint32_t tifs); void radio_tmr_tifs_set(u32_t tifs);
uint32_t radio_tmr_start(uint8_t trx, uint32_t ticks_start, uint32_t remainder); u32_t radio_tmr_start(u8_t trx, u32_t ticks_start, u32_t remainder);
void radio_tmr_stop(void); void radio_tmr_stop(void);
void radio_tmr_hcto_configure(uint32_t hcto); void radio_tmr_hcto_configure(u32_t hcto);
void radio_tmr_aa_capture(void); void radio_tmr_aa_capture(void);
uint32_t radio_tmr_aa_get(void); u32_t radio_tmr_aa_get(void);
void radio_tmr_end_capture(void); void radio_tmr_end_capture(void);
uint32_t radio_tmr_end_get(void); u32_t radio_tmr_end_get(void);
void radio_tmr_sample(void); void radio_tmr_sample(void);
uint32_t radio_tmr_sample_get(void); u32_t radio_tmr_sample_get(void);
void *radio_ccm_rx_pkt_set(struct ccm *ccm, void *pkt); void *radio_ccm_rx_pkt_set(struct ccm *ccm, void *pkt);
void *radio_ccm_tx_pkt_set(struct ccm *ccm, void *pkt); void *radio_ccm_tx_pkt_set(struct ccm *ccm, void *pkt);
uint32_t radio_ccm_is_done(void); u32_t radio_ccm_is_done(void);
uint32_t radio_ccm_mic_is_valid(void); u32_t radio_ccm_mic_is_valid(void);
void radio_ar_configure(uint32_t nirk, void *irk); void radio_ar_configure(u32_t nirk, void *irk);
uint32_t radio_ar_match_get(void); u32_t radio_ar_match_get(void);
void radio_ar_status_reset(void); void radio_ar_status_reset(void);
uint32_t radio_ar_has_match(void); u32_t radio_ar_has_match(void);
#endif #endif

View file

@ -8,8 +8,8 @@
#ifndef _RAND_H_ #ifndef _RAND_H_
#define _RAND_H_ #define _RAND_H_
void rand_init(uint8_t *context, uint8_t context_len); void rand_init(u8_t *context, u8_t context_len);
size_t rand_get(size_t octets, uint8_t *rand); size_t rand_get(size_t octets, u8_t *rand);
void isr_rand(void *param); void isr_rand(void *param);
#endif /* _RAND_H_ */ #endif /* _RAND_H_ */

View file

@ -33,26 +33,26 @@
* by hci_cmd_handle() and then used during the creation of cmd complete and * by hci_cmd_handle() and then used during the creation of cmd complete and
* cmd status events to avoid passing it up the call chain. * cmd status events to avoid passing it up the call chain.
*/ */
static uint16_t _opcode; static u16_t _opcode;
#if CONFIG_BLUETOOTH_CONTROLLER_DUP_FILTER_LEN > 0 #if CONFIG_BLUETOOTH_CONTROLLER_DUP_FILTER_LEN > 0
/* Scan duplicate filter */ /* Scan duplicate filter */
struct dup { struct dup {
uint8_t mask; u8_t mask;
bt_addr_le_t addr; bt_addr_le_t addr;
}; };
static struct dup dup_filter[CONFIG_BLUETOOTH_CONTROLLER_DUP_FILTER_LEN]; static struct dup dup_filter[CONFIG_BLUETOOTH_CONTROLLER_DUP_FILTER_LEN];
static int32_t dup_count; static s32_t dup_count;
static uint32_t dup_curr; static u32_t dup_curr;
#endif #endif
#define DEFAULT_EVENT_MASK 0x1fffffffffff #define DEFAULT_EVENT_MASK 0x1fffffffffff
#define DEFAULT_LE_EVENT_MASK 0x1f #define DEFAULT_LE_EVENT_MASK 0x1f
static uint64_t event_mask = DEFAULT_EVENT_MASK; static u64_t event_mask = DEFAULT_EVENT_MASK;
static uint64_t le_event_mask = DEFAULT_LE_EVENT_MASK; static u64_t le_event_mask = DEFAULT_LE_EVENT_MASK;
static void evt_create(struct net_buf *buf, uint8_t evt, uint8_t len) static void evt_create(struct net_buf *buf, u8_t evt, u8_t len)
{ {
struct bt_hci_evt_hdr *hdr; struct bt_hci_evt_hdr *hdr;
@ -61,7 +61,7 @@ static void evt_create(struct net_buf *buf, uint8_t evt, uint8_t len)
hdr->len = len; hdr->len = len;
} }
static void *cmd_complete(struct net_buf **buf, uint8_t plen) static void *cmd_complete(struct net_buf **buf, u8_t plen)
{ {
struct bt_hci_evt_cmd_complete *cc; struct bt_hci_evt_cmd_complete *cc;
@ -76,7 +76,7 @@ static void *cmd_complete(struct net_buf **buf, uint8_t plen)
return net_buf_add(*buf, plen); return net_buf_add(*buf, plen);
} }
static struct net_buf *cmd_status(uint8_t status) static struct net_buf *cmd_status(u8_t status)
{ {
struct bt_hci_evt_cmd_status *cs; struct bt_hci_evt_cmd_status *cs;
struct net_buf *buf; struct net_buf *buf;
@ -92,7 +92,7 @@ static struct net_buf *cmd_status(uint8_t status)
return buf; return buf;
} }
static void *meta_evt(struct net_buf *buf, uint8_t subevt, uint8_t melen) static void *meta_evt(struct net_buf *buf, u8_t subevt, u8_t melen)
{ {
struct bt_hci_evt_le_meta_event *me; struct bt_hci_evt_le_meta_event *me;
@ -106,8 +106,8 @@ static void *meta_evt(struct net_buf *buf, uint8_t subevt, uint8_t melen)
static void disconnect(struct net_buf *buf, struct net_buf **evt) static void disconnect(struct net_buf *buf, struct net_buf **evt)
{ {
struct bt_hci_cp_disconnect *cmd = (void *)buf->data; struct bt_hci_cp_disconnect *cmd = (void *)buf->data;
uint16_t handle; u16_t handle;
uint32_t status; u32_t status;
handle = sys_le16_to_cpu(cmd->handle); handle = sys_le16_to_cpu(cmd->handle);
status = ll_terminate_ind_send(handle, cmd->reason); status = ll_terminate_ind_send(handle, cmd->reason);
@ -118,8 +118,8 @@ static void disconnect(struct net_buf *buf, struct net_buf **evt)
static void read_remote_ver_info(struct net_buf *buf, struct net_buf **evt) static void read_remote_ver_info(struct net_buf *buf, struct net_buf **evt)
{ {
struct bt_hci_cp_read_remote_version_info *cmd = (void *)buf->data; struct bt_hci_cp_read_remote_version_info *cmd = (void *)buf->data;
uint16_t handle; u16_t handle;
uint32_t status; u32_t status;
handle = sys_le16_to_cpu(cmd->handle); handle = sys_le16_to_cpu(cmd->handle);
status = ll_version_ind_send(handle); status = ll_version_ind_send(handle);
@ -127,7 +127,7 @@ static void read_remote_ver_info(struct net_buf *buf, struct net_buf **evt)
*evt = cmd_status((!status) ? 0x00 : BT_HCI_ERR_CMD_DISALLOWED); *evt = cmd_status((!status) ? 0x00 : BT_HCI_ERR_CMD_DISALLOWED);
} }
static int link_control_cmd_handle(uint8_t ocf, struct net_buf *cmd, static int link_control_cmd_handle(u8_t ocf, struct net_buf *cmd,
struct net_buf **evt) struct net_buf **evt)
{ {
switch (ocf) { switch (ocf) {
@ -172,7 +172,7 @@ static void reset(struct net_buf *buf, struct net_buf **evt)
ccst->status = 0x00; ccst->status = 0x00;
} }
static int ctrl_bb_cmd_handle(uint8_t ocf, struct net_buf *cmd, static int ctrl_bb_cmd_handle(u8_t ocf, struct net_buf *cmd,
struct net_buf **evt) struct net_buf **evt)
{ {
switch (ocf) { switch (ocf) {
@ -276,7 +276,7 @@ static void read_bd_addr(struct net_buf *buf, struct net_buf **evt)
ll_address_get(0, &rp->bdaddr.val[0]); ll_address_get(0, &rp->bdaddr.val[0]);
} }
static int info_cmd_handle(uint8_t ocf, struct net_buf *cmd, static int info_cmd_handle(u8_t ocf, struct net_buf *cmd,
struct net_buf **evt) struct net_buf **evt)
{ {
switch (ocf) { switch (ocf) {
@ -355,10 +355,10 @@ static void le_set_adv_param(struct net_buf *buf, struct net_buf **evt)
{ {
struct bt_hci_cp_le_set_adv_param *cmd = (void *)buf->data; struct bt_hci_cp_le_set_adv_param *cmd = (void *)buf->data;
struct bt_hci_evt_cc_status *ccst; struct bt_hci_evt_cc_status *ccst;
uint8_t const c_adv_type[] = { u8_t const c_adv_type[] = {
PDU_ADV_TYPE_ADV_IND, PDU_ADV_TYPE_DIRECT_IND, PDU_ADV_TYPE_ADV_IND, PDU_ADV_TYPE_DIRECT_IND,
PDU_ADV_TYPE_SCAN_IND, PDU_ADV_TYPE_NONCONN_IND }; PDU_ADV_TYPE_SCAN_IND, PDU_ADV_TYPE_NONCONN_IND };
uint16_t min_interval; u16_t min_interval;
min_interval = sys_le16_to_cpu(cmd->min_interval); min_interval = sys_le16_to_cpu(cmd->min_interval);
@ -408,7 +408,7 @@ static void le_set_adv_enable(struct net_buf *buf, struct net_buf **evt)
{ {
struct bt_hci_cp_le_set_adv_enable *cmd = (void *)buf->data; struct bt_hci_cp_le_set_adv_enable *cmd = (void *)buf->data;
struct bt_hci_evt_cc_status *ccst; struct bt_hci_evt_cc_status *ccst;
uint32_t status; u32_t status;
status = ll_adv_enable(cmd->enable); status = ll_adv_enable(cmd->enable);
@ -420,8 +420,8 @@ static void le_set_scan_param(struct net_buf *buf, struct net_buf **evt)
{ {
struct bt_hci_cp_le_set_scan_param *cmd = (void *)buf->data; struct bt_hci_cp_le_set_scan_param *cmd = (void *)buf->data;
struct bt_hci_evt_cc_status *ccst; struct bt_hci_evt_cc_status *ccst;
uint16_t interval; u16_t interval;
uint16_t window; u16_t window;
interval = sys_le16_to_cpu(cmd->interval); interval = sys_le16_to_cpu(cmd->interval);
window = sys_le16_to_cpu(cmd->window); window = sys_le16_to_cpu(cmd->window);
@ -437,7 +437,7 @@ static void le_set_scan_enable(struct net_buf *buf, struct net_buf **evt)
{ {
struct bt_hci_cp_le_set_scan_enable *cmd = (void *)buf->data; struct bt_hci_cp_le_set_scan_enable *cmd = (void *)buf->data;
struct bt_hci_evt_cc_status *ccst; struct bt_hci_evt_cc_status *ccst;
uint32_t status; u32_t status;
#if CONFIG_BLUETOOTH_CONTROLLER_DUP_FILTER_LEN > 0 #if CONFIG_BLUETOOTH_CONTROLLER_DUP_FILTER_LEN > 0
/* initialize duplicate filtering */ /* initialize duplicate filtering */
@ -457,12 +457,12 @@ static void le_set_scan_enable(struct net_buf *buf, struct net_buf **evt)
static void le_create_connection(struct net_buf *buf, struct net_buf **evt) static void le_create_connection(struct net_buf *buf, struct net_buf **evt)
{ {
struct bt_hci_cp_le_create_conn *cmd = (void *)buf->data; struct bt_hci_cp_le_create_conn *cmd = (void *)buf->data;
uint16_t supervision_timeout; u16_t supervision_timeout;
uint16_t conn_interval_max; u16_t conn_interval_max;
uint16_t scan_interval; u16_t scan_interval;
uint16_t conn_latency; u16_t conn_latency;
uint16_t scan_window; u16_t scan_window;
uint32_t status; u32_t status;
scan_interval = sys_le16_to_cpu(cmd->scan_interval); scan_interval = sys_le16_to_cpu(cmd->scan_interval);
scan_window = sys_le16_to_cpu(cmd->scan_window); scan_window = sys_le16_to_cpu(cmd->scan_window);
@ -483,7 +483,7 @@ static void le_create_connection(struct net_buf *buf, struct net_buf **evt)
static void le_create_conn_cancel(struct net_buf *buf, struct net_buf **evt) static void le_create_conn_cancel(struct net_buf *buf, struct net_buf **evt)
{ {
struct bt_hci_evt_cc_status *ccst; struct bt_hci_evt_cc_status *ccst;
uint32_t status; u32_t status;
status = ll_connect_disable(); status = ll_connect_disable();
@ -515,7 +515,7 @@ static void le_add_dev_to_wl(struct net_buf *buf, struct net_buf **evt)
{ {
struct bt_hci_cp_le_add_dev_to_wl *cmd = (void *)buf->data; struct bt_hci_cp_le_add_dev_to_wl *cmd = (void *)buf->data;
struct bt_hci_evt_cc_status *ccst; struct bt_hci_evt_cc_status *ccst;
uint32_t status; u32_t status;
status = ll_filter_add(cmd->addr.type, &cmd->addr.a.val[0]); status = ll_filter_add(cmd->addr.type, &cmd->addr.a.val[0]);
@ -527,7 +527,7 @@ static void le_rem_dev_from_wl(struct net_buf *buf, struct net_buf **evt)
{ {
struct bt_hci_cp_le_rem_dev_from_wl *cmd = (void *)buf->data; struct bt_hci_cp_le_rem_dev_from_wl *cmd = (void *)buf->data;
struct bt_hci_evt_cc_status *ccst; struct bt_hci_evt_cc_status *ccst;
uint32_t status; u32_t status;
status = ll_filter_remove(cmd->addr.type, &cmd->addr.a.val[0]); status = ll_filter_remove(cmd->addr.type, &cmd->addr.a.val[0]);
@ -538,11 +538,11 @@ static void le_rem_dev_from_wl(struct net_buf *buf, struct net_buf **evt)
static void le_conn_update(struct net_buf *buf, struct net_buf **evt) static void le_conn_update(struct net_buf *buf, struct net_buf **evt)
{ {
struct hci_cp_le_conn_update *cmd = (void *)buf->data; struct hci_cp_le_conn_update *cmd = (void *)buf->data;
uint16_t supervision_timeout; u16_t supervision_timeout;
uint16_t conn_interval_max; u16_t conn_interval_max;
uint16_t conn_latency; u16_t conn_latency;
uint32_t status; u32_t status;
uint16_t handle; u16_t handle;
handle = sys_le16_to_cpu(cmd->handle); handle = sys_le16_to_cpu(cmd->handle);
conn_interval_max = sys_le16_to_cpu(cmd->conn_interval_max); conn_interval_max = sys_le16_to_cpu(cmd->conn_interval_max);
@ -562,7 +562,7 @@ static void le_set_host_chan_classif(struct net_buf *buf, struct net_buf **evt)
{ {
struct bt_hci_cp_le_set_host_chan_classif *cmd = (void *)buf->data; struct bt_hci_cp_le_set_host_chan_classif *cmd = (void *)buf->data;
struct bt_hci_evt_cc_status *ccst; struct bt_hci_evt_cc_status *ccst;
uint32_t status; u32_t status;
status = ll_chm_update(&cmd->ch_map[0]); status = ll_chm_update(&cmd->ch_map[0]);
@ -573,8 +573,8 @@ static void le_set_host_chan_classif(struct net_buf *buf, struct net_buf **evt)
static void le_read_remote_features(struct net_buf *buf, struct net_buf **evt) static void le_read_remote_features(struct net_buf *buf, struct net_buf **evt)
{ {
struct bt_hci_cp_le_read_remote_features *cmd = (void *)buf->data; struct bt_hci_cp_le_read_remote_features *cmd = (void *)buf->data;
uint32_t status; u32_t status;
uint16_t handle; u16_t handle;
handle = sys_le16_to_cpu(cmd->handle); handle = sys_le16_to_cpu(cmd->handle);
status = ll_feature_req_send(handle); status = ll_feature_req_send(handle);
@ -586,7 +586,7 @@ static void le_encrypt(struct net_buf *buf, struct net_buf **evt)
{ {
struct bt_hci_cp_le_encrypt *cmd = (void *)buf->data; struct bt_hci_cp_le_encrypt *cmd = (void *)buf->data;
struct bt_hci_rp_le_encrypt *rp; struct bt_hci_rp_le_encrypt *rp;
uint8_t enc_data[16]; u8_t enc_data[16];
ecb_encrypt(cmd->key, cmd->plaintext, enc_data, NULL); ecb_encrypt(cmd->key, cmd->plaintext, enc_data, NULL);
@ -599,7 +599,7 @@ static void le_encrypt(struct net_buf *buf, struct net_buf **evt)
static void le_rand(struct net_buf *buf, struct net_buf **evt) static void le_rand(struct net_buf *buf, struct net_buf **evt)
{ {
struct bt_hci_rp_le_rand *rp; struct bt_hci_rp_le_rand *rp;
uint8_t count = sizeof(rp->rand); u8_t count = sizeof(rp->rand);
rp = cmd_complete(evt, sizeof(*rp)); rp = cmd_complete(evt, sizeof(*rp));
rp->status = 0x00; rp->status = 0x00;
@ -610,13 +610,13 @@ static void le_rand(struct net_buf *buf, struct net_buf **evt)
static void le_start_encryption(struct net_buf *buf, struct net_buf **evt) static void le_start_encryption(struct net_buf *buf, struct net_buf **evt)
{ {
struct bt_hci_cp_le_start_encryption *cmd = (void *)buf->data; struct bt_hci_cp_le_start_encryption *cmd = (void *)buf->data;
uint32_t status; u32_t status;
uint16_t handle; u16_t handle;
handle = sys_le16_to_cpu(cmd->handle); handle = sys_le16_to_cpu(cmd->handle);
status = ll_enc_req_send(handle, status = ll_enc_req_send(handle,
(uint8_t *)&cmd->rand, (u8_t *)&cmd->rand,
(uint8_t *)&cmd->ediv, (u8_t *)&cmd->ediv,
&cmd->ltk[0]); &cmd->ltk[0]);
*evt = cmd_status((!status) ? 0x00 : BT_HCI_ERR_CMD_DISALLOWED); *evt = cmd_status((!status) ? 0x00 : BT_HCI_ERR_CMD_DISALLOWED);
@ -626,8 +626,8 @@ static void le_ltk_req_reply(struct net_buf *buf, struct net_buf **evt)
{ {
struct bt_hci_cp_le_ltk_req_reply *cmd = (void *)buf->data; struct bt_hci_cp_le_ltk_req_reply *cmd = (void *)buf->data;
struct bt_hci_rp_le_ltk_req_reply *rp; struct bt_hci_rp_le_ltk_req_reply *rp;
uint32_t status; u32_t status;
uint16_t handle; u16_t handle;
handle = sys_le16_to_cpu(cmd->handle); handle = sys_le16_to_cpu(cmd->handle);
status = ll_start_enc_req_send(handle, 0x00, &cmd->ltk[0]); status = ll_start_enc_req_send(handle, 0x00, &cmd->ltk[0]);
@ -641,8 +641,8 @@ static void le_ltk_req_neg_reply(struct net_buf *buf, struct net_buf **evt)
{ {
struct bt_hci_cp_le_ltk_req_neg_reply *cmd = (void *)buf->data; struct bt_hci_cp_le_ltk_req_neg_reply *cmd = (void *)buf->data;
struct bt_hci_rp_le_ltk_req_neg_reply *rp; struct bt_hci_rp_le_ltk_req_neg_reply *rp;
uint32_t status; u32_t status;
uint16_t handle; u16_t handle;
handle = sys_le16_to_cpu(cmd->handle); handle = sys_le16_to_cpu(cmd->handle);
status = ll_start_enc_req_send(handle, BT_HCI_ERR_PIN_OR_KEY_MISSING, status = ll_start_enc_req_send(handle, BT_HCI_ERR_PIN_OR_KEY_MISSING,
@ -667,11 +667,11 @@ static void le_conn_param_req_reply(struct net_buf *buf, struct net_buf **evt)
{ {
struct bt_hci_cp_le_conn_param_req_reply *cmd = (void *)buf->data; struct bt_hci_cp_le_conn_param_req_reply *cmd = (void *)buf->data;
struct bt_hci_rp_le_conn_param_req_reply *rp; struct bt_hci_rp_le_conn_param_req_reply *rp;
uint16_t interval_max; u16_t interval_max;
uint16_t latency; u16_t latency;
uint16_t timeout; u16_t timeout;
uint32_t status; u32_t status;
uint16_t handle; u16_t handle;
handle = sys_le16_to_cpu(cmd->handle); handle = sys_le16_to_cpu(cmd->handle);
interval_max = sys_le16_to_cpu(cmd->interval_max); interval_max = sys_le16_to_cpu(cmd->interval_max);
@ -691,8 +691,8 @@ static void le_conn_param_req_neg_reply(struct net_buf *buf,
{ {
struct bt_hci_cp_le_conn_param_req_neg_reply *cmd = (void *)buf->data; struct bt_hci_cp_le_conn_param_req_neg_reply *cmd = (void *)buf->data;
struct bt_hci_rp_le_conn_param_req_neg_reply *rp; struct bt_hci_rp_le_conn_param_req_neg_reply *rp;
uint32_t status; u32_t status;
uint16_t handle; u16_t handle;
handle = sys_le16_to_cpu(cmd->handle); handle = sys_le16_to_cpu(cmd->handle);
status = ll_conn_update(handle, 2, cmd->reason, 0, 0, 0); status = ll_conn_update(handle, 2, cmd->reason, 0, 0, 0);
@ -707,9 +707,9 @@ static void le_set_data_len(struct net_buf *buf, struct net_buf **evt)
{ {
struct bt_hci_cp_le_set_data_len *cmd = (void *)buf->data; struct bt_hci_cp_le_set_data_len *cmd = (void *)buf->data;
struct bt_hci_rp_le_set_data_len *rp; struct bt_hci_rp_le_set_data_len *rp;
uint32_t status; u32_t status;
uint16_t tx_octets; u16_t tx_octets;
uint16_t handle; u16_t handle;
handle = sys_le16_to_cpu(cmd->handle); handle = sys_le16_to_cpu(cmd->handle);
tx_octets = sys_le16_to_cpu(cmd->tx_octets); tx_octets = sys_le16_to_cpu(cmd->tx_octets);
@ -736,7 +736,7 @@ static void le_write_default_data_len(struct net_buf *buf,
{ {
struct bt_hci_cp_le_write_default_data_len *cmd = (void *)buf->data; struct bt_hci_cp_le_write_default_data_len *cmd = (void *)buf->data;
struct bt_hci_evt_cc_status *ccst; struct bt_hci_evt_cc_status *ccst;
uint32_t status; u32_t status;
status = ll_length_default_set(cmd->max_tx_octets, cmd->max_tx_time); status = ll_length_default_set(cmd->max_tx_octets, cmd->max_tx_time);
@ -756,7 +756,7 @@ static void le_read_max_data_len(struct net_buf *buf, struct net_buf **evt)
} }
#endif /* CONFIG_BLUETOOTH_CONTROLLER_DATA_LENGTH */ #endif /* CONFIG_BLUETOOTH_CONTROLLER_DATA_LENGTH */
static int controller_cmd_handle(uint8_t ocf, struct net_buf *cmd, static int controller_cmd_handle(u8_t ocf, struct net_buf *cmd,
struct net_buf **evt) struct net_buf **evt)
{ {
switch (ocf) { switch (ocf) {
@ -902,7 +902,7 @@ struct net_buf *hci_cmd_handle(struct net_buf *cmd)
struct bt_hci_evt_cc_status *ccst; struct bt_hci_evt_cc_status *ccst;
struct bt_hci_cmd_hdr *chdr; struct bt_hci_cmd_hdr *chdr;
struct net_buf *evt = NULL; struct net_buf *evt = NULL;
uint8_t ocf; u8_t ocf;
int err; int err;
if (cmd->len < sizeof(*chdr)) { if (cmd->len < sizeof(*chdr)) {
@ -956,9 +956,9 @@ int hci_acl_handle(struct net_buf *buf)
{ {
struct radio_pdu_node_tx *radio_pdu_node_tx; struct radio_pdu_node_tx *radio_pdu_node_tx;
struct bt_hci_acl_hdr *acl; struct bt_hci_acl_hdr *acl;
uint16_t handle; u16_t handle;
uint8_t flags; u8_t flags;
uint16_t len; u16_t len;
if (buf->len < sizeof(*acl)) { if (buf->len < sizeof(*acl)) {
BT_ERR("No HCI ACL header"); BT_ERR("No HCI ACL header");
@ -999,17 +999,17 @@ int hci_acl_handle(struct net_buf *buf)
return 0; return 0;
} }
static void le_advertising_report(struct pdu_data *pdu_data, uint8_t *b, static void le_advertising_report(struct pdu_data *pdu_data, u8_t *b,
struct net_buf *buf) struct net_buf *buf)
{ {
const uint8_t c_adv_type[] = { 0x00, 0x01, 0x03, 0xff, 0x04, const u8_t c_adv_type[] = { 0x00, 0x01, 0x03, 0xff, 0x04,
0xff, 0x02 }; 0xff, 0x02 };
struct bt_hci_ev_le_advertising_report *sep; struct bt_hci_ev_le_advertising_report *sep;
struct pdu_adv *adv = (struct pdu_adv *)pdu_data; struct pdu_adv *adv = (struct pdu_adv *)pdu_data;
struct bt_hci_ev_le_advertising_info *adv_info; struct bt_hci_ev_le_advertising_info *adv_info;
uint8_t data_len; u8_t data_len;
uint8_t *rssi; u8_t *rssi;
uint8_t info_len; u8_t info_len;
if (!(event_mask & BT_EVT_MASK_LE_META_EVENT) || if (!(event_mask & BT_EVT_MASK_LE_META_EVENT) ||
!(le_event_mask & BT_EVT_MASK_LE_ADVERTISING_REPORT)) { !(le_event_mask & BT_EVT_MASK_LE_ADVERTISING_REPORT)) {
@ -1069,7 +1069,7 @@ fill_report:
sizeof(*sep) + info_len); sizeof(*sep) + info_len);
sep->num_reports = 1; sep->num_reports = 1;
adv_info = (void *)(((uint8_t *)sep) + sizeof(*sep)); adv_info = (void *)(((u8_t *)sep) + sizeof(*sep));
adv_info->evt_type = c_adv_type[adv->type]; adv_info->evt_type = c_adv_type[adv->type];
adv_info->addr.type = adv->tx_addr; adv_info->addr.type = adv->tx_addr;
@ -1085,7 +1085,7 @@ fill_report:
} }
static void le_conn_complete(struct pdu_data *pdu_data, uint16_t handle, static void le_conn_complete(struct pdu_data *pdu_data, u16_t handle,
struct net_buf *buf) struct net_buf *buf)
{ {
struct bt_hci_evt_le_conn_complete *sep; struct bt_hci_evt_le_conn_complete *sep;
@ -1111,7 +1111,7 @@ static void le_conn_complete(struct pdu_data *pdu_data, uint16_t handle,
sep->clock_accuracy = radio_cc->mca; sep->clock_accuracy = radio_cc->mca;
} }
static void disconn_complete(struct pdu_data *pdu_data, uint16_t handle, static void disconn_complete(struct pdu_data *pdu_data, u16_t handle,
struct net_buf *buf) struct net_buf *buf)
{ {
struct bt_hci_evt_disconn_complete *ep; struct bt_hci_evt_disconn_complete *ep;
@ -1125,10 +1125,10 @@ static void disconn_complete(struct pdu_data *pdu_data, uint16_t handle,
ep->status = 0x00; ep->status = 0x00;
ep->handle = sys_cpu_to_le16(handle); ep->handle = sys_cpu_to_le16(handle);
ep->reason = *((uint8_t *)pdu_data); ep->reason = *((u8_t *)pdu_data);
} }
static void le_conn_update_complete(struct pdu_data *pdu_data, uint16_t handle, static void le_conn_update_complete(struct pdu_data *pdu_data, u16_t handle,
struct net_buf *buf) struct net_buf *buf)
{ {
struct bt_hci_evt_le_conn_update_complete *sep; struct bt_hci_evt_le_conn_update_complete *sep;
@ -1151,7 +1151,7 @@ static void le_conn_update_complete(struct pdu_data *pdu_data, uint16_t handle,
sep->supv_timeout = sys_cpu_to_le16(radio_cu->timeout); sep->supv_timeout = sys_cpu_to_le16(radio_cu->timeout);
} }
static void enc_refresh_complete(struct pdu_data *pdu_data, uint16_t handle, static void enc_refresh_complete(struct pdu_data *pdu_data, u16_t handle,
struct net_buf *buf) struct net_buf *buf)
{ {
struct bt_hci_evt_encrypt_key_refresh_complete *ep; struct bt_hci_evt_encrypt_key_refresh_complete *ep;
@ -1168,7 +1168,7 @@ static void enc_refresh_complete(struct pdu_data *pdu_data, uint16_t handle,
} }
#if defined(CONFIG_BLUETOOTH_CONTROLLER_LE_PING) #if defined(CONFIG_BLUETOOTH_CONTROLLER_LE_PING)
static void auth_payload_timeout_exp(struct pdu_data *pdu_data, uint16_t handle, static void auth_payload_timeout_exp(struct pdu_data *pdu_data, u16_t handle,
struct net_buf *buf) struct net_buf *buf)
{ {
struct bt_hci_evt_auth_payload_timeout_exp *ep; struct bt_hci_evt_auth_payload_timeout_exp *ep;
@ -1181,7 +1181,7 @@ static void auth_payload_timeout_exp(struct pdu_data *pdu_data, uint16_t handle,
#endif /* CONFIG_BLUETOOTH_CONTROLLER_LE_PING */ #endif /* CONFIG_BLUETOOTH_CONTROLLER_LE_PING */
#if defined(CONFIG_BLUETOOTH_CONTROLLER_CHAN_SEL_2) #if defined(CONFIG_BLUETOOTH_CONTROLLER_CHAN_SEL_2)
static void le_chan_sel_algo(struct pdu_data *pdu_data, uint16_t handle, static void le_chan_sel_algo(struct pdu_data *pdu_data, u16_t handle,
struct net_buf *buf) struct net_buf *buf)
{ {
struct bt_hci_evt_le_chan_sel_algo *sep; struct bt_hci_evt_le_chan_sel_algo *sep;
@ -1205,8 +1205,8 @@ static void le_chan_sel_algo(struct pdu_data *pdu_data, uint16_t handle,
static void encode_control(struct radio_pdu_node_rx *node_rx, static void encode_control(struct radio_pdu_node_rx *node_rx,
struct pdu_data *pdu_data, struct net_buf *buf) struct pdu_data *pdu_data, struct net_buf *buf)
{ {
uint8_t *b = (uint8_t *)node_rx; u8_t *b = (u8_t *)node_rx;
uint16_t handle; u16_t handle;
handle = node_rx->hdr.handle; handle = node_rx->hdr.handle;
@ -1274,7 +1274,7 @@ static void encode_control(struct radio_pdu_node_rx *node_rx,
} }
} }
static void le_ltk_request(struct pdu_data *pdu_data, uint16_t handle, static void le_ltk_request(struct pdu_data *pdu_data, u16_t handle,
struct net_buf *buf) struct net_buf *buf)
{ {
struct bt_hci_evt_le_ltk_request *sep; struct bt_hci_evt_le_ltk_request *sep;
@ -1288,12 +1288,12 @@ static void le_ltk_request(struct pdu_data *pdu_data, uint16_t handle,
sep->handle = sys_cpu_to_le16(handle); sep->handle = sys_cpu_to_le16(handle);
memcpy(&sep->rand, pdu_data->payload.llctrl.ctrldata.enc_req.rand, memcpy(&sep->rand, pdu_data->payload.llctrl.ctrldata.enc_req.rand,
sizeof(uint64_t)); sizeof(u64_t));
memcpy(&sep->ediv, pdu_data->payload.llctrl.ctrldata.enc_req.ediv, memcpy(&sep->ediv, pdu_data->payload.llctrl.ctrldata.enc_req.ediv,
sizeof(uint16_t)); sizeof(u16_t));
} }
static void encrypt_change(uint8_t err, uint16_t handle, static void encrypt_change(u8_t err, u16_t handle,
struct net_buf *buf) struct net_buf *buf)
{ {
struct bt_hci_evt_encrypt_change *ep; struct bt_hci_evt_encrypt_change *ep;
@ -1310,8 +1310,8 @@ static void encrypt_change(uint8_t err, uint16_t handle,
ep->encrypt = !err ? 1 : 0; ep->encrypt = !err ? 1 : 0;
} }
static void le_remote_feat_complete(uint8_t status, struct pdu_data *pdu_data, static void le_remote_feat_complete(u8_t status, struct pdu_data *pdu_data,
uint16_t handle, struct net_buf *buf) u16_t handle, struct net_buf *buf)
{ {
struct bt_hci_ev_le_remote_feat_complete *sep; struct bt_hci_ev_le_remote_feat_complete *sep;
@ -1333,7 +1333,7 @@ static void le_remote_feat_complete(uint8_t status, struct pdu_data *pdu_data,
} }
} }
static void le_unknown_rsp(struct pdu_data *pdu_data, uint16_t handle, static void le_unknown_rsp(struct pdu_data *pdu_data, u16_t handle,
struct net_buf *buf) struct net_buf *buf)
{ {
@ -1350,7 +1350,7 @@ static void le_unknown_rsp(struct pdu_data *pdu_data, uint16_t handle,
} }
} }
static void remote_version_info(struct pdu_data *pdu_data, uint16_t handle, static void remote_version_info(struct pdu_data *pdu_data, u16_t handle,
struct net_buf *buf) struct net_buf *buf)
{ {
struct bt_hci_evt_remote_version_info *ep; struct bt_hci_evt_remote_version_info *ep;
@ -1372,7 +1372,7 @@ static void remote_version_info(struct pdu_data *pdu_data, uint16_t handle,
pdu_data->payload.llctrl.ctrldata.version_ind.sub_version_number; pdu_data->payload.llctrl.ctrldata.version_ind.sub_version_number;
} }
static void le_conn_param_req(struct pdu_data *pdu_data, uint16_t handle, static void le_conn_param_req(struct pdu_data *pdu_data, u16_t handle,
struct net_buf *buf) struct net_buf *buf)
{ {
struct bt_hci_evt_le_conn_param_req *sep; struct bt_hci_evt_le_conn_param_req *sep;
@ -1393,7 +1393,7 @@ static void le_conn_param_req(struct pdu_data *pdu_data, uint16_t handle,
sep->timeout = pdu_data->payload.llctrl.ctrldata.conn_param_req.timeout; sep->timeout = pdu_data->payload.llctrl.ctrldata.conn_param_req.timeout;
} }
static void le_data_len_change(struct pdu_data *pdu_data, uint16_t handle, static void le_data_len_change(struct pdu_data *pdu_data, u16_t handle,
struct net_buf *buf) struct net_buf *buf)
{ {
struct bt_hci_evt_le_data_len_change *sep; struct bt_hci_evt_le_data_len_change *sep;
@ -1419,7 +1419,7 @@ static void le_data_len_change(struct pdu_data *pdu_data, uint16_t handle,
static void encode_data_ctrl(struct radio_pdu_node_rx *node_rx, static void encode_data_ctrl(struct radio_pdu_node_rx *node_rx,
struct pdu_data *pdu_data, struct net_buf *buf) struct pdu_data *pdu_data, struct net_buf *buf)
{ {
uint16_t handle = node_rx->hdr.handle; u16_t handle = node_rx->hdr.handle;
switch (pdu_data->payload.llctrl.opcode) { switch (pdu_data->payload.llctrl.opcode) {
case PDU_DATA_LLCTRL_TYPE_ENC_REQ: case PDU_DATA_LLCTRL_TYPE_ENC_REQ:
@ -1467,9 +1467,9 @@ void hci_acl_encode(struct radio_pdu_node_rx *node_rx, struct net_buf *buf)
{ {
struct bt_hci_acl_hdr *acl; struct bt_hci_acl_hdr *acl;
struct pdu_data *pdu_data; struct pdu_data *pdu_data;
uint16_t handle_flags; u16_t handle_flags;
uint16_t handle; u16_t handle;
uint8_t *data; u8_t *data;
pdu_data = (struct pdu_data *)node_rx->pdu_data; pdu_data = (struct pdu_data *)node_rx->pdu_data;
handle = node_rx->hdr.handle; handle = node_rx->hdr.handle;
@ -1509,12 +1509,12 @@ void hci_evt_encode(struct radio_pdu_node_rx *node_rx, struct net_buf *buf)
} }
} }
void hci_num_cmplt_encode(struct net_buf *buf, uint16_t handle, uint8_t num) void hci_num_cmplt_encode(struct net_buf *buf, u16_t handle, u8_t num)
{ {
struct bt_hci_evt_num_completed_packets *ep; struct bt_hci_evt_num_completed_packets *ep;
struct bt_hci_handle_count *hc; struct bt_hci_handle_count *hc;
uint8_t num_handles; u8_t num_handles;
uint8_t len; u8_t len;
num_handles = 1; num_handles = 1;

View file

@ -47,8 +47,8 @@ static BT_STACK_NOINIT(prio_recv_thread_stack,
static BT_STACK_NOINIT(recv_thread_stack, CONFIG_BLUETOOTH_RX_STACK_SIZE); static BT_STACK_NOINIT(recv_thread_stack, CONFIG_BLUETOOTH_RX_STACK_SIZE);
#if defined(CONFIG_INIT_STACKS) #if defined(CONFIG_INIT_STACKS)
static uint32_t prio_ts; static u32_t prio_ts;
static uint32_t rx_ts; static u32_t rx_ts;
#endif #endif
static void prio_recv_thread(void *p1, void *p2, void *p3) static void prio_recv_thread(void *p1, void *p2, void *p3)
@ -56,8 +56,8 @@ static void prio_recv_thread(void *p1, void *p2, void *p3)
while (1) { while (1) {
struct radio_pdu_node_rx *node_rx; struct radio_pdu_node_rx *node_rx;
struct net_buf *buf; struct net_buf *buf;
uint8_t num_cmplt; u8_t num_cmplt;
uint16_t handle; u16_t handle;
while ((num_cmplt = radio_rx_get(&node_rx, &handle))) { while ((num_cmplt = radio_rx_get(&node_rx, &handle))) {
@ -173,7 +173,7 @@ static int cmd_handle(struct net_buf *buf)
static int hci_driver_send(struct net_buf *buf) static int hci_driver_send(struct net_buf *buf)
{ {
uint8_t type; u8_t type;
int err; int err;
BT_DBG("enter"); BT_DBG("enter");
@ -207,7 +207,7 @@ static int hci_driver_send(struct net_buf *buf)
static int hci_driver_open(void) static int hci_driver_open(void)
{ {
uint32_t err; u32_t err;
DEBUG_INIT(); DEBUG_INIT();

View file

@ -12,6 +12,6 @@ struct net_buf *hci_cmd_handle(struct net_buf *cmd);
int hci_acl_handle(struct net_buf *acl); int hci_acl_handle(struct net_buf *acl);
void hci_evt_encode(struct radio_pdu_node_rx *node_rx, struct net_buf *buf); void hci_evt_encode(struct radio_pdu_node_rx *node_rx, struct net_buf *buf);
void hci_acl_encode(struct radio_pdu_node_rx *node_rx, struct net_buf *buf); void hci_acl_encode(struct radio_pdu_node_rx *node_rx, struct net_buf *buf);
void hci_num_cmplt_encode(struct net_buf *buf, uint16_t handle, uint8_t num); void hci_num_cmplt_encode(struct net_buf *buf, u16_t handle, u8_t num);
bool hci_evt_is_discardable(struct radio_pdu_node_rx *node_rx); bool hci_evt_is_discardable(struct radio_pdu_node_rx *node_rx);
#endif /* _HCI_CONTROLLER_H_ */ #endif /* _HCI_CONTROLLER_H_ */

View file

@ -10,49 +10,49 @@
int ll_init(struct k_sem *sem_rx); int ll_init(struct k_sem *sem_rx);
void ll_reset(void); void ll_reset(void);
void ll_address_get(uint8_t addr_type, uint8_t *p_bdaddr); void ll_address_get(u8_t addr_type, u8_t *p_bdaddr);
void ll_address_set(uint8_t addr_type, uint8_t const *const p_bdaddr); void ll_address_set(u8_t addr_type, u8_t const *const p_bdaddr);
void ll_adv_params_set(uint16_t interval, uint8_t adv_type, void ll_adv_params_set(u16_t interval, u8_t adv_type,
uint8_t own_addr_type, uint8_t direct_addr_type, u8_t own_addr_type, u8_t direct_addr_type,
uint8_t const *const p_direct_addr, uint8_t chl_map, u8_t const *const p_direct_addr, u8_t chl_map,
uint8_t filter_policy); u8_t filter_policy);
void ll_adv_data_set(uint8_t len, uint8_t const *const p_data); void ll_adv_data_set(u8_t len, u8_t const *const p_data);
void ll_scan_data_set(uint8_t len, uint8_t const *const p_data); void ll_scan_data_set(u8_t len, u8_t const *const p_data);
uint32_t ll_adv_enable(uint8_t enable); u32_t ll_adv_enable(u8_t enable);
void ll_scan_params_set(uint8_t scan_type, uint16_t interval, uint16_t window, void ll_scan_params_set(u8_t scan_type, u16_t interval, u16_t window,
uint8_t own_addr_type, uint8_t filter_policy); u8_t own_addr_type, u8_t filter_policy);
uint32_t ll_scan_enable(uint8_t enable); u32_t ll_scan_enable(u8_t enable);
void ll_filter_clear(void); void ll_filter_clear(void);
uint32_t ll_filter_add(uint8_t addr_type, uint8_t *addr); u32_t ll_filter_add(u8_t addr_type, u8_t *addr);
uint32_t ll_filter_remove(uint8_t addr_type, uint8_t *addr); u32_t ll_filter_remove(u8_t addr_type, u8_t *addr);
void ll_irk_clear(void); void ll_irk_clear(void);
uint32_t ll_irk_add(uint8_t *irk); u32_t ll_irk_add(u8_t *irk);
uint32_t ll_create_connection(uint16_t scan_interval, uint16_t scan_window, u32_t ll_create_connection(u16_t scan_interval, u16_t scan_window,
uint8_t filter_policy, uint8_t peer_addr_type, u8_t filter_policy, u8_t peer_addr_type,
uint8_t *p_peer_addr, uint8_t own_addr_type, u8_t *p_peer_addr, u8_t own_addr_type,
uint16_t interval, uint16_t latency, u16_t interval, u16_t latency,
uint16_t timeout); u16_t timeout);
uint32_t ll_connect_disable(void); u32_t ll_connect_disable(void);
uint32_t ll_conn_update(uint16_t handle, uint8_t cmd, uint8_t status, u32_t ll_conn_update(u16_t handle, u8_t cmd, u8_t status,
uint16_t interval, uint16_t latency, u16_t interval, u16_t latency,
uint16_t timeout); u16_t timeout);
uint32_t ll_chm_update(uint8_t *chm); u32_t ll_chm_update(u8_t *chm);
uint32_t ll_chm_get(uint16_t handle, uint8_t *chm); u32_t ll_chm_get(u16_t handle, u8_t *chm);
uint32_t ll_enc_req_send(uint16_t handle, uint8_t *rand, uint8_t *ediv, u32_t ll_enc_req_send(u16_t handle, u8_t *rand, u8_t *ediv,
uint8_t *ltk); u8_t *ltk);
uint32_t ll_start_enc_req_send(uint16_t handle, uint8_t err_code, u32_t ll_start_enc_req_send(u16_t handle, u8_t err_code,
uint8_t const *const ltk); u8_t const *const ltk);
uint32_t ll_feature_req_send(uint16_t handle); u32_t ll_feature_req_send(u16_t handle);
uint32_t ll_version_ind_send(uint16_t handle); u32_t ll_version_ind_send(u16_t handle);
uint32_t ll_terminate_ind_send(uint16_t handle, uint8_t reason); u32_t ll_terminate_ind_send(u16_t handle, u8_t reason);
#if defined(CONFIG_BLUETOOTH_CONTROLLER_DATA_LENGTH) #if defined(CONFIG_BLUETOOTH_CONTROLLER_DATA_LENGTH)
uint32_t ll_length_req_send(uint16_t handle, uint16_t tx_octets); u32_t ll_length_req_send(u16_t handle, u16_t tx_octets);
void ll_length_default_get(uint16_t *max_tx_octets, uint16_t *max_tx_time); void ll_length_default_get(u16_t *max_tx_octets, u16_t *max_tx_time);
uint32_t ll_length_default_set(uint16_t max_tx_octets, uint16_t max_tx_time); u32_t ll_length_default_set(u16_t max_tx_octets, u16_t max_tx_time);
void ll_length_max_get(uint16_t *max_tx_octets, uint16_t *max_tx_time, void ll_length_max_get(u16_t *max_tx_octets, u16_t *max_tx_time,
uint16_t *max_rx_octets, uint16_t *max_rx_time); u16_t *max_rx_octets, u16_t *max_rx_time);
#endif /* CONFIG_BLUETOOTH_CONTROLLER_DATA_LENGTH */ #endif /* CONFIG_BLUETOOTH_CONTROLLER_DATA_LENGTH */
#endif /* _LL_H_ */ #endif /* _LL_H_ */

View file

@ -29,8 +29,8 @@ int bt_rand(void *buf, size_t len)
return 0; return 0;
} }
int bt_encrypt_le(const uint8_t key[16], const uint8_t plaintext[16], int bt_encrypt_le(const u8_t key[16], const u8_t plaintext[16],
uint8_t enc_data[16]) u8_t enc_data[16])
{ {
BT_DBG("key %s plaintext %s", bt_hex(key, 16), bt_hex(plaintext, 16)); BT_DBG("key %s plaintext %s", bt_hex(key, 16), bt_hex(plaintext, 16));
@ -41,8 +41,8 @@ int bt_encrypt_le(const uint8_t key[16], const uint8_t plaintext[16],
return 0; return 0;
} }
int bt_encrypt_be(const uint8_t key[16], const uint8_t plaintext[16], int bt_encrypt_be(const u8_t key[16], const u8_t plaintext[16],
uint8_t enc_data[16]) u8_t enc_data[16])
{ {
BT_DBG("key %s plaintext %s", bt_hex(key, 16), bt_hex(plaintext, 16)); BT_DBG("key %s plaintext %s", bt_hex(key, 16), bt_hex(plaintext, 16));

File diff suppressed because it is too large Load diff

View file

@ -185,14 +185,14 @@
* Controller Interface Structures * Controller Interface Structures
****************************************************************************/ ****************************************************************************/
struct radio_adv_data { struct radio_adv_data {
uint8_t data[DOUBLE_BUFFER_SIZE][PDU_AC_SIZE_MAX]; u8_t data[DOUBLE_BUFFER_SIZE][PDU_AC_SIZE_MAX];
uint8_t first; u8_t first;
uint8_t last; u8_t last;
}; };
struct radio_pdu_node_tx { struct radio_pdu_node_tx {
void *next; void *next;
uint8_t pdu_data[1]; u8_t pdu_data[1];
}; };
enum radio_pdu_node_rx_type { enum radio_pdu_node_rx_type {
@ -224,82 +224,82 @@ enum radio_pdu_node_rx_type {
}; };
struct radio_le_conn_cmplt { struct radio_le_conn_cmplt {
uint8_t status; u8_t status;
uint8_t role; u8_t role;
uint8_t peer_addr_type; u8_t peer_addr_type;
uint8_t peer_addr[BDADDR_SIZE]; u8_t peer_addr[BDADDR_SIZE];
uint8_t own_addr_type; u8_t own_addr_type;
uint8_t own_addr[BDADDR_SIZE]; u8_t own_addr[BDADDR_SIZE];
uint8_t peer_irk_index; u8_t peer_irk_index;
uint16_t interval; u16_t interval;
uint16_t latency; u16_t latency;
uint16_t timeout; u16_t timeout;
uint8_t mca; u8_t mca;
} __packed; } __packed;
struct radio_le_conn_update_cmplt { struct radio_le_conn_update_cmplt {
uint8_t status; u8_t status;
uint16_t interval; u16_t interval;
uint16_t latency; u16_t latency;
uint16_t timeout; u16_t timeout;
} __packed; } __packed;
struct radio_le_chan_sel_algo { struct radio_le_chan_sel_algo {
uint8_t chan_sel_algo; u8_t chan_sel_algo;
} __packed; } __packed;
struct radio_pdu_node_rx_hdr { struct radio_pdu_node_rx_hdr {
union { union {
void *next; /* used also by k_fifo once pulled */ void *next; /* used also by k_fifo once pulled */
void *link; void *link;
uint8_t packet_release_last; u8_t packet_release_last;
} onion; } onion;
enum radio_pdu_node_rx_type type; enum radio_pdu_node_rx_type type;
uint16_t handle; u16_t handle;
}; };
struct radio_pdu_node_rx { struct radio_pdu_node_rx {
struct radio_pdu_node_rx_hdr hdr; struct radio_pdu_node_rx_hdr hdr;
uint8_t pdu_data[1]; u8_t pdu_data[1];
}; };
/***************************************************************************** /*****************************************************************************
* Controller Interface Functions * Controller Interface Functions
****************************************************************************/ ****************************************************************************/
/* Downstream */ /* Downstream */
uint32_t radio_init(void *hf_clock, uint8_t sca, uint8_t connection_count_max, u32_t radio_init(void *hf_clock, u8_t sca, u8_t connection_count_max,
uint8_t rx_count_max, uint8_t tx_count_max, u8_t rx_count_max, u8_t tx_count_max,
uint16_t packet_data_octets_max, u16_t packet_data_octets_max,
uint16_t packet_tx_data_size, uint8_t *mem_radio, u16_t packet_tx_data_size, u8_t *mem_radio,
uint16_t mem_size); u16_t mem_size);
void radio_ticks_active_to_start_set(uint32_t ticks_active_to_start); void radio_ticks_active_to_start_set(u32_t ticks_active_to_start);
struct radio_adv_data *radio_adv_data_get(void); struct radio_adv_data *radio_adv_data_get(void);
struct radio_adv_data *radio_scan_data_get(void); struct radio_adv_data *radio_scan_data_get(void);
uint32_t radio_adv_enable(uint16_t interval, uint8_t chl_map, u32_t radio_adv_enable(u16_t interval, u8_t chl_map,
uint8_t filter_policy); u8_t filter_policy);
uint32_t radio_adv_disable(void); u32_t radio_adv_disable(void);
uint32_t radio_scan_enable(uint8_t scan_type, uint8_t init_addr_type, u32_t radio_scan_enable(u8_t scan_type, u8_t init_addr_type,
uint8_t *init_addr, uint16_t interval, u8_t *init_addr, u16_t interval,
uint16_t window, uint8_t filter_policy); u16_t window, u8_t filter_policy);
uint32_t radio_scan_disable(void); u32_t radio_scan_disable(void);
uint32_t radio_connect_enable(uint8_t adv_addr_type, uint8_t *adv_addr, u32_t radio_connect_enable(u8_t adv_addr_type, u8_t *adv_addr,
uint16_t interval, uint16_t latency, u16_t interval, u16_t latency,
uint16_t timeout); u16_t timeout);
/* Upstream */ /* Upstream */
uint8_t radio_rx_get(struct radio_pdu_node_rx **radio_pdu_node_rx, u8_t radio_rx_get(struct radio_pdu_node_rx **radio_pdu_node_rx,
uint16_t *handle); u16_t *handle);
void radio_rx_dequeue(void); void radio_rx_dequeue(void);
void radio_rx_mem_release(struct radio_pdu_node_rx **radio_pdu_node_rx); void radio_rx_mem_release(struct radio_pdu_node_rx **radio_pdu_node_rx);
uint8_t radio_rx_fc_set(uint16_t handle, uint8_t fc); u8_t radio_rx_fc_set(u16_t handle, u8_t fc);
uint8_t radio_rx_fc_get(uint16_t *handle); u8_t radio_rx_fc_get(u16_t *handle);
struct radio_pdu_node_tx *radio_tx_mem_acquire(void); struct radio_pdu_node_tx *radio_tx_mem_acquire(void);
void radio_tx_mem_release(struct radio_pdu_node_tx *pdu_data_node_tx); void radio_tx_mem_release(struct radio_pdu_node_tx *pdu_data_node_tx);
uint32_t radio_tx_mem_enqueue(uint16_t handle, u32_t radio_tx_mem_enqueue(u16_t handle,
struct radio_pdu_node_tx *pdu_data_node_tx); struct radio_pdu_node_tx *pdu_data_node_tx);
/* Callbacks */ /* Callbacks */
extern void radio_active_callback(uint8_t active); extern void radio_active_callback(u8_t active);
extern void radio_event_callback(void); extern void radio_event_callback(void);
#endif #endif

View file

@ -21,99 +21,99 @@ enum llcp {
struct shdr { struct shdr {
uint32_t ticks_xtal_to_start; u32_t ticks_xtal_to_start;
uint32_t ticks_active_to_start; u32_t ticks_active_to_start;
uint32_t ticks_preempt_to_start; u32_t ticks_preempt_to_start;
uint32_t ticks_slot; u32_t ticks_slot;
}; };
struct connection { struct connection {
struct shdr hdr; struct shdr hdr;
uint8_t access_addr[4]; u8_t access_addr[4];
uint8_t crc_init[3]; u8_t crc_init[3];
uint8_t data_chan_map[5]; u8_t data_chan_map[5];
uint8_t data_chan_count:6; u8_t data_chan_count:6;
uint8_t data_chan_sel:1; u8_t data_chan_sel:1;
uint8_t rfu:1; u8_t rfu:1;
union { union {
struct { struct {
uint8_t data_chan_hop; u8_t data_chan_hop;
uint8_t data_chan_use; u8_t data_chan_use;
}; };
uint16_t data_chan_id; u16_t data_chan_id;
}; };
uint16_t handle; u16_t handle;
uint16_t event_counter; u16_t event_counter;
uint16_t conn_interval; u16_t conn_interval;
uint16_t latency; u16_t latency;
uint16_t latency_prepare; u16_t latency_prepare;
uint16_t latency_event; u16_t latency_event;
#if defined(CONFIG_BLUETOOTH_CONTROLLER_DATA_LENGTH) #if defined(CONFIG_BLUETOOTH_CONTROLLER_DATA_LENGTH)
uint16_t default_tx_octets; u16_t default_tx_octets;
uint16_t max_tx_octets; u16_t max_tx_octets;
uint16_t max_rx_octets; u16_t max_rx_octets;
#endif /* CONFIG_BLUETOOTH_CONTROLLER_DATA_LENGTH */ #endif /* CONFIG_BLUETOOTH_CONTROLLER_DATA_LENGTH */
uint16_t supervision_reload; u16_t supervision_reload;
uint16_t supervision_expire; u16_t supervision_expire;
uint16_t procedure_reload; u16_t procedure_reload;
uint16_t procedure_expire; u16_t procedure_expire;
#if defined(CONFIG_BLUETOOTH_CONTROLLER_LE_PING) #if defined(CONFIG_BLUETOOTH_CONTROLLER_LE_PING)
uint16_t appto_reload; u16_t appto_reload;
uint16_t appto_expire; u16_t appto_expire;
uint16_t apto_reload; u16_t apto_reload;
uint16_t apto_expire; u16_t apto_expire;
#endif /* CONFIG_BLUETOOTH_CONTROLLER_LE_PING */ #endif /* CONFIG_BLUETOOTH_CONTROLLER_LE_PING */
union { union {
struct { struct {
uint8_t role:1; u8_t role:1;
uint8_t connect_expire; u8_t connect_expire;
} master; } master;
struct { struct {
uint8_t role:1; u8_t role:1;
uint8_t sca:3; u8_t sca:3;
uint8_t latency_cancel:1; u8_t latency_cancel:1;
uint32_t window_widening_periodic_us; u32_t window_widening_periodic_us;
uint32_t window_widening_max_us; u32_t window_widening_max_us;
uint32_t window_widening_prepare_us; u32_t window_widening_prepare_us;
uint32_t window_widening_event_us; u32_t window_widening_event_us;
uint32_t window_size_prepare_us; u32_t window_size_prepare_us;
uint32_t window_size_event_us; u32_t window_size_event_us;
uint32_t force; u32_t force;
uint32_t ticks_to_offset; u32_t ticks_to_offset;
} slave; } slave;
} role; } role;
uint8_t llcp_req; u8_t llcp_req;
uint8_t llcp_ack; u8_t llcp_ack;
enum llcp llcp_type; enum llcp llcp_type;
union { union {
struct { struct {
uint16_t interval; u16_t interval;
uint16_t latency; u16_t latency;
uint16_t timeout; u16_t timeout;
uint8_t preferred_periodicity; u8_t preferred_periodicity;
uint16_t instant; u16_t instant;
uint16_t offset0; u16_t offset0;
uint16_t offset1; u16_t offset1;
uint16_t offset2; u16_t offset2;
uint16_t offset3; u16_t offset3;
uint16_t offset4; u16_t offset4;
uint16_t offset5; u16_t offset5;
uint32_t ticks_ref; u32_t ticks_ref;
uint32_t ticks_to_offset_next; u32_t ticks_to_offset_next;
uint32_t win_offset_us; u32_t win_offset_us;
uint16_t *pdu_win_offset; u16_t *pdu_win_offset;
uint8_t win_size; u8_t win_size;
uint8_t state:3; u8_t state:3;
#define LLCP_CONN_STATE_INPROG 0 /* master + slave proc in progress #define LLCP_CONN_STATE_INPROG 0 /* master + slave proc in progress
* until instant * until instant
*/ */
@ -124,65 +124,65 @@ struct connection {
#define LLCP_CONN_STATE_RSP_WAIT 5 /* master rsp or slave conn_update #define LLCP_CONN_STATE_RSP_WAIT 5 /* master rsp or slave conn_update
* or rej * or rej
*/ */
uint8_t is_internal:2; u8_t is_internal:2;
} connection_update; } connection_update;
struct { struct {
uint8_t initiate; u8_t initiate;
uint8_t chm[5]; u8_t chm[5];
uint16_t instant; u16_t instant;
} chan_map; } chan_map;
struct { struct {
uint8_t error_code; u8_t error_code;
uint8_t rand[8]; u8_t rand[8];
uint8_t ediv[2]; u8_t ediv[2];
uint8_t ltk[16]; u8_t ltk[16];
uint8_t skd[16]; u8_t skd[16];
} encryption; } encryption;
} llcp; } llcp;
uint32_t llcp_features; u32_t llcp_features;
struct { struct {
uint8_t tx:1; u8_t tx:1;
uint8_t rx:1; u8_t rx:1;
uint8_t version_number; u8_t version_number;
uint16_t company_id; u16_t company_id;
uint16_t sub_version_number; u16_t sub_version_number;
} llcp_version; } llcp_version;
struct { struct {
uint8_t req; u8_t req;
uint8_t ack; u8_t ack;
uint8_t reason_own; u8_t reason_own;
uint8_t reason_peer; u8_t reason_peer;
struct { struct {
struct radio_pdu_node_rx_hdr hdr; struct radio_pdu_node_rx_hdr hdr;
uint8_t reason; u8_t reason;
} radio_pdu_node_rx; } radio_pdu_node_rx;
} llcp_terminate; } llcp_terminate;
#if defined(CONFIG_BLUETOOTH_CONTROLLER_DATA_LENGTH) #if defined(CONFIG_BLUETOOTH_CONTROLLER_DATA_LENGTH)
struct { struct {
uint8_t req; u8_t req;
uint8_t ack; u8_t ack;
uint8_t state:2; u8_t state:2;
#define LLCP_LENGTH_STATE_REQ 0 #define LLCP_LENGTH_STATE_REQ 0
#define LLCP_LENGTH_STATE_ACK_WAIT 1 #define LLCP_LENGTH_STATE_ACK_WAIT 1
#define LLCP_LENGTH_STATE_RSP_WAIT 2 #define LLCP_LENGTH_STATE_RSP_WAIT 2
#define LLCP_LENGTH_STATE_RESIZE 3 #define LLCP_LENGTH_STATE_RESIZE 3
uint16_t rx_octets; u16_t rx_octets;
uint16_t tx_octets; u16_t tx_octets;
} llcp_length; } llcp_length;
#endif /* CONFIG_BLUETOOTH_CONTROLLER_DATA_LENGTH */ #endif /* CONFIG_BLUETOOTH_CONTROLLER_DATA_LENGTH */
uint8_t sn:1; u8_t sn:1;
uint8_t nesn:1; u8_t nesn:1;
uint8_t pause_rx:1; u8_t pause_rx:1;
uint8_t pause_tx:1; u8_t pause_tx:1;
uint8_t enc_rx:1; u8_t enc_rx:1;
uint8_t enc_tx:1; u8_t enc_tx:1;
uint8_t refresh:1; u8_t refresh:1;
uint8_t empty:1; u8_t empty:1;
struct ccm ccm_rx; struct ccm ccm_rx;
struct ccm ccm_tx; struct ccm ccm_tx;
@ -191,19 +191,19 @@ struct connection {
struct radio_pdu_node_tx *pkt_tx_ctrl; struct radio_pdu_node_tx *pkt_tx_ctrl;
struct radio_pdu_node_tx *pkt_tx_data; struct radio_pdu_node_tx *pkt_tx_data;
struct radio_pdu_node_tx *pkt_tx_last; struct radio_pdu_node_tx *pkt_tx_last;
uint8_t packet_tx_head_len; u8_t packet_tx_head_len;
uint8_t packet_tx_head_offset; u8_t packet_tx_head_offset;
#if defined(CONFIG_BLUETOOTH_CONTROLLER_CONN_RSSI) #if defined(CONFIG_BLUETOOTH_CONTROLLER_CONN_RSSI)
uint8_t rssi_latest; u8_t rssi_latest;
uint8_t rssi_reported; u8_t rssi_reported;
uint8_t rssi_sample_count; u8_t rssi_sample_count;
#endif /* CONFIG_BLUETOOTH_CONTROLLER_CONN_RSSI */ #endif /* CONFIG_BLUETOOTH_CONTROLLER_CONN_RSSI */
}; };
#define CONNECTION_T_SIZE MROUND(sizeof(struct connection)) #define CONNECTION_T_SIZE MROUND(sizeof(struct connection))
struct pdu_data_q_tx { struct pdu_data_q_tx {
uint16_t handle; u16_t handle;
struct radio_pdu_node_tx *node_tx; struct radio_pdu_node_tx *node_tx;
}; };

View file

@ -37,41 +37,41 @@
#include "ll.h" #include "ll.h"
/* Global singletons */ /* Global singletons */
static uint8_t MALIGN(4) _rand_context[3 + 4 + 1]; static u8_t MALIGN(4) _rand_context[3 + 4 + 1];
static uint8_t MALIGN(4) _ticker_nodes[RADIO_TICKER_NODES][TICKER_NODE_T_SIZE]; static u8_t MALIGN(4) _ticker_nodes[RADIO_TICKER_NODES][TICKER_NODE_T_SIZE];
static uint8_t MALIGN(4) _ticker_users[MAYFLY_CALLER_COUNT] static u8_t MALIGN(4) _ticker_users[MAYFLY_CALLER_COUNT]
[TICKER_USER_T_SIZE]; [TICKER_USER_T_SIZE];
static uint8_t MALIGN(4) _ticker_user_ops[RADIO_TICKER_USER_OPS] static u8_t MALIGN(4) _ticker_user_ops[RADIO_TICKER_USER_OPS]
[TICKER_USER_OP_T_SIZE]; [TICKER_USER_OP_T_SIZE];
static uint8_t MALIGN(4) _radio[LL_MEM_TOTAL]; static u8_t MALIGN(4) _radio[LL_MEM_TOTAL];
static struct k_sem *sem_recv; static struct k_sem *sem_recv;
static struct { static struct {
uint8_t pub_addr[BDADDR_SIZE]; u8_t pub_addr[BDADDR_SIZE];
uint8_t rnd_addr[BDADDR_SIZE]; u8_t rnd_addr[BDADDR_SIZE];
} _ll_context; } _ll_context;
static struct { static struct {
uint16_t interval; u16_t interval;
uint8_t adv_type:4; u8_t adv_type:4;
uint8_t tx_addr:1; u8_t tx_addr:1;
uint8_t rx_addr:1; u8_t rx_addr:1;
uint8_t filter_policy:2; u8_t filter_policy:2;
uint8_t chl_map:3; u8_t chl_map:3;
uint8_t adv_addr[BDADDR_SIZE]; u8_t adv_addr[BDADDR_SIZE];
uint8_t direct_addr[BDADDR_SIZE]; u8_t direct_addr[BDADDR_SIZE];
} _ll_adv_params; } _ll_adv_params;
static struct { static struct {
uint16_t interval; u16_t interval;
uint16_t window; u16_t window;
uint8_t scan_type:1; u8_t scan_type:1;
uint8_t tx_addr:1; u8_t tx_addr:1;
uint8_t filter_policy:1; u8_t filter_policy:1;
} _ll_scan_params; } _ll_scan_params;
void mayfly_enable_cb(uint8_t caller_id, uint8_t callee_id, uint8_t enable) void mayfly_enable_cb(u8_t caller_id, u8_t callee_id, u8_t enable)
{ {
(void)caller_id; (void)caller_id;
@ -84,7 +84,7 @@ void mayfly_enable_cb(uint8_t caller_id, uint8_t callee_id, uint8_t enable)
} }
} }
uint32_t mayfly_is_enabled(uint8_t caller_id, uint8_t callee_id) u32_t mayfly_is_enabled(u8_t caller_id, u8_t callee_id)
{ {
(void)caller_id; (void)caller_id;
@ -99,7 +99,7 @@ uint32_t mayfly_is_enabled(uint8_t caller_id, uint8_t callee_id)
return 0; return 0;
} }
uint32_t mayfly_prio_is_equal(uint8_t caller_id, uint8_t callee_id) u32_t mayfly_prio_is_equal(u8_t caller_id, u8_t callee_id)
{ {
return (caller_id == callee_id) || return (caller_id == callee_id) ||
((caller_id == MAYFLY_CALL_ID_0) && ((caller_id == MAYFLY_CALL_ID_0) &&
@ -108,7 +108,7 @@ uint32_t mayfly_prio_is_equal(uint8_t caller_id, uint8_t callee_id)
(callee_id == MAYFLY_CALL_ID_0)); (callee_id == MAYFLY_CALL_ID_0));
} }
void mayfly_pend(uint8_t caller_id, uint8_t callee_id) void mayfly_pend(u8_t caller_id, u8_t callee_id)
{ {
(void)caller_id; (void)caller_id;
@ -128,7 +128,7 @@ void mayfly_pend(uint8_t caller_id, uint8_t callee_id)
} }
} }
void radio_active_callback(uint8_t active) void radio_active_callback(u8_t active)
{ {
} }
@ -147,7 +147,7 @@ ISR_DIRECT_DECLARE(radio_nrf5_isr)
static void rtc0_nrf5_isr(void *arg) static void rtc0_nrf5_isr(void *arg)
{ {
uint32_t compare0, compare1; u32_t compare0, compare1;
/* store interested events */ /* store interested events */
compare0 = NRF_RTC0->EVENTS_COMPARE[0]; compare0 = NRF_RTC0->EVENTS_COMPARE[0];
@ -184,7 +184,7 @@ int ll_init(struct k_sem *sem_rx)
{ {
struct device *clk_k32; struct device *clk_k32;
struct device *clk_m16; struct device *clk_m16;
uint32_t err; u32_t err;
sem_recv = sem_rx; sem_recv = sem_rx;
@ -246,7 +246,7 @@ int ll_init(struct k_sem *sem_rx)
return 0; return 0;
} }
void ll_address_get(uint8_t addr_type, uint8_t *bdaddr) void ll_address_get(u8_t addr_type, u8_t *bdaddr)
{ {
if (addr_type) { if (addr_type) {
memcpy(bdaddr, &_ll_context.rnd_addr[0], BDADDR_SIZE); memcpy(bdaddr, &_ll_context.rnd_addr[0], BDADDR_SIZE);
@ -255,7 +255,7 @@ void ll_address_get(uint8_t addr_type, uint8_t *bdaddr)
} }
} }
void ll_address_set(uint8_t addr_type, uint8_t const *const bdaddr) void ll_address_set(u8_t addr_type, u8_t const *const bdaddr)
{ {
if (addr_type) { if (addr_type) {
memcpy(&_ll_context.rnd_addr[0], bdaddr, BDADDR_SIZE); memcpy(&_ll_context.rnd_addr[0], bdaddr, BDADDR_SIZE);
@ -264,10 +264,10 @@ void ll_address_set(uint8_t addr_type, uint8_t const *const bdaddr)
} }
} }
void ll_adv_params_set(uint16_t interval, uint8_t adv_type, void ll_adv_params_set(u16_t interval, u8_t adv_type,
uint8_t own_addr_type, uint8_t direct_addr_type, u8_t own_addr_type, u8_t direct_addr_type,
uint8_t const *const direct_addr, uint8_t chl_map, u8_t const *const direct_addr, u8_t chl_map,
uint8_t filter_policy) u8_t filter_policy)
{ {
struct radio_adv_data *radio_adv_data; struct radio_adv_data *radio_adv_data;
struct pdu_adv *pdu; struct pdu_adv *pdu;
@ -330,11 +330,11 @@ void ll_adv_params_set(uint16_t interval, uint8_t adv_type,
pdu->resv = 0; pdu->resv = 0;
} }
void ll_adv_data_set(uint8_t len, uint8_t const *const data) void ll_adv_data_set(u8_t len, u8_t const *const data)
{ {
struct radio_adv_data *radio_adv_data; struct radio_adv_data *radio_adv_data;
struct pdu_adv *pdu; struct pdu_adv *pdu;
uint8_t last; u8_t last;
/** @todo dont update data if directed adv type. */ /** @todo dont update data if directed adv type. */
@ -380,11 +380,11 @@ void ll_adv_data_set(uint8_t len, uint8_t const *const data)
radio_adv_data->last = last; radio_adv_data->last = last;
} }
void ll_scan_data_set(uint8_t len, uint8_t const *const data) void ll_scan_data_set(u8_t len, u8_t const *const data)
{ {
struct radio_adv_data *radio_scan_data; struct radio_adv_data *radio_scan_data;
struct pdu_adv *pdu; struct pdu_adv *pdu;
uint8_t last; u8_t last;
/* use the last index in double buffer, */ /* use the last index in double buffer, */
radio_scan_data = radio_scan_data_get(); radio_scan_data = radio_scan_data_get();
@ -414,9 +414,9 @@ void ll_scan_data_set(uint8_t len, uint8_t const *const data)
radio_scan_data->last = last; radio_scan_data->last = last;
} }
uint32_t ll_adv_enable(uint8_t enable) u32_t ll_adv_enable(u8_t enable)
{ {
uint32_t status; u32_t status;
if (enable) { if (enable) {
struct radio_adv_data *radio_adv_data; struct radio_adv_data *radio_adv_data;
@ -464,8 +464,8 @@ uint32_t ll_adv_enable(uint8_t enable)
return status; return status;
} }
void ll_scan_params_set(uint8_t scan_type, uint16_t interval, uint16_t window, void ll_scan_params_set(u8_t scan_type, u16_t interval, u16_t window,
uint8_t own_addr_type, uint8_t filter_policy) u8_t own_addr_type, u8_t filter_policy)
{ {
_ll_scan_params.scan_type = scan_type; _ll_scan_params.scan_type = scan_type;
_ll_scan_params.interval = interval; _ll_scan_params.interval = interval;
@ -474,9 +474,9 @@ void ll_scan_params_set(uint8_t scan_type, uint16_t interval, uint16_t window,
_ll_scan_params.filter_policy = filter_policy; _ll_scan_params.filter_policy = filter_policy;
} }
uint32_t ll_scan_enable(uint8_t enable) u32_t ll_scan_enable(u8_t enable)
{ {
uint32_t status; u32_t status;
if (enable) { if (enable) {
status = radio_scan_enable(_ll_scan_params.scan_type, status = radio_scan_enable(_ll_scan_params.scan_type,
@ -494,13 +494,13 @@ uint32_t ll_scan_enable(uint8_t enable)
return status; return status;
} }
uint32_t ll_create_connection(uint16_t scan_interval, uint16_t scan_window, u32_t ll_create_connection(u16_t scan_interval, u16_t scan_window,
uint8_t filter_policy, uint8_t peer_addr_type, u8_t filter_policy, u8_t peer_addr_type,
uint8_t *peer_addr, uint8_t own_addr_type, u8_t *peer_addr, u8_t own_addr_type,
uint16_t interval, uint16_t latency, u16_t interval, u16_t latency,
uint16_t timeout) u16_t timeout)
{ {
uint32_t status; u32_t status;
status = radio_connect_enable(peer_addr_type, peer_addr, interval, status = radio_connect_enable(peer_addr_type, peer_addr, interval,
latency, timeout); latency, timeout);

View file

@ -16,39 +16,39 @@
#define PDU_AC_SIZE_MAX (37 + PDU_AC_SIZE_OVERHEAD) #define PDU_AC_SIZE_MAX (37 + PDU_AC_SIZE_OVERHEAD)
struct pdu_adv_payload_adv_ind { struct pdu_adv_payload_adv_ind {
uint8_t addr[BDADDR_SIZE]; u8_t addr[BDADDR_SIZE];
uint8_t data[31]; u8_t data[31];
} __packed; } __packed;
struct pdu_adv_payload_direct_ind { struct pdu_adv_payload_direct_ind {
uint8_t adv_addr[BDADDR_SIZE]; u8_t adv_addr[BDADDR_SIZE];
uint8_t tgt_addr[BDADDR_SIZE]; u8_t tgt_addr[BDADDR_SIZE];
} __packed; } __packed;
struct pdu_adv_payload_scan_rsp { struct pdu_adv_payload_scan_rsp {
uint8_t addr[BDADDR_SIZE]; u8_t addr[BDADDR_SIZE];
uint8_t data[31]; u8_t data[31];
} __packed; } __packed;
struct pdu_adv_payload_scan_req { struct pdu_adv_payload_scan_req {
uint8_t scan_addr[BDADDR_SIZE]; u8_t scan_addr[BDADDR_SIZE];
uint8_t adv_addr[BDADDR_SIZE]; u8_t adv_addr[BDADDR_SIZE];
} __packed; } __packed;
struct pdu_adv_payload_connect_ind { struct pdu_adv_payload_connect_ind {
uint8_t init_addr[BDADDR_SIZE]; u8_t init_addr[BDADDR_SIZE];
uint8_t adv_addr[BDADDR_SIZE]; u8_t adv_addr[BDADDR_SIZE];
struct { struct {
uint8_t access_addr[4]; u8_t access_addr[4];
uint8_t crc_init[3]; u8_t crc_init[3];
uint8_t win_size; u8_t win_size;
uint16_t win_offset; u16_t win_offset;
uint16_t interval; u16_t interval;
uint16_t latency; u16_t latency;
uint16_t timeout; u16_t timeout;
uint8_t chan_map[5]; u8_t chan_map[5];
uint8_t hop:5; u8_t hop:5;
uint8_t sca:3; u8_t sca:3;
} __packed lldata; } __packed lldata;
} __packed; } __packed;
@ -71,15 +71,15 @@ enum pdu_adv_type {
} __packed; } __packed;
struct pdu_adv { struct pdu_adv {
uint8_t type:4; u8_t type:4;
uint8_t rfu:1; u8_t rfu:1;
uint8_t chan_sel:1; u8_t chan_sel:1;
uint8_t tx_addr:1; u8_t tx_addr:1;
uint8_t rx_addr:1; u8_t rx_addr:1;
uint8_t len:8; u8_t len:8;
uint8_t resv:8; /* TODO: remove nRF specific code */ u8_t resv:8; /* TODO: remove nRF specific code */
union { union {
struct pdu_adv_payload_adv_ind adv_ind; struct pdu_adv_payload_adv_ind adv_ind;
@ -127,117 +127,117 @@ enum pdu_data_llctrl_type {
}; };
struct pdu_data_llctrl_conn_update_ind { struct pdu_data_llctrl_conn_update_ind {
uint8_t win_size; u8_t win_size;
uint16_t win_offset; u16_t win_offset;
uint16_t interval; u16_t interval;
uint16_t latency; u16_t latency;
uint16_t timeout; u16_t timeout;
uint16_t instant; u16_t instant;
} __packed; } __packed;
struct pdu_data_llctrl_chan_map_ind { struct pdu_data_llctrl_chan_map_ind {
uint8_t chm[5]; u8_t chm[5];
uint16_t instant; u16_t instant;
} __packed; } __packed;
struct pdu_data_llctrl_terminate_ind { struct pdu_data_llctrl_terminate_ind {
uint8_t error_code; u8_t error_code;
} __packed; } __packed;
struct pdu_data_llctrl_enc_req { struct pdu_data_llctrl_enc_req {
uint8_t rand[8]; u8_t rand[8];
uint8_t ediv[2]; u8_t ediv[2];
uint8_t skdm[8]; u8_t skdm[8];
uint8_t ivm[4]; u8_t ivm[4];
} __packed; } __packed;
struct pdu_data_llctrl_enc_rsp { struct pdu_data_llctrl_enc_rsp {
uint8_t skds[8]; u8_t skds[8];
uint8_t ivs[4]; u8_t ivs[4];
} __packed; } __packed;
struct pdu_data_llctrl_unknown_rsp { struct pdu_data_llctrl_unknown_rsp {
uint8_t type; u8_t type;
} __packed; } __packed;
struct pdu_data_llctrl_feature_req { struct pdu_data_llctrl_feature_req {
uint8_t features[8]; u8_t features[8];
} __packed; } __packed;
struct pdu_data_llctrl_feature_rsp { struct pdu_data_llctrl_feature_rsp {
uint8_t features[8]; u8_t features[8];
} __packed; } __packed;
struct pdu_data_llctrl_version_ind { struct pdu_data_llctrl_version_ind {
uint8_t version_number; u8_t version_number;
uint16_t company_id; u16_t company_id;
uint16_t sub_version_number; u16_t sub_version_number;
} __packed; } __packed;
struct pdu_data_llctrl_reject_ind { struct pdu_data_llctrl_reject_ind {
uint8_t error_code; u8_t error_code;
} __packed; } __packed;
struct pdu_data_llctrl_conn_param_req { struct pdu_data_llctrl_conn_param_req {
uint16_t interval_min; u16_t interval_min;
uint16_t interval_max; u16_t interval_max;
uint16_t latency; u16_t latency;
uint16_t timeout; u16_t timeout;
uint8_t preferred_periodicity; u8_t preferred_periodicity;
uint16_t reference_conn_event_count; u16_t reference_conn_event_count;
uint16_t offset0; u16_t offset0;
uint16_t offset1; u16_t offset1;
uint16_t offset2; u16_t offset2;
uint16_t offset3; u16_t offset3;
uint16_t offset4; u16_t offset4;
uint16_t offset5; u16_t offset5;
} __packed; } __packed;
struct pdu_data_llctrl_conn_param_rsp { struct pdu_data_llctrl_conn_param_rsp {
uint16_t interval_min; u16_t interval_min;
uint16_t interval_max; u16_t interval_max;
uint16_t latency; u16_t latency;
uint16_t timeout; u16_t timeout;
uint8_t preferred_periodicity; u8_t preferred_periodicity;
uint16_t reference_conn_event_count; u16_t reference_conn_event_count;
uint16_t offset0; u16_t offset0;
uint16_t offset1; u16_t offset1;
uint16_t offset2; u16_t offset2;
uint16_t offset3; u16_t offset3;
uint16_t offset4; u16_t offset4;
uint16_t offset5; u16_t offset5;
} __packed; } __packed;
struct pdu_data_llctrl_reject_ext_ind { struct pdu_data_llctrl_reject_ext_ind {
uint8_t reject_opcode; u8_t reject_opcode;
uint8_t error_code; u8_t error_code;
} __packed; } __packed;
struct pdu_data_llctrl_length_req_rsp { struct pdu_data_llctrl_length_req_rsp {
uint16_t max_rx_octets; u16_t max_rx_octets;
uint16_t max_rx_time; u16_t max_rx_time;
uint16_t max_tx_octets; u16_t max_tx_octets;
uint16_t max_tx_time; u16_t max_tx_time;
} __packed; } __packed;
struct pdu_data_llctrl_phy_req_rsp { struct pdu_data_llctrl_phy_req_rsp {
uint8_t tx_phys; u8_t tx_phys;
uint8_t rx_phys; u8_t rx_phys;
} __packed; } __packed;
struct pdu_data_llctrl_phy_update_ind { struct pdu_data_llctrl_phy_update_ind {
uint8_t m_to_s_phy; u8_t m_to_s_phy;
uint8_t s_to_m_phy; u8_t s_to_m_phy;
uint16_t instant; u16_t instant;
} __packed; } __packed;
struct pdu_data_llctrl_min_used_chans_ind { struct pdu_data_llctrl_min_used_chans_ind {
uint8_t phys; u8_t phys;
uint8_t min_used_chans; u8_t min_used_chans;
} __packed; } __packed;
struct pdu_data_llctrl { struct pdu_data_llctrl {
uint8_t opcode; u8_t opcode;
union { union {
struct pdu_data_llctrl_conn_update_ind conn_update_ind; struct pdu_data_llctrl_conn_update_ind conn_update_ind;
struct pdu_data_llctrl_chan_map_ind chan_map_ind; struct pdu_data_llctrl_chan_map_ind chan_map_ind;
@ -264,32 +264,32 @@ struct pdu_data_llctrl {
#if defined(CONFIG_BLUETOOTH_CONTROLLER_PROFILE_ISR) #if defined(CONFIG_BLUETOOTH_CONTROLLER_PROFILE_ISR)
struct profile { struct profile {
uint8_t lcur; u8_t lcur;
uint8_t lmin; u8_t lmin;
uint8_t lmax; u8_t lmax;
uint8_t cur; u8_t cur;
uint8_t min; u8_t min;
uint8_t max; u8_t max;
} __packed; } __packed;
#endif /* CONFIG_BLUETOOTH_CONTROLLER_PROFILE_ISR */ #endif /* CONFIG_BLUETOOTH_CONTROLLER_PROFILE_ISR */
struct pdu_data { struct pdu_data {
uint8_t ll_id:2; u8_t ll_id:2;
uint8_t nesn:1; u8_t nesn:1;
uint8_t sn:1; u8_t sn:1;
uint8_t md:1; u8_t md:1;
uint8_t rfu:3; u8_t rfu:3;
uint8_t len:8; u8_t len:8;
uint8_t resv:8; /* TODO: remove nRF specific code */ u8_t resv:8; /* TODO: remove nRF specific code */
union { union {
uint8_t lldata[1]; u8_t lldata[1];
struct pdu_data_llctrl llctrl; struct pdu_data_llctrl llctrl;
#if defined(CONFIG_BLUETOOTH_CONTROLLER_CONN_RSSI) #if defined(CONFIG_BLUETOOTH_CONTROLLER_CONN_RSSI)
uint8_t rssi; u8_t rssi;
#endif /* CONFIG_BLUETOOTH_CONTROLLER_CONN_RSSI */ #endif /* CONFIG_BLUETOOTH_CONTROLLER_CONN_RSSI */
#if defined(CONFIG_BLUETOOTH_CONTROLLER_PROFILE_ISR) #if defined(CONFIG_BLUETOOTH_CONTROLLER_PROFILE_ISR)

View file

@ -29,22 +29,22 @@
* Types * Types
****************************************************************************/ ****************************************************************************/
struct ticker_node { struct ticker_node {
uint8_t next; u8_t next;
uint8_t req; u8_t req;
uint8_t ack; u8_t ack;
uint8_t force; u8_t force;
uint32_t ticks_periodic; u32_t ticks_periodic;
uint32_t ticks_to_expire; u32_t ticks_to_expire;
ticker_timeout_func timeout_func; ticker_timeout_func timeout_func;
void *context; void *context;
uint16_t ticks_to_expire_minus; u16_t ticks_to_expire_minus;
uint16_t ticks_slot; u16_t ticks_slot;
uint16_t lazy_periodic; u16_t lazy_periodic;
uint16_t lazy_current; u16_t lazy_current;
uint32_t remainder_periodic; u32_t remainder_periodic;
uint32_t remainder_current; u32_t remainder_current;
}; };
enum ticker_user_op_type { enum ticker_user_op_type {
@ -57,69 +57,69 @@ enum ticker_user_op_type {
}; };
struct ticker_user_op_start { struct ticker_user_op_start {
uint32_t ticks_at_start; u32_t ticks_at_start;
uint32_t ticks_first; u32_t ticks_first;
uint32_t ticks_periodic; u32_t ticks_periodic;
uint32_t remainder_periodic; u32_t remainder_periodic;
uint16_t lazy; u16_t lazy;
uint16_t ticks_slot; u16_t ticks_slot;
ticker_timeout_func fp_timeout_func; ticker_timeout_func fp_timeout_func;
void *context; void *context;
}; };
struct ticker_user_op_update { struct ticker_user_op_update {
uint16_t ticks_drift_plus; u16_t ticks_drift_plus;
uint16_t ticks_drift_minus; u16_t ticks_drift_minus;
uint16_t ticks_slot_plus; u16_t ticks_slot_plus;
uint16_t ticks_slot_minus; u16_t ticks_slot_minus;
uint16_t lazy; u16_t lazy;
uint8_t force; u8_t force;
}; };
struct ticker_user_op_slot_get { struct ticker_user_op_slot_get {
uint8_t *ticker_id; u8_t *ticker_id;
uint32_t *ticks_current; u32_t *ticks_current;
uint32_t *ticks_to_expire; u32_t *ticks_to_expire;
}; };
struct ticker_user_op { struct ticker_user_op {
enum ticker_user_op_type op; enum ticker_user_op_type op;
uint8_t id; u8_t id;
union { union {
struct ticker_user_op_start start; struct ticker_user_op_start start;
struct ticker_user_op_update update; struct ticker_user_op_update update;
struct ticker_user_op_slot_get slot_get; struct ticker_user_op_slot_get slot_get;
} params; } params;
uint32_t status; u32_t status;
ticker_op_func fp_op_func; ticker_op_func fp_op_func;
void *op_context; void *op_context;
}; };
struct ticker_user { struct ticker_user {
uint8_t count_user_op; u8_t count_user_op;
uint8_t first; u8_t first;
uint8_t middle; u8_t middle;
uint8_t last; u8_t last;
struct ticker_user_op *user_op; struct ticker_user_op *user_op;
}; };
struct ticker_instance { struct ticker_instance {
struct ticker_node *node; struct ticker_node *node;
struct ticker_user *user; struct ticker_user *user;
uint8_t count_node; u8_t count_node;
uint8_t count_user; u8_t count_user;
uint8_t ticks_elapsed_first; u8_t ticks_elapsed_first;
uint8_t ticks_elapsed_last; u8_t ticks_elapsed_last;
uint32_t ticks_elapsed[DOUBLE_BUFFER_SIZE]; u32_t ticks_elapsed[DOUBLE_BUFFER_SIZE];
uint32_t ticks_current; u32_t ticks_current;
uint8_t ticker_id_head; u8_t ticker_id_head;
uint8_t ticker_id_slot_previous; u8_t ticker_id_slot_previous;
uint16_t ticks_slot_previous; u16_t ticks_slot_previous;
uint8_t job_guard; u8_t job_guard;
uint8_t worker_trigger; u8_t worker_trigger;
uint8_t (*fp_caller_id_get)(uint8_t user_id); u8_t (*fp_caller_id_get)(u8_t user_id);
void (*fp_sched)(uint8_t caller_id, uint8_t callee_id, uint8_t chain); void (*fp_sched)(u8_t caller_id, u8_t callee_id, u8_t chain);
void (*fp_cmp_set)(uint32_t value); void (*fp_cmp_set)(u32_t value);
}; };
/***************************************************************************** /*****************************************************************************
@ -130,13 +130,13 @@ static struct ticker_instance _instance[2];
/***************************************************************************** /*****************************************************************************
* Static Functions * Static Functions
****************************************************************************/ ****************************************************************************/
static uint8_t ticker_by_slot_get(struct ticker_node *node, static u8_t ticker_by_slot_get(struct ticker_node *node,
uint8_t ticker_id_head, u8_t ticker_id_head,
uint32_t ticks_slot) u32_t ticks_slot)
{ {
while (ticker_id_head != TICKER_NULL) { while (ticker_id_head != TICKER_NULL) {
struct ticker_node *ticker; struct ticker_node *ticker;
uint32_t ticks_to_expire; u32_t ticks_to_expire;
ticker = &node[ticker_id_head]; ticker = &node[ticker_id_head];
ticks_to_expire = ticker->ticks_to_expire; ticks_to_expire = ticker->ticks_to_expire;
@ -157,14 +157,14 @@ static uint8_t ticker_by_slot_get(struct ticker_node *node,
} }
static void ticker_by_next_slot_get(struct ticker_instance *instance, static void ticker_by_next_slot_get(struct ticker_instance *instance,
uint8_t *ticker_id_head, u8_t *ticker_id_head,
uint32_t *ticks_current, u32_t *ticks_current,
uint32_t *ticks_to_expire) u32_t *ticks_to_expire)
{ {
struct ticker_node *node; struct ticker_node *node;
uint8_t _ticker_id_head; u8_t _ticker_id_head;
struct ticker_node *ticker; struct ticker_node *ticker;
uint32_t _ticks_to_expire; u32_t _ticks_to_expire;
node = instance->node; node = instance->node;
@ -195,19 +195,19 @@ static void ticker_by_next_slot_get(struct ticker_instance *instance,
*ticks_to_expire = _ticks_to_expire; *ticks_to_expire = _ticks_to_expire;
} }
static uint8_t ticker_enqueue(struct ticker_instance *instance, static u8_t ticker_enqueue(struct ticker_instance *instance,
uint8_t id) u8_t id)
{ {
struct ticker_node *node; struct ticker_node *node;
struct ticker_node *ticker_new; struct ticker_node *ticker_new;
struct ticker_node *ticker_current; struct ticker_node *ticker_current;
uint8_t previous; u8_t previous;
uint8_t current; u8_t current;
uint8_t ticker_id_slot_previous; u8_t ticker_id_slot_previous;
uint8_t collide; u8_t collide;
uint32_t ticks_to_expire; u32_t ticks_to_expire;
uint32_t ticks_to_expire_current; u32_t ticks_to_expire_current;
uint32_t ticks_slot_previous; u32_t ticks_slot_previous;
node = &instance->node[0]; node = &instance->node[0];
ticker_new = &node[id]; ticker_new = &node[id];
@ -269,15 +269,15 @@ static uint8_t ticker_enqueue(struct ticker_instance *instance,
return id; return id;
} }
static uint32_t ticker_dequeue(struct ticker_instance *instance, static u32_t ticker_dequeue(struct ticker_instance *instance,
uint8_t id) u8_t id)
{ {
struct ticker_node *ticker_current; struct ticker_node *ticker_current;
struct ticker_node *node; struct ticker_node *node;
uint8_t previous; u8_t previous;
uint8_t current; u8_t current;
uint32_t timeout; u32_t timeout;
uint32_t total; u32_t total;
/* find the ticker's position in ticker list */ /* find the ticker's position in ticker list */
node = &instance->node[0]; node = &instance->node[0];
@ -329,9 +329,9 @@ static uint32_t ticker_dequeue(struct ticker_instance *instance,
static inline void ticker_worker(struct ticker_instance *instance) static inline void ticker_worker(struct ticker_instance *instance)
{ {
struct ticker_node *node; struct ticker_node *node;
uint32_t ticks_elapsed; u32_t ticks_elapsed;
uint32_t ticks_expired; u32_t ticks_expired;
uint8_t ticker_id_head; u8_t ticker_id_head;
/* Defer worker if job running */ /* Defer worker if job running */
instance->worker_trigger = 1; instance->worker_trigger = 1;
@ -360,7 +360,7 @@ static inline void ticker_worker(struct ticker_instance *instance)
node = &instance->node[0]; node = &instance->node[0];
while (ticker_id_head != TICKER_NULL) { while (ticker_id_head != TICKER_NULL) {
struct ticker_node *ticker; struct ticker_node *ticker;
uint32_t ticks_to_expire; u32_t ticks_to_expire;
/* auto variable for current ticker node */ /* auto variable for current ticker node */
ticker = &node[ticker_id_head]; ticker = &node[ticker_id_head];
@ -401,7 +401,7 @@ static inline void ticker_worker(struct ticker_instance *instance)
/* queue the elapsed value */ /* queue the elapsed value */
if (instance->ticks_elapsed_first == instance->ticks_elapsed_last) { if (instance->ticks_elapsed_first == instance->ticks_elapsed_last) {
uint8_t last; u8_t last;
last = instance->ticks_elapsed_last + 1; last = instance->ticks_elapsed_last + 1;
if (last == DOUBLE_BUFFER_SIZE) { if (last == DOUBLE_BUFFER_SIZE) {
@ -418,18 +418,18 @@ static inline void ticker_worker(struct ticker_instance *instance)
} }
static void prepare_ticks_to_expire(struct ticker_node *ticker, static void prepare_ticks_to_expire(struct ticker_node *ticker,
uint32_t ticks_current, u32_t ticks_current,
uint32_t ticks_at_start) u32_t ticks_at_start)
{ {
uint32_t ticks_to_expire = ticker->ticks_to_expire; u32_t ticks_to_expire = ticker->ticks_to_expire;
uint16_t ticks_to_expire_minus = ticker->ticks_to_expire_minus; u16_t ticks_to_expire_minus = ticker->ticks_to_expire_minus;
/* Calculate ticks to expire for this new node */ /* Calculate ticks to expire for this new node */
if (((ticks_at_start - ticks_current) & 0x00800000) == 0) { if (((ticks_at_start - ticks_current) & 0x00800000) == 0) {
ticks_to_expire += ticks_to_expire +=
ticker_ticks_diff_get(ticks_at_start, ticks_current); ticker_ticks_diff_get(ticks_at_start, ticks_current);
} else { } else {
uint32_t delta_current_start; u32_t delta_current_start;
delta_current_start = delta_current_start =
ticker_ticks_diff_get(ticks_current, ticks_at_start); ticker_ticks_diff_get(ticks_current, ticks_at_start);
@ -455,7 +455,7 @@ static void prepare_ticks_to_expire(struct ticker_node *ticker,
ticker->ticks_to_expire_minus = ticks_to_expire_minus; ticker->ticks_to_expire_minus = ticks_to_expire_minus;
} }
static uint8_t ticker_remainder_increment(struct ticker_node *ticker) static u8_t ticker_remainder_increment(struct ticker_node *ticker)
{ {
ticker->remainder_current += ticker->remainder_periodic; ticker->remainder_current += ticker->remainder_periodic;
if ((ticker->remainder_current < 0x80000000) if ((ticker->remainder_current < 0x80000000)
@ -466,9 +466,9 @@ static uint8_t ticker_remainder_increment(struct ticker_node *ticker)
return 0; return 0;
} }
static uint8_t ticker_remainder_decrement(struct ticker_node *ticker) static u8_t ticker_remainder_decrement(struct ticker_node *ticker)
{ {
uint8_t decrement = 0; u8_t decrement = 0;
if ((ticker->remainder_current >= 0x80000000) if ((ticker->remainder_current >= 0x80000000)
|| (ticker->remainder_current <= (30517578UL / 2))) { || (ticker->remainder_current <= (30517578UL / 2))) {
@ -482,12 +482,12 @@ static uint8_t ticker_remainder_decrement(struct ticker_node *ticker)
static inline void ticker_job_node_update(struct ticker_node *ticker, static inline void ticker_job_node_update(struct ticker_node *ticker,
struct ticker_user_op *user_op, struct ticker_user_op *user_op,
uint32_t ticks_current, u32_t ticks_current,
uint32_t ticks_elapsed, u32_t ticks_elapsed,
uint8_t *insert_head) u8_t *insert_head)
{ {
uint32_t ticks_now; u32_t ticks_now;
uint32_t ticks_to_expire = ticker->ticks_to_expire; u32_t ticks_to_expire = ticker->ticks_to_expire;
ticks_now = cntr_cnt_get(); ticks_now = cntr_cnt_get();
ticks_elapsed += ticker_ticks_diff_get(ticks_now, ticks_current); ticks_elapsed += ticker_ticks_diff_get(ticks_now, ticks_current);
@ -545,15 +545,15 @@ static inline void ticker_job_node_update(struct ticker_node *ticker,
*insert_head = user_op->id; *insert_head = user_op->id;
} }
static inline uint8_t ticker_job_list_manage( static inline u8_t ticker_job_list_manage(
struct ticker_instance *instance, struct ticker_instance *instance,
uint32_t ticks_elapsed, u32_t ticks_elapsed,
uint8_t *insert_head) u8_t *insert_head)
{ {
uint8_t pending; u8_t pending;
struct ticker_node *node; struct ticker_node *node;
struct ticker_user *users; struct ticker_user *users;
uint8_t count_user; u8_t count_user;
pending = 0; pending = 0;
node = &instance->node[0]; node = &instance->node[0];
@ -568,9 +568,9 @@ static inline uint8_t ticker_job_list_manage(
while (user->middle != user->last) { while (user->middle != user->last) {
struct ticker_user_op *user_op; struct ticker_user_op *user_op;
struct ticker_node *ticker; struct ticker_node *ticker;
uint8_t state; u8_t state;
uint8_t prev; u8_t prev;
uint8_t middle; u8_t middle;
user_op = &user_ops[user->middle]; user_op = &user_ops[user->middle];
@ -696,19 +696,19 @@ static inline uint8_t ticker_job_list_manage(
static inline void ticker_job_worker_bottom_half( static inline void ticker_job_worker_bottom_half(
struct ticker_instance *instance, struct ticker_instance *instance,
uint32_t ticks_previous, u32_t ticks_previous,
uint32_t ticks_elapsed, u32_t ticks_elapsed,
uint8_t *insert_head) u8_t *insert_head)
{ {
struct ticker_node *node; struct ticker_node *node;
uint32_t ticks_expired; u32_t ticks_expired;
node = &instance->node[0]; node = &instance->node[0];
ticks_expired = 0; ticks_expired = 0;
while (instance->ticker_id_head != TICKER_NULL) { while (instance->ticker_id_head != TICKER_NULL) {
struct ticker_node *ticker; struct ticker_node *ticker;
uint8_t id_expired; u8_t id_expired;
uint32_t ticks_to_expire; u32_t ticks_to_expire;
/* auto variable for current ticker node */ /* auto variable for current ticker node */
id_expired = instance->ticker_id_head; id_expired = instance->ticker_id_head;
@ -747,7 +747,7 @@ static inline void ticker_job_worker_bottom_half(
/* ticker will be restarted if periodic */ /* ticker will be restarted if periodic */
if (ticker->ticks_periodic != 0) { if (ticker->ticks_periodic != 0) {
uint32_t count; u32_t count;
count = 1 + ticker->lazy_periodic; count = 1 + ticker->lazy_periodic;
@ -780,30 +780,30 @@ static inline void ticker_job_worker_bottom_half(
static inline void ticker_job_list_insert( static inline void ticker_job_list_insert(
struct ticker_instance *instance, struct ticker_instance *instance,
uint8_t insert_head) u8_t insert_head)
{ {
struct ticker_node *node; struct ticker_node *node;
struct ticker_user *users; struct ticker_user *users;
uint8_t count_user; u8_t count_user;
node = &instance->node[0]; node = &instance->node[0];
users = &instance->user[0]; users = &instance->user[0];
count_user = instance->count_user; count_user = instance->count_user;
while (count_user--) { while (count_user--) {
struct ticker_user *user; struct ticker_user *user;
uint8_t user_ops_first; u8_t user_ops_first;
user = &users[count_user]; user = &users[count_user];
user_ops_first = user->first; user_ops_first = user->first;
while ((insert_head != TICKER_NULL) while ((insert_head != TICKER_NULL)
|| (user_ops_first != user->middle) || (user_ops_first != user->middle)
) { ) {
uint8_t id_insert; u8_t id_insert;
uint8_t id_collide; u8_t id_collide;
struct ticker_user_op *user_op; struct ticker_user_op *user_op;
enum ticker_user_op_type _user_op; enum ticker_user_op_type _user_op;
struct ticker_node *ticker; struct ticker_node *ticker;
uint32_t status; u32_t status;
if (insert_head != TICKER_NULL) { if (insert_head != TICKER_NULL) {
id_insert = insert_head; id_insert = insert_head;
@ -813,7 +813,7 @@ static inline void ticker_job_list_insert(
user_op = 0; user_op = 0;
_user_op = TICKER_USER_OP_TYPE_START; _user_op = TICKER_USER_OP_TYPE_START;
} else { } else {
uint8_t first; u8_t first;
user_op = &user->user_op[user_ops_first]; user_op = &user->user_op[user_ops_first];
first = user_ops_first + 1; first = user_ops_first + 1;
@ -940,7 +940,7 @@ static inline void ticker_job_list_inquire(
struct ticker_instance *instance) struct ticker_instance *instance)
{ {
struct ticker_user *users; struct ticker_user *users;
uint8_t count_user; u8_t count_user;
users = &instance->user[0]; users = &instance->user[0];
count_user = instance->count_user; count_user = instance->count_user;
@ -951,7 +951,7 @@ static inline void ticker_job_list_inquire(
while (user->first != user->last) { while (user->first != user->last) {
struct ticker_user_op *user_op; struct ticker_user_op *user_op;
ticker_op_func fp_op_func; ticker_op_func fp_op_func;
uint8_t first; u8_t first;
user_op = &user->user_op[user->first]; user_op = &user->user_op[user->first];
fp_op_func = 0; fp_op_func = 0;
@ -1004,15 +1004,15 @@ static inline void ticker_job_list_inquire(
static inline void ticker_job_compare_update( static inline void ticker_job_compare_update(
struct ticker_instance *instance, struct ticker_instance *instance,
uint8_t ticker_id_old_head) u8_t ticker_id_old_head)
{ {
struct ticker_node *ticker; struct ticker_node *ticker;
struct ticker_node *node; struct ticker_node *node;
uint32_t ticks_to_expire; u32_t ticks_to_expire;
uint32_t ctr_post; u32_t ctr_post;
uint32_t ctr; u32_t ctr;
uint32_t cc; u32_t cc;
uint32_t i; u32_t i;
if (instance->ticker_id_head == TICKER_NULL) { if (instance->ticker_id_head == TICKER_NULL) {
if (cntr_stop() == 0) { if (cntr_stop() == 0) {
@ -1023,7 +1023,7 @@ static inline void ticker_job_compare_update(
} }
if (ticker_id_old_head == TICKER_NULL) { if (ticker_id_old_head == TICKER_NULL) {
uint32_t ticks_current; u32_t ticks_current;
ticks_current = cntr_cnt_get(); ticks_current = cntr_cnt_get();
@ -1043,7 +1043,7 @@ static inline void ticker_job_compare_update(
*/ */
i = 10; i = 10;
do { do {
uint32_t ticks_elapsed; u32_t ticks_elapsed;
LL_ASSERT(i); LL_ASSERT(i);
i--; i--;
@ -1065,13 +1065,13 @@ static inline void ticker_job_compare_update(
static inline void ticker_job(struct ticker_instance *instance) static inline void ticker_job(struct ticker_instance *instance)
{ {
uint8_t ticker_id_old_head; u8_t ticker_id_old_head;
uint8_t insert_head; u8_t insert_head;
uint32_t ticks_elapsed; u32_t ticks_elapsed;
uint32_t ticks_previous; u32_t ticks_previous;
uint8_t flag_elapsed; u8_t flag_elapsed;
uint8_t pending; u8_t pending;
uint8_t flag_compare_update; u8_t flag_compare_update;
DEBUG_TICKER_JOB(1); DEBUG_TICKER_JOB(1);
@ -1088,7 +1088,7 @@ static inline void ticker_job(struct ticker_instance *instance)
/* Update current tick with the elapsed value from queue, and dequeue */ /* Update current tick with the elapsed value from queue, and dequeue */
if (instance->ticks_elapsed_first != instance->ticks_elapsed_last) { if (instance->ticks_elapsed_first != instance->ticks_elapsed_last) {
uint8_t first; u8_t first;
first = instance->ticks_elapsed_first + 1; first = instance->ticks_elapsed_first + 1;
if (first == DOUBLE_BUFFER_SIZE) { if (first == DOUBLE_BUFFER_SIZE) {
@ -1178,7 +1178,7 @@ static inline void ticker_job(struct ticker_instance *instance)
****************************************************************************/ ****************************************************************************/
#include "util/mayfly.h" #include "util/mayfly.h"
static uint8_t ticker_instance0_caller_id_get(uint8_t user_id) static u8_t ticker_instance0_caller_id_get(u8_t user_id)
{ {
switch (user_id) { switch (user_id) {
case MAYFLY_CALL_ID_0: case MAYFLY_CALL_ID_0:
@ -1199,7 +1199,7 @@ static uint8_t ticker_instance0_caller_id_get(uint8_t user_id)
return 0; return 0;
} }
static uint8_t ticker_instance1_caller_id_get(uint8_t user_id) static u8_t ticker_instance1_caller_id_get(u8_t user_id)
{ {
switch (user_id) { switch (user_id) {
case MAYFLY_CALL_ID_2: case MAYFLY_CALL_ID_2:
@ -1218,8 +1218,8 @@ static uint8_t ticker_instance1_caller_id_get(uint8_t user_id)
return 0; return 0;
} }
static void ticker_instance0_sched(uint8_t caller_id, uint8_t callee_id, static void ticker_instance0_sched(u8_t caller_id, u8_t callee_id,
uint8_t chain) u8_t chain)
{ {
/* return value not checked as we allow multiple calls to schedule /* return value not checked as we allow multiple calls to schedule
* before being actually needing the work to complete before new * before being actually needing the work to complete before new
@ -1345,8 +1345,8 @@ static void ticker_instance0_sched(uint8_t caller_id, uint8_t callee_id,
} }
} }
static void ticker_instance1_sched(uint8_t caller_id, uint8_t callee_id, static void ticker_instance1_sched(u8_t caller_id, u8_t callee_id,
uint8_t chain) u8_t chain)
{ {
/* return value not checked as we allow multiple calls to schedule /* return value not checked as we allow multiple calls to schedule
* before being actually needing the work to complete before new * before being actually needing the work to complete before new
@ -1472,12 +1472,12 @@ static void ticker_instance1_sched(uint8_t caller_id, uint8_t callee_id,
} }
} }
static void ticker_instance0_cmp_set(uint32_t value) static void ticker_instance0_cmp_set(u32_t value)
{ {
cntr_cmp_set(0, value); cntr_cmp_set(0, value);
} }
static void ticker_instance1_cmp_set(uint32_t value) static void ticker_instance1_cmp_set(u32_t value)
{ {
cntr_cmp_set(1, value); cntr_cmp_set(1, value);
} }
@ -1485,8 +1485,8 @@ static void ticker_instance1_cmp_set(uint32_t value)
/***************************************************************************** /*****************************************************************************
* Public Interface * Public Interface
****************************************************************************/ ****************************************************************************/
uint32_t ticker_init(uint8_t instance_index, uint8_t count_node, void *node, u32_t ticker_init(u8_t instance_index, u8_t count_node, void *node,
uint8_t count_user, void *user, uint8_t count_op, u8_t count_user, void *user, u8_t count_op,
void *user_op) void *user_op)
{ {
struct ticker_instance *instance = &_instance[instance_index]; struct ticker_instance *instance = &_instance[instance_index];
@ -1547,7 +1547,7 @@ uint32_t ticker_init(uint8_t instance_index, uint8_t count_node, void *node,
return TICKER_STATUS_SUCCESS; return TICKER_STATUS_SUCCESS;
} }
void ticker_trigger(uint8_t instance_index) void ticker_trigger(u8_t instance_index)
{ {
DEBUG_TICKER_ISR(1); DEBUG_TICKER_ISR(1);
@ -1559,15 +1559,15 @@ void ticker_trigger(uint8_t instance_index)
DEBUG_TICKER_ISR(0); DEBUG_TICKER_ISR(0);
} }
uint32_t ticker_start(uint8_t instance_index, uint8_t user_id, u32_t ticker_start(u8_t instance_index, u8_t user_id,
uint8_t _ticker_id, uint32_t ticks_anchor, u8_t _ticker_id, u32_t ticks_anchor,
uint32_t ticks_first, uint32_t ticks_periodic, u32_t ticks_first, u32_t ticks_periodic,
uint32_t remainder_periodic, uint16_t lazy, u32_t remainder_periodic, u16_t lazy,
uint16_t ticks_slot, u16_t ticks_slot,
ticker_timeout_func ticker_timeout_func, void *context, ticker_timeout_func ticker_timeout_func, void *context,
ticker_op_func fp_op_func, void *op_context) ticker_op_func fp_op_func, void *op_context)
{ {
uint8_t last; u8_t last;
struct ticker_instance *instance = &_instance[instance_index]; struct ticker_instance *instance = &_instance[instance_index];
struct ticker_user *user; struct ticker_user *user;
struct ticker_user_op *user_op; struct ticker_user_op *user_op;
@ -1605,14 +1605,14 @@ uint32_t ticker_start(uint8_t instance_index, uint8_t user_id,
return user_op->status; return user_op->status;
} }
uint32_t ticker_update(uint8_t instance_index, uint8_t user_id, u32_t ticker_update(u8_t instance_index, u8_t user_id,
uint8_t _ticker_id, uint16_t ticks_drift_plus, u8_t _ticker_id, u16_t ticks_drift_plus,
uint16_t ticks_drift_minus, uint16_t ticks_slot_plus, u16_t ticks_drift_minus, u16_t ticks_slot_plus,
uint16_t ticks_slot_minus, uint16_t lazy, uint8_t force, u16_t ticks_slot_minus, u16_t lazy, u8_t force,
ticker_op_func fp_op_func, void *op_context) ticker_op_func fp_op_func, void *op_context)
{ {
struct ticker_instance *instance = &_instance[instance_index]; struct ticker_instance *instance = &_instance[instance_index];
uint8_t last; u8_t last;
struct ticker_user *user; struct ticker_user *user;
struct ticker_user_op *user_op; struct ticker_user_op *user_op;
@ -1647,12 +1647,12 @@ uint32_t ticker_update(uint8_t instance_index, uint8_t user_id,
return user_op->status; return user_op->status;
} }
uint32_t ticker_stop(uint8_t instance_index, uint8_t user_id, u32_t ticker_stop(u8_t instance_index, u8_t user_id,
uint8_t _ticker_id, ticker_op_func fp_op_func, u8_t _ticker_id, ticker_op_func fp_op_func,
void *op_context) void *op_context)
{ {
struct ticker_instance *instance = &_instance[instance_index]; struct ticker_instance *instance = &_instance[instance_index];
uint8_t last; u8_t last;
struct ticker_user *user; struct ticker_user *user;
struct ticker_user_op *user_op; struct ticker_user_op *user_op;
@ -1681,14 +1681,14 @@ uint32_t ticker_stop(uint8_t instance_index, uint8_t user_id,
return user_op->status; return user_op->status;
} }
uint32_t ticker_next_slot_get(uint8_t instance_index, uint8_t user_id, u32_t ticker_next_slot_get(u8_t instance_index, u8_t user_id,
uint8_t *_ticker_id, u8_t *_ticker_id,
uint32_t *ticks_current, u32_t *ticks_current,
uint32_t *ticks_to_expire, u32_t *ticks_to_expire,
ticker_op_func fp_op_func, void *op_context) ticker_op_func fp_op_func, void *op_context)
{ {
struct ticker_instance *instance = &_instance[instance_index]; struct ticker_instance *instance = &_instance[instance_index];
uint8_t last; u8_t last;
struct ticker_user *user; struct ticker_user *user;
struct ticker_user_op *user_op; struct ticker_user_op *user_op;
@ -1720,11 +1720,11 @@ uint32_t ticker_next_slot_get(uint8_t instance_index, uint8_t user_id,
return user_op->status; return user_op->status;
} }
uint32_t ticker_job_idle_get(uint8_t instance_index, uint8_t user_id, u32_t ticker_job_idle_get(u8_t instance_index, u8_t user_id,
ticker_op_func fp_op_func, void *op_context) ticker_op_func fp_op_func, void *op_context)
{ {
struct ticker_instance *instance = &_instance[instance_index]; struct ticker_instance *instance = &_instance[instance_index];
uint8_t last; u8_t last;
struct ticker_user *user; struct ticker_user *user;
struct ticker_user_op *user_op; struct ticker_user_op *user_op;
@ -1753,19 +1753,19 @@ uint32_t ticker_job_idle_get(uint8_t instance_index, uint8_t user_id,
return user_op->status; return user_op->status;
} }
void ticker_job_sched(uint8_t instance_index, uint8_t user_id) void ticker_job_sched(u8_t instance_index, u8_t user_id)
{ {
struct ticker_instance *instance = &_instance[instance_index]; struct ticker_instance *instance = &_instance[instance_index];
instance->fp_sched(instance->fp_caller_id_get(user_id), CALL_ID_JOB, 0); instance->fp_sched(instance->fp_caller_id_get(user_id), CALL_ID_JOB, 0);
} }
uint32_t ticker_ticks_now_get(void) u32_t ticker_ticks_now_get(void)
{ {
return cntr_cnt_get(); return cntr_cnt_get();
} }
uint32_t ticker_ticks_diff_get(uint32_t ticks_now, uint32_t ticks_old) u32_t ticker_ticks_diff_get(u32_t ticks_now, u32_t ticks_old)
{ {
return ((ticks_now - ticks_old) & 0x00FFFFFF); return ((ticks_now - ticks_old) & 0x00FFFFFF);
} }

View file

@ -14,7 +14,7 @@
*/ */
#define TICKER_US_TO_TICKS(x) \ #define TICKER_US_TO_TICKS(x) \
( \ ( \
((uint32_t)(((uint64_t) (x) * 1000000000UL) / 30517578125UL)) \ ((u32_t)(((u64_t) (x) * 1000000000UL) / 30517578125UL)) \
& 0x00FFFFFF \ & 0x00FFFFFF \
) )
@ -23,8 +23,8 @@
#define TICKER_REMAINDER(x) \ #define TICKER_REMAINDER(x) \
( \ ( \
( \ ( \
((uint64_t) (x) * 1000000000UL) \ ((u64_t) (x) * 1000000000UL) \
- ((uint64_t) TICKER_US_TO_TICKS(x) * 30517578125UL) \ - ((u64_t) TICKER_US_TO_TICKS(x) * 30517578125UL) \
) \ ) \
/ 1000UL \ / 1000UL \
) )
@ -32,7 +32,7 @@
/** \brief Macro to translate tick units to microseconds. /** \brief Macro to translate tick units to microseconds.
*/ */
#define TICKER_TICKS_TO_US(x) \ #define TICKER_TICKS_TO_US(x) \
((uint32_t)(((uint64_t) (x) * 30517578125UL) / 1000000000UL)) ((u32_t)(((u64_t) (x) * 30517578125UL) / 1000000000UL))
/** \defgroup Timer API return codes. /** \defgroup Timer API return codes.
* *
@ -53,7 +53,7 @@
* *
* @{ * @{
*/ */
#define TICKER_NULL ((uint8_t)((uint8_t)0 - 1)) #define TICKER_NULL ((u8_t)((u8_t)0 - 1))
#define TICKER_NULL_REMAINDER 0 #define TICKER_NULL_REMAINDER 0
#define TICKER_NULL_PERIOD 0 #define TICKER_NULL_PERIOD 0
#define TICKER_NULL_SLOT 0 #define TICKER_NULL_SLOT 0
@ -76,13 +76,13 @@
/** \brief Timer timeout function type. /** \brief Timer timeout function type.
*/ */
typedef void (*ticker_timeout_func) (uint32_t ticks_at_expire, typedef void (*ticker_timeout_func) (u32_t ticks_at_expire,
uint32_t remainder, uint16_t lazy, u32_t remainder, u16_t lazy,
void *context); void *context);
/** \brief Timer operation complete function type. /** \brief Timer operation complete function type.
*/ */
typedef void (*ticker_op_func) (uint32_t status, void *op_context); typedef void (*ticker_op_func) (u32_t status, void *op_context);
/** \brief Timer module initialization. /** \brief Timer module initialization.
* *
@ -95,34 +95,34 @@ typedef void (*ticker_op_func) (uint32_t status, void *op_context);
* \param[in] count_op * \param[in] count_op
* \param[in] user_op * \param[in] user_op
*/ */
uint32_t ticker_init(uint8_t instance_index, uint8_t count_node, void *node, u32_t ticker_init(u8_t instance_index, u8_t count_node, void *node,
uint8_t count_user, void *user, uint8_t count_op, u8_t count_user, void *user, u8_t count_op,
void *user_op); void *user_op);
void ticker_trigger(uint8_t instance_index); void ticker_trigger(u8_t instance_index);
uint32_t ticker_start(uint8_t instance_index, uint8_t user_id, u32_t ticker_start(u8_t instance_index, u8_t user_id,
uint8_t ticker_id, uint32_t ticks_anchor, u8_t ticker_id, u32_t ticks_anchor,
uint32_t ticks_first, uint32_t ticks_periodic, u32_t ticks_first, u32_t ticks_periodic,
uint32_t remainder_periodic, uint16_t lazy, u32_t remainder_periodic, u16_t lazy,
uint16_t ticks_slot, u16_t ticks_slot,
ticker_timeout_func ticker_timeout_func, void *context, ticker_timeout_func ticker_timeout_func, void *context,
ticker_op_func fp_op_func, void *op_context); ticker_op_func fp_op_func, void *op_context);
uint32_t ticker_update(uint8_t instance_index, uint8_t user_id, u32_t ticker_update(u8_t instance_index, u8_t user_id,
uint8_t ticker_id, uint16_t ticks_drift_plus, u8_t ticker_id, u16_t ticks_drift_plus,
uint16_t ticks_drift_minus, uint16_t ticks_slot_plus, u16_t ticks_drift_minus, u16_t ticks_slot_plus,
uint16_t ticks_slot_minus, uint16_t lazy, uint8_t force, u16_t ticks_slot_minus, u16_t lazy, u8_t force,
ticker_op_func fp_op_func, void *op_context); ticker_op_func fp_op_func, void *op_context);
uint32_t ticker_stop(uint8_t instance_index, uint8_t user_id, u32_t ticker_stop(u8_t instance_index, u8_t user_id,
uint8_t ticker_id, ticker_op_func fp_op_func, u8_t ticker_id, ticker_op_func fp_op_func,
void *op_context); void *op_context);
uint32_t ticker_next_slot_get(uint8_t instance_index, uint8_t user_id, u32_t ticker_next_slot_get(u8_t instance_index, u8_t user_id,
uint8_t *ticker_id_head, u8_t *ticker_id_head,
uint32_t *ticks_current, u32_t *ticks_current,
uint32_t *ticks_to_expire, u32_t *ticks_to_expire,
ticker_op_func fp_op_func, void *op_context); ticker_op_func fp_op_func, void *op_context);
uint32_t ticker_job_idle_get(uint8_t instance_index, uint8_t user_id, u32_t ticker_job_idle_get(u8_t instance_index, u8_t user_id,
ticker_op_func fp_op_func, void *op_context); ticker_op_func fp_op_func, void *op_context);
void ticker_job_sched(uint8_t instance_index, uint8_t user_id); void ticker_job_sched(u8_t instance_index, u8_t user_id);
uint32_t ticker_ticks_now_get(void); u32_t ticker_ticks_now_get(void);
uint32_t ticker_ticks_diff_get(uint32_t ticks_now, uint32_t ticks_old); u32_t ticker_ticks_diff_get(u32_t ticks_now, u32_t ticks_old);
#endif #endif

View file

@ -12,21 +12,21 @@
static struct { static struct {
void *head; void *head;
void *tail; void *tail;
uint8_t enable_req; u8_t enable_req;
uint8_t enable_ack; u8_t enable_ack;
uint8_t disable_req; u8_t disable_req;
uint8_t disable_ack; u8_t disable_ack;
} mft[MAYFLY_CALLEE_COUNT][MAYFLY_CALLER_COUNT]; } mft[MAYFLY_CALLEE_COUNT][MAYFLY_CALLER_COUNT];
static void *mfl[MAYFLY_CALLEE_COUNT][MAYFLY_CALLER_COUNT][2]; static void *mfl[MAYFLY_CALLEE_COUNT][MAYFLY_CALLER_COUNT][2];
void mayfly_init(void) void mayfly_init(void)
{ {
uint8_t callee_id; u8_t callee_id;
callee_id = MAYFLY_CALLEE_COUNT; callee_id = MAYFLY_CALLEE_COUNT;
while (callee_id--) { while (callee_id--) {
uint8_t caller_id; u8_t caller_id;
caller_id = MAYFLY_CALLER_COUNT; caller_id = MAYFLY_CALLER_COUNT;
while (caller_id--) { while (caller_id--) {
@ -37,7 +37,7 @@ void mayfly_init(void)
} }
} }
void mayfly_enable(uint8_t caller_id, uint8_t callee_id, uint8_t enable) void mayfly_enable(u8_t caller_id, u8_t callee_id, u8_t enable)
{ {
if (enable) { if (enable) {
if (mft[callee_id][caller_id].enable_req == if (mft[callee_id][caller_id].enable_req ==
@ -56,11 +56,11 @@ void mayfly_enable(uint8_t caller_id, uint8_t callee_id, uint8_t enable)
} }
} }
uint32_t mayfly_enqueue(uint8_t caller_id, uint8_t callee_id, uint8_t chain, u32_t mayfly_enqueue(u8_t caller_id, u8_t callee_id, u8_t chain,
struct mayfly *m) struct mayfly *m)
{ {
uint8_t state; u8_t state;
uint8_t ack; u8_t ack;
chain = chain || !mayfly_prio_is_equal(caller_id, callee_id) || chain = chain || !mayfly_prio_is_equal(caller_id, callee_id) ||
!mayfly_is_enabled(caller_id, callee_id) || !mayfly_is_enabled(caller_id, callee_id) ||
@ -110,11 +110,11 @@ uint32_t mayfly_enqueue(uint8_t caller_id, uint8_t callee_id, uint8_t chain,
return 0; return 0;
} }
void mayfly_run(uint8_t callee_id) void mayfly_run(u8_t callee_id)
{ {
uint8_t disable = 0; u8_t disable = 0;
uint8_t enable = 0; u8_t enable = 0;
uint8_t caller_id; u8_t caller_id;
/* iterate through each caller queue to this callee_id */ /* iterate through each caller queue to this callee_id */
caller_id = MAYFLY_CALLER_COUNT; caller_id = MAYFLY_CALLER_COUNT;
@ -127,8 +127,8 @@ void mayfly_run(uint8_t callee_id)
mft[callee_id][caller_id].head, mft[callee_id][caller_id].head,
(void **)&m); (void **)&m);
while (link) { while (link) {
uint8_t state; u8_t state;
uint8_t req; u8_t req;
/* execute work if ready */ /* execute work if ready */
req = m->_req; req = m->_req;

View file

@ -16,23 +16,23 @@
#define MAYFLY_CALLEE_COUNT 4 #define MAYFLY_CALLEE_COUNT 4
struct mayfly { struct mayfly {
uint8_t volatile _req; u8_t volatile _req;
uint8_t _ack; u8_t _ack;
void *_link; void *_link;
void *param; void *param;
void (*fp)(void *); void (*fp)(void *);
}; };
void mayfly_init(void); void mayfly_init(void);
void mayfly_enable(uint8_t caller_id, uint8_t callee_id, uint8_t enable); void mayfly_enable(u8_t caller_id, u8_t callee_id, u8_t enable);
uint32_t mayfly_enqueue(uint8_t caller_id, uint8_t callee_id, uint8_t chain, u32_t mayfly_enqueue(u8_t caller_id, u8_t callee_id, u8_t chain,
struct mayfly *m); struct mayfly *m);
void mayfly_run(uint8_t callee_id); void mayfly_run(u8_t callee_id);
extern void mayfly_enable_cb(uint8_t caller_id, uint8_t callee_id, extern void mayfly_enable_cb(u8_t caller_id, u8_t callee_id,
uint8_t enable); u8_t enable);
extern uint32_t mayfly_is_enabled(uint8_t caller_id, uint8_t callee_id); extern u32_t mayfly_is_enabled(u8_t caller_id, u8_t callee_id);
extern uint32_t mayfly_prio_is_equal(uint8_t caller_id, uint8_t callee_id); extern u32_t mayfly_prio_is_equal(u8_t caller_id, u8_t callee_id);
extern void mayfly_pend(uint8_t caller_id, uint8_t callee_id); extern void mayfly_pend(u8_t caller_id, u8_t callee_id);
#endif /* _MAYFLY_H_ */ #endif /* _MAYFLY_H_ */

View file

@ -12,7 +12,7 @@
#include "mem.h" #include "mem.h"
void mem_init(void *mem_pool, uint16_t mem_size, uint16_t mem_count, void mem_init(void *mem_pool, u16_t mem_size, u16_t mem_count,
void **mem_head) void **mem_head)
{ {
*mem_head = mem_pool; *mem_head = mem_pool;
@ -20,20 +20,20 @@ void mem_init(void *mem_pool, uint16_t mem_size, uint16_t mem_count,
/* Store free mem_count after the list's next pointer at an aligned /* Store free mem_count after the list's next pointer at an aligned
* memory location to ensure atomic read/write (in ARM for now). * memory location to ensure atomic read/write (in ARM for now).
*/ */
*((uint16_t *)MROUND((uint8_t *)mem_pool + sizeof(mem_pool))) = *((u16_t *)MROUND((u8_t *)mem_pool + sizeof(mem_pool))) =
mem_count; mem_count;
/* Initialize next pointers to form a free list, /* Initialize next pointers to form a free list,
* next pointer is stored in the first 32-bit of each block * next pointer is stored in the first 32-bit of each block
*/ */
memset(((uint8_t *)mem_pool + (mem_size * (--mem_count))), 0, memset(((u8_t *)mem_pool + (mem_size * (--mem_count))), 0,
sizeof(mem_pool)); sizeof(mem_pool));
while (mem_count--) { while (mem_count--) {
uint32_t next; u32_t next;
next = (uint32_t)((uint8_t *) mem_pool + next = (u32_t)((u8_t *) mem_pool +
(mem_size * (mem_count + 1))); (mem_size * (mem_count + 1)));
memcpy(((uint8_t *)mem_pool + (mem_size * mem_count)), memcpy(((u8_t *)mem_pool + (mem_size * mem_count)),
(void *)&next, sizeof(next)); (void *)&next, sizeof(next));
} }
} }
@ -41,12 +41,12 @@ void mem_init(void *mem_pool, uint16_t mem_size, uint16_t mem_count,
void *mem_acquire(void **mem_head) void *mem_acquire(void **mem_head)
{ {
if (*mem_head) { if (*mem_head) {
uint16_t free_count; u16_t free_count;
void *head; void *head;
void *mem; void *mem;
/* Get the free count from the list and decrement it */ /* Get the free count from the list and decrement it */
free_count = *((uint16_t *)MROUND((uint8_t *)*mem_head + free_count = *((u16_t *)MROUND((u8_t *)*mem_head +
sizeof(mem_head))); sizeof(mem_head)));
free_count--; free_count--;
@ -55,7 +55,7 @@ void *mem_acquire(void **mem_head)
/* Store free mem_count after the list's next pointer */ /* Store free mem_count after the list's next pointer */
if (head) { if (head) {
*((uint16_t *)MROUND((uint8_t *)head + sizeof(head))) = *((u16_t *)MROUND((u8_t *)head + sizeof(head))) =
free_count; free_count;
} }
@ -68,11 +68,11 @@ void *mem_acquire(void **mem_head)
void mem_release(void *mem, void **mem_head) void mem_release(void *mem, void **mem_head)
{ {
uint16_t free_count = 0; u16_t free_count = 0;
/* Get the free count from the list and increment it */ /* Get the free count from the list and increment it */
if (*mem_head) { if (*mem_head) {
free_count = *((uint16_t *)MROUND((uint8_t *)*mem_head + free_count = *((u16_t *)MROUND((u8_t *)*mem_head +
sizeof(mem_head))); sizeof(mem_head)));
} }
free_count++; free_count++;
@ -80,36 +80,36 @@ void mem_release(void *mem, void **mem_head)
memcpy(mem, mem_head, sizeof(mem)); memcpy(mem, mem_head, sizeof(mem));
/* Store free mem_count after the list's next pointer */ /* Store free mem_count after the list's next pointer */
*((uint16_t *)MROUND((uint8_t *)mem + sizeof(mem))) = free_count; *((u16_t *)MROUND((u8_t *)mem + sizeof(mem))) = free_count;
*mem_head = mem; *mem_head = mem;
} }
uint16_t mem_free_count_get(void *mem_head) u16_t mem_free_count_get(void *mem_head)
{ {
uint16_t free_count = 0; u16_t free_count = 0;
/* Get the free count from the list */ /* Get the free count from the list */
if (mem_head) { if (mem_head) {
free_count = *((uint16_t *)MROUND((uint8_t *)mem_head + free_count = *((u16_t *)MROUND((u8_t *)mem_head +
sizeof(mem_head))); sizeof(mem_head)));
} }
return free_count; return free_count;
} }
void *mem_get(void *mem_pool, uint16_t mem_size, uint16_t index) void *mem_get(void *mem_pool, u16_t mem_size, u16_t index)
{ {
return ((void *)((uint8_t *)mem_pool + (mem_size * index))); return ((void *)((u8_t *)mem_pool + (mem_size * index)));
} }
uint16_t mem_index_get(void *mem, void *mem_pool, uint16_t mem_size) u16_t mem_index_get(void *mem, void *mem_pool, u16_t mem_size)
{ {
return ((uint16_t)((uint8_t *)mem - (uint8_t *)mem_pool) / return ((u16_t)((u8_t *)mem - (u8_t *)mem_pool) /
mem_size); mem_size);
} }
void mem_rcopy(uint8_t *dst, uint8_t const *src, uint16_t len) void mem_rcopy(u8_t *dst, u8_t const *src, u16_t len)
{ {
src += len; src += len;
while (len--) { while (len--) {
@ -117,7 +117,7 @@ void mem_rcopy(uint8_t *dst, uint8_t const *src, uint16_t len)
} }
} }
uint8_t mem_is_zero(uint8_t *src, uint16_t len) u8_t mem_is_zero(u8_t *src, u16_t len)
{ {
while (len--) { while (len--) {
if (*src++) { if (*src++) {
@ -128,14 +128,14 @@ uint8_t mem_is_zero(uint8_t *src, uint16_t len)
return 0; return 0;
} }
uint32_t mem_ut(void) u32_t mem_ut(void)
{ {
#define BLOCK_SIZE MROUND(10) #define BLOCK_SIZE MROUND(10)
#define BLOCK_COUNT 10 #define BLOCK_COUNT 10
uint8_t MALIGN(4) pool[BLOCK_COUNT][BLOCK_SIZE]; u8_t MALIGN(4) pool[BLOCK_COUNT][BLOCK_SIZE];
void *mem_free; void *mem_free;
void *mem_used; void *mem_used;
uint16_t mem_free_count; u16_t mem_free_count;
void *mem; void *mem;
mem_init(pool, BLOCK_SIZE, BLOCK_COUNT, &mem_free); mem_init(pool, BLOCK_SIZE, BLOCK_COUNT, &mem_free);
@ -147,7 +147,7 @@ uint32_t mem_ut(void)
mem_used = 0; mem_used = 0;
while (mem_free_count--) { while (mem_free_count--) {
uint16_t mem_free_count_current; u16_t mem_free_count_current;
mem = mem_acquire(&mem_free); mem = mem_acquire(&mem_free);
mem_free_count_current = mem_free_count_get(mem_free); mem_free_count_current = mem_free_count_get(mem_free);
@ -165,7 +165,7 @@ uint32_t mem_ut(void)
} }
while (++mem_free_count < BLOCK_COUNT) { while (++mem_free_count < BLOCK_COUNT) {
uint16_t mem_free_count_current; u16_t mem_free_count_current;
mem = mem_used; mem = mem_used;
memcpy(&mem_used, mem, sizeof(void *)); memcpy(&mem_used, mem, sizeof(void *));

View file

@ -13,21 +13,21 @@
#endif #endif
#ifndef MROUND #ifndef MROUND
#define MROUND(x) (((uint32_t)(x)+3) & (~((uint32_t)3))) #define MROUND(x) (((u32_t)(x)+3) & (~((u32_t)3)))
#endif #endif
void mem_init(void *mem_pool, uint16_t mem_size, uint16_t mem_count, void mem_init(void *mem_pool, u16_t mem_size, u16_t mem_count,
void **mem_head); void **mem_head);
void *mem_acquire(void **mem_head); void *mem_acquire(void **mem_head);
void mem_release(void *mem, void **mem_head); void mem_release(void *mem, void **mem_head);
uint16_t mem_free_count_get(void *mem_head); u16_t mem_free_count_get(void *mem_head);
void *mem_get(void *mem_pool, uint16_t mem_size, uint16_t index); void *mem_get(void *mem_pool, u16_t mem_size, u16_t index);
uint16_t mem_index_get(void *mem, void *mem_pool, uint16_t mem_size); u16_t mem_index_get(void *mem, void *mem_pool, u16_t mem_size);
void mem_rcopy(uint8_t *dst, uint8_t const *src, uint16_t len); void mem_rcopy(u8_t *dst, u8_t const *src, u16_t len);
uint8_t mem_is_zero(uint8_t *src, uint16_t len); u8_t mem_is_zero(u8_t *src, u16_t len);
uint32_t mem_ut(void); u32_t mem_ut(void);
#endif /* _MEM_H_ */ #endif /* _MEM_H_ */

View file

@ -65,7 +65,7 @@ void *memq_dequeue(void *tail, void **head, void **mem)
return link; return link;
} }
uint32_t memq_ut(void) u32_t memq_ut(void)
{ {
void *head; void *head;
void *tail; void *tail;

View file

@ -8,12 +8,12 @@
#include <zephyr/types.h> #include <zephyr/types.h>
#include "util.h" #include "util.h"
uint8_t util_ones_count_get(uint8_t *octets, uint8_t octets_len) u8_t util_ones_count_get(u8_t *octets, u8_t octets_len)
{ {
uint8_t one_count = 0; u8_t one_count = 0;
while (octets_len--) { while (octets_len--) {
uint8_t bite; u8_t bite;
bite = *octets; bite = *octets;
while (bite) { while (bite) {

View file

@ -16,6 +16,6 @@
#define TRIPLE_BUFFER_SIZE 3 #define TRIPLE_BUFFER_SIZE 3
#endif #endif
uint8_t util_ones_count_get(uint8_t *octets, uint8_t octets_len); u8_t util_ones_count_get(u8_t *octets, u8_t octets_len);
#endif #endif

View file

@ -45,7 +45,7 @@ void a2d_reset(struct bt_a2dp *a2dp_conn)
struct bt_a2dp *get_new_connection(struct bt_conn *conn) struct bt_a2dp *get_new_connection(struct bt_conn *conn)
{ {
int8_t i, free; s8_t i, free;
free = A2DP_NO_SPACE; free = A2DP_NO_SPACE;
@ -143,7 +143,7 @@ struct bt_a2dp *bt_a2dp_connect(struct bt_conn *conn)
} }
int bt_a2dp_register_endpoint(struct bt_a2dp_endpoint *endpoint, int bt_a2dp_register_endpoint(struct bt_a2dp_endpoint *endpoint,
uint8_t media_type, uint8_t role) u8_t media_type, u8_t role)
{ {
int err; int err;

View file

@ -43,9 +43,9 @@ static void skip_space(struct at_client *at)
} }
} }
int at_get_number(struct at_client *at, uint32_t *val) int at_get_number(struct at_client *at, u32_t *val)
{ {
uint32_t i; u32_t i;
skip_space(at); skip_space(at);
@ -91,7 +91,7 @@ static int get_cmd_value(struct at_client *at, struct net_buf *buf,
char stop_byte, enum at_cmd_state cmd_state) char stop_byte, enum at_cmd_state cmd_state)
{ {
int cmd_len = 0; int cmd_len = 0;
uint8_t pos = at->pos; u8_t pos = at->pos;
const unsigned char *str = buf->data; const unsigned char *str = buf->data;
while (cmd_len < buf->len && at->pos != at->buf_max_len) { while (cmd_len < buf->len && at->pos != at->buf_max_len) {
@ -121,7 +121,7 @@ static int get_response_string(struct at_client *at, struct net_buf *buf,
char stop_byte, enum at_state state) char stop_byte, enum at_state state)
{ {
int cmd_len = 0; int cmd_len = 0;
uint8_t pos = at->pos; u8_t pos = at->pos;
const unsigned char *str = buf->data; const unsigned char *str = buf->data;
while (cmd_len < buf->len && at->pos != at->buf_max_len) { while (cmd_len < buf->len && at->pos != at->buf_max_len) {
@ -267,7 +267,7 @@ static int at_state_process_result(struct at_client *at, struct net_buf *buf)
int cme_handle(struct at_client *at) int cme_handle(struct at_client *at)
{ {
enum at_cme cme_err; enum at_cme cme_err;
uint32_t val; u32_t val;
if (!at_get_number(at, &val) && val <= CME_ERROR_NETWORK_NOT_ALLOWED) { if (!at_get_number(at, &val) && val <= CME_ERROR_NETWORK_NOT_ALLOWED) {
cme_err = val; cme_err = val;
@ -455,7 +455,7 @@ int at_close_list(struct at_client *at)
return 0; return 0;
} }
int at_list_get_string(struct at_client *at, char *name, uint8_t len) int at_list_get_string(struct at_client *at, char *name, u8_t len)
{ {
int i = 0; int i = 0;
@ -490,9 +490,9 @@ int at_list_get_string(struct at_client *at, char *name, uint8_t len)
return 0; return 0;
} }
int at_list_get_range(struct at_client *at, uint32_t *min, uint32_t *max) int at_list_get_range(struct at_client *at, u32_t *min, u32_t *max)
{ {
uint32_t low, high; u32_t low, high;
int ret; int ret;
ret = at_get_number(at, &low); ret = at_get_number(at, &low);

View file

@ -90,10 +90,10 @@ typedef int (*handle_cmd_input_t)(struct at_client *at, struct net_buf *buf,
struct at_client { struct at_client {
unsigned char *buf; unsigned char *buf;
uint8_t pos; u8_t pos;
uint8_t buf_max_len; u8_t buf_max_len;
uint8_t state; u8_t state;
uint8_t cmd_state; u8_t cmd_state;
at_resp_cb_t resp; at_resp_cb_t resp;
at_resp_cb_t unsolicited; at_resp_cb_t unsolicited;
at_finish_cb_t finish; at_finish_cb_t finish;
@ -103,7 +103,7 @@ struct at_client {
void at_register(struct at_client *at, at_resp_cb_t resp, void at_register(struct at_client *at, at_resp_cb_t resp,
at_finish_cb_t finish); at_finish_cb_t finish);
void at_register_unsolicited(struct at_client *at, at_resp_cb_t unsolicited); void at_register_unsolicited(struct at_client *at, at_resp_cb_t unsolicited);
int at_get_number(struct at_client *at, uint32_t *val); int at_get_number(struct at_client *at, u32_t *val);
/* This parsing will only works for non-fragmented net_buf */ /* This parsing will only works for non-fragmented net_buf */
int at_parse_input(struct at_client *at, struct net_buf *buf); int at_parse_input(struct at_client *at, struct net_buf *buf);
/* This command parsing will only works for non-fragmented net_buf */ /* This command parsing will only works for non-fragmented net_buf */
@ -111,8 +111,8 @@ int at_parse_cmd_input(struct at_client *at, struct net_buf *buf,
const char *prefix, parse_val_t func, const char *prefix, parse_val_t func,
enum at_cmd_type type); enum at_cmd_type type);
int at_check_byte(struct net_buf *buf, char check_byte); int at_check_byte(struct net_buf *buf, char check_byte);
int at_list_get_range(struct at_client *at, uint32_t *min, uint32_t *max); int at_list_get_range(struct at_client *at, u32_t *min, u32_t *max);
int at_list_get_string(struct at_client *at, char *name, uint8_t len); int at_list_get_string(struct at_client *at, char *name, u8_t len);
int at_close_list(struct at_client *at); int at_close_list(struct at_client *at);
int at_open_list(struct at_client *at); int at_open_list(struct at_client *at);
int at_has_next_list(struct at_client *at); int at_has_next_list(struct at_client *at);

View file

@ -55,12 +55,12 @@ typedef enum __packed {
ATT_UNKNOWN, ATT_UNKNOWN,
} att_type_t; } att_type_t;
static att_type_t att_op_get_type(uint8_t op); static att_type_t att_op_get_type(u8_t op);
#if CONFIG_BLUETOOTH_ATT_PREPARE_COUNT > 0 #if CONFIG_BLUETOOTH_ATT_PREPARE_COUNT > 0
struct bt_attr_data { struct bt_attr_data {
uint16_t handle; u16_t handle;
uint16_t offset; u16_t offset;
}; };
/* Pool for incoming ATT packets */ /* Pool for incoming ATT packets */
@ -178,8 +178,8 @@ static bt_conn_tx_cb_t att_cb(struct net_buf *buf)
} }
} }
static void send_err_rsp(struct bt_conn *conn, uint8_t req, uint16_t handle, static void send_err_rsp(struct bt_conn *conn, u8_t req, u16_t handle,
uint8_t err) u8_t err)
{ {
struct bt_att_error_rsp *rsp; struct bt_att_error_rsp *rsp;
struct net_buf *buf; struct net_buf *buf;
@ -202,13 +202,13 @@ static void send_err_rsp(struct bt_conn *conn, uint8_t req, uint16_t handle,
bt_l2cap_send_cb(conn, BT_L2CAP_CID_ATT, buf, att_rsp_sent); bt_l2cap_send_cb(conn, BT_L2CAP_CID_ATT, buf, att_rsp_sent);
} }
static uint8_t att_mtu_req(struct bt_att *att, struct net_buf *buf) static u8_t att_mtu_req(struct bt_att *att, struct net_buf *buf)
{ {
struct bt_conn *conn = att->chan.chan.conn; struct bt_conn *conn = att->chan.chan.conn;
struct bt_att_exchange_mtu_req *req; struct bt_att_exchange_mtu_req *req;
struct bt_att_exchange_mtu_rsp *rsp; struct bt_att_exchange_mtu_rsp *rsp;
struct net_buf *pdu; struct net_buf *pdu;
uint16_t mtu_client, mtu_server; u16_t mtu_client, mtu_server;
req = (void *)buf->data; req = (void *)buf->data;
@ -291,8 +291,8 @@ static void att_process(struct bt_att *att)
att_send_req(att, ATT_REQ(node)); att_send_req(att, ATT_REQ(node));
} }
static uint8_t att_handle_rsp(struct bt_att *att, void *pdu, uint16_t len, static u8_t att_handle_rsp(struct bt_att *att, void *pdu, u16_t len,
uint8_t err) u8_t err)
{ {
bt_att_func_t func; bt_att_func_t func;
@ -329,10 +329,10 @@ process:
return 0; return 0;
} }
static uint8_t att_mtu_rsp(struct bt_att *att, struct net_buf *buf) static u8_t att_mtu_rsp(struct bt_att *att, struct net_buf *buf)
{ {
struct bt_att_exchange_mtu_rsp *rsp; struct bt_att_exchange_mtu_rsp *rsp;
uint16_t mtu; u16_t mtu;
if (!att) { if (!att) {
return 0; return 0;
@ -363,7 +363,7 @@ static uint8_t att_mtu_rsp(struct bt_att *att, struct net_buf *buf)
return att_handle_rsp(att, rsp, buf->len, 0); return att_handle_rsp(att, rsp, buf->len, 0);
} }
static bool range_is_valid(uint16_t start, uint16_t end, uint16_t *err) static bool range_is_valid(u16_t start, u16_t end, u16_t *err)
{ {
/* Handle 0 is invalid */ /* Handle 0 is invalid */
if (!start || !end) { if (!start || !end) {
@ -394,7 +394,7 @@ struct find_info_data {
}; };
}; };
static uint8_t find_info_cb(const struct bt_gatt_attr *attr, void *user_data) static u8_t find_info_cb(const struct bt_gatt_attr *attr, void *user_data)
{ {
struct find_info_data *data = user_data; struct find_info_data *data = user_data;
struct bt_att *att = data->att; struct bt_att *att = data->att;
@ -445,8 +445,8 @@ static uint8_t find_info_cb(const struct bt_gatt_attr *attr, void *user_data)
return BT_GATT_ITER_STOP; return BT_GATT_ITER_STOP;
} }
static uint8_t att_find_info_rsp(struct bt_att *att, uint16_t start_handle, static u8_t att_find_info_rsp(struct bt_att *att, u16_t start_handle,
uint16_t end_handle) u16_t end_handle)
{ {
struct bt_conn *conn = att->chan.chan.conn; struct bt_conn *conn = att->chan.chan.conn;
struct find_info_data data; struct find_info_data data;
@ -474,11 +474,11 @@ static uint8_t att_find_info_rsp(struct bt_att *att, uint16_t start_handle,
return 0; return 0;
} }
static uint8_t att_find_info_req(struct bt_att *att, struct net_buf *buf) static u8_t att_find_info_req(struct bt_att *att, struct net_buf *buf)
{ {
struct bt_conn *conn = att->chan.chan.conn; struct bt_conn *conn = att->chan.chan.conn;
struct bt_att_find_info_req *req; struct bt_att_find_info_req *req;
uint16_t start_handle, end_handle, err_handle; u16_t start_handle, end_handle, err_handle;
req = (void *)buf->data; req = (void *)buf->data;
@ -502,17 +502,17 @@ struct find_type_data {
struct net_buf *buf; struct net_buf *buf;
struct bt_att_handle_group *group; struct bt_att_handle_group *group;
const void *value; const void *value;
uint8_t value_len; u8_t value_len;
uint8_t err; u8_t err;
}; };
static uint8_t find_type_cb(const struct bt_gatt_attr *attr, void *user_data) static u8_t find_type_cb(const struct bt_gatt_attr *attr, void *user_data)
{ {
struct find_type_data *data = user_data; struct find_type_data *data = user_data;
struct bt_att *att = data->att; struct bt_att *att = data->att;
struct bt_conn *conn = att->chan.chan.conn; struct bt_conn *conn = att->chan.chan.conn;
int read; int read;
uint8_t uuid[16]; u8_t uuid[16];
/* Skip secondary services */ /* Skip secondary services */
if (!bt_uuid_cmp(attr->uuid, BT_UUID_GATT_SECONDARY)) { if (!bt_uuid_cmp(attr->uuid, BT_UUID_GATT_SECONDARY)) {
@ -564,9 +564,9 @@ static uint8_t find_type_cb(const struct bt_gatt_attr *attr, void *user_data)
return BT_GATT_ITER_CONTINUE; return BT_GATT_ITER_CONTINUE;
} }
static uint8_t att_find_type_rsp(struct bt_att *att, uint16_t start_handle, static u8_t att_find_type_rsp(struct bt_att *att, u16_t start_handle,
uint16_t end_handle, const void *value, u16_t end_handle, const void *value,
uint8_t value_len) u8_t value_len)
{ {
struct bt_conn *conn = att->chan.chan.conn; struct bt_conn *conn = att->chan.chan.conn;
struct find_type_data data; struct find_type_data data;
@ -602,12 +602,12 @@ static uint8_t att_find_type_rsp(struct bt_att *att, uint16_t start_handle,
return 0; return 0;
} }
static uint8_t att_find_type_req(struct bt_att *att, struct net_buf *buf) static u8_t att_find_type_req(struct bt_att *att, struct net_buf *buf)
{ {
struct bt_conn *conn = att->chan.chan.conn; struct bt_conn *conn = att->chan.chan.conn;
struct bt_att_find_type_req *req; struct bt_att_find_type_req *req;
uint16_t start_handle, end_handle, err_handle, type; u16_t start_handle, end_handle, err_handle, type;
uint8_t *value; u8_t *value;
req = (void *)buf->data; req = (void *)buf->data;
@ -656,8 +656,8 @@ static bool uuid_create(struct bt_uuid *uuid, struct net_buf *buf)
return false; return false;
} }
static uint8_t check_perm(struct bt_conn *conn, const struct bt_gatt_attr *attr, static u8_t check_perm(struct bt_conn *conn, const struct bt_gatt_attr *attr,
uint8_t mask) u8_t mask)
{ {
if ((mask & BT_GATT_PERM_READ) && if ((mask & BT_GATT_PERM_READ) &&
(!(attr->perm & BT_GATT_PERM_READ_MASK) || !attr->read)) { (!(attr->perm & BT_GATT_PERM_READ_MASK) || !attr->read)) {
@ -693,7 +693,7 @@ static uint8_t check_perm(struct bt_conn *conn, const struct bt_gatt_attr *attr,
return 0; return 0;
} }
static uint8_t err_to_att(int err) static u8_t err_to_att(int err)
{ {
BT_DBG("%d", err); BT_DBG("%d", err);
@ -710,10 +710,10 @@ struct read_type_data {
struct net_buf *buf; struct net_buf *buf;
struct bt_att_read_type_rsp *rsp; struct bt_att_read_type_rsp *rsp;
struct bt_att_data *item; struct bt_att_data *item;
uint8_t err; u8_t err;
}; };
static uint8_t read_type_cb(const struct bt_gatt_attr *attr, void *user_data) static u8_t read_type_cb(const struct bt_gatt_attr *attr, void *user_data)
{ {
struct read_type_data *data = user_data; struct read_type_data *data = user_data;
struct bt_att *att = data->att; struct bt_att *att = data->att;
@ -779,8 +779,8 @@ static uint8_t read_type_cb(const struct bt_gatt_attr *attr, void *user_data)
BT_GATT_ITER_CONTINUE : BT_GATT_ITER_STOP; BT_GATT_ITER_CONTINUE : BT_GATT_ITER_STOP;
} }
static uint8_t att_read_type_rsp(struct bt_att *att, struct bt_uuid *uuid, static u8_t att_read_type_rsp(struct bt_att *att, struct bt_uuid *uuid,
uint16_t start_handle, uint16_t end_handle) u16_t start_handle, u16_t end_handle)
{ {
struct bt_conn *conn = att->chan.chan.conn; struct bt_conn *conn = att->chan.chan.conn;
struct read_type_data data; struct read_type_data data;
@ -816,11 +816,11 @@ static uint8_t att_read_type_rsp(struct bt_att *att, struct bt_uuid *uuid,
return 0; return 0;
} }
static uint8_t att_read_type_req(struct bt_att *att, struct net_buf *buf) static u8_t att_read_type_req(struct bt_att *att, struct net_buf *buf)
{ {
struct bt_conn *conn = att->chan.chan.conn; struct bt_conn *conn = att->chan.chan.conn;
struct bt_att_read_type_req *req; struct bt_att_read_type_req *req;
uint16_t start_handle, end_handle, err_handle; u16_t start_handle, end_handle, err_handle;
union { union {
struct bt_uuid uuid; struct bt_uuid uuid;
struct bt_uuid_16 u16; struct bt_uuid_16 u16;
@ -856,13 +856,13 @@ static uint8_t att_read_type_req(struct bt_att *att, struct net_buf *buf)
struct read_data { struct read_data {
struct bt_att *att; struct bt_att *att;
uint16_t offset; u16_t offset;
struct net_buf *buf; struct net_buf *buf;
struct bt_att_read_rsp *rsp; struct bt_att_read_rsp *rsp;
uint8_t err; u8_t err;
}; };
static uint8_t read_cb(const struct bt_gatt_attr *attr, void *user_data) static u8_t read_cb(const struct bt_gatt_attr *attr, void *user_data)
{ {
struct read_data *data = user_data; struct read_data *data = user_data;
struct bt_att *att = data->att; struct bt_att *att = data->att;
@ -898,8 +898,8 @@ static uint8_t read_cb(const struct bt_gatt_attr *attr, void *user_data)
return BT_GATT_ITER_CONTINUE; return BT_GATT_ITER_CONTINUE;
} }
static uint8_t att_read_rsp(struct bt_att *att, uint8_t op, uint8_t rsp, static u8_t att_read_rsp(struct bt_att *att, u8_t op, u8_t rsp,
uint16_t handle, uint16_t offset) u16_t handle, u16_t offset)
{ {
struct bt_conn *conn = att->chan.chan.conn; struct bt_conn *conn = att->chan.chan.conn;
struct read_data data; struct read_data data;
@ -936,10 +936,10 @@ static uint8_t att_read_rsp(struct bt_att *att, uint8_t op, uint8_t rsp,
return 0; return 0;
} }
static uint8_t att_read_req(struct bt_att *att, struct net_buf *buf) static u8_t att_read_req(struct bt_att *att, struct net_buf *buf)
{ {
struct bt_att_read_req *req; struct bt_att_read_req *req;
uint16_t handle; u16_t handle;
req = (void *)buf->data; req = (void *)buf->data;
@ -951,10 +951,10 @@ static uint8_t att_read_req(struct bt_att *att, struct net_buf *buf)
handle, 0); handle, 0);
} }
static uint8_t att_read_blob_req(struct bt_att *att, struct net_buf *buf) static u8_t att_read_blob_req(struct bt_att *att, struct net_buf *buf)
{ {
struct bt_att_read_blob_req *req; struct bt_att_read_blob_req *req;
uint16_t handle, offset; u16_t handle, offset;
req = (void *)buf->data; req = (void *)buf->data;
@ -967,11 +967,11 @@ static uint8_t att_read_blob_req(struct bt_att *att, struct net_buf *buf)
BT_ATT_OP_READ_BLOB_RSP, handle, offset); BT_ATT_OP_READ_BLOB_RSP, handle, offset);
} }
static uint8_t att_read_mult_req(struct bt_att *att, struct net_buf *buf) static u8_t att_read_mult_req(struct bt_att *att, struct net_buf *buf)
{ {
struct bt_conn *conn = att->chan.chan.conn; struct bt_conn *conn = att->chan.chan.conn;
struct read_data data; struct read_data data;
uint16_t handle; u16_t handle;
memset(&data, 0, sizeof(data)); memset(&data, 0, sizeof(data));
@ -982,7 +982,7 @@ static uint8_t att_read_mult_req(struct bt_att *att, struct net_buf *buf)
data.att = att; data.att = att;
while (buf->len >= sizeof(uint16_t)) { while (buf->len >= sizeof(u16_t)) {
handle = net_buf_pull_le16(buf); handle = net_buf_pull_le16(buf);
BT_DBG("handle 0x%04x ", handle); BT_DBG("handle 0x%04x ", handle);
@ -1021,7 +1021,7 @@ struct read_group_data {
struct bt_att_group_data *group; struct bt_att_group_data *group;
}; };
static uint8_t read_group_cb(const struct bt_gatt_attr *attr, void *user_data) static u8_t read_group_cb(const struct bt_gatt_attr *attr, void *user_data)
{ {
struct read_group_data *data = user_data; struct read_group_data *data = user_data;
struct bt_att *att = data->att; struct bt_att *att = data->att;
@ -1081,8 +1081,8 @@ static uint8_t read_group_cb(const struct bt_gatt_attr *attr, void *user_data)
return BT_GATT_ITER_CONTINUE; return BT_GATT_ITER_CONTINUE;
} }
static uint8_t att_read_group_rsp(struct bt_att *att, struct bt_uuid *uuid, static u8_t att_read_group_rsp(struct bt_att *att, struct bt_uuid *uuid,
uint16_t start_handle, uint16_t end_handle) u16_t start_handle, u16_t end_handle)
{ {
struct bt_conn *conn = att->chan.chan.conn; struct bt_conn *conn = att->chan.chan.conn;
struct read_group_data data; struct read_group_data data;
@ -1116,11 +1116,11 @@ static uint8_t att_read_group_rsp(struct bt_att *att, struct bt_uuid *uuid,
return 0; return 0;
} }
static uint8_t att_read_group_req(struct bt_att *att, struct net_buf *buf) static u8_t att_read_group_req(struct bt_att *att, struct net_buf *buf)
{ {
struct bt_conn *conn = att->chan.chan.conn; struct bt_conn *conn = att->chan.chan.conn;
struct bt_att_read_group_req *req; struct bt_att_read_group_req *req;
uint16_t start_handle, end_handle, err_handle; u16_t start_handle, end_handle, err_handle;
union { union {
struct bt_uuid uuid; struct bt_uuid uuid;
struct bt_uuid_16 u16; struct bt_uuid_16 u16;
@ -1171,14 +1171,14 @@ static uint8_t att_read_group_req(struct bt_att *att, struct net_buf *buf)
struct write_data { struct write_data {
struct bt_conn *conn; struct bt_conn *conn;
struct net_buf *buf; struct net_buf *buf;
uint8_t op; u8_t op;
const void *value; const void *value;
uint8_t len; u8_t len;
uint16_t offset; u16_t offset;
uint8_t err; u8_t err;
}; };
static uint8_t write_cb(const struct bt_gatt_attr *attr, void *user_data) static u8_t write_cb(const struct bt_gatt_attr *attr, void *user_data)
{ {
struct write_data *data = user_data; struct write_data *data = user_data;
int write; int write;
@ -1204,9 +1204,9 @@ static uint8_t write_cb(const struct bt_gatt_attr *attr, void *user_data)
return BT_GATT_ITER_CONTINUE; return BT_GATT_ITER_CONTINUE;
} }
static uint8_t att_write_rsp(struct bt_conn *conn, uint8_t op, uint8_t rsp, static u8_t att_write_rsp(struct bt_conn *conn, u8_t op, u8_t rsp,
uint16_t handle, uint16_t offset, u16_t handle, u16_t offset,
const void *value, uint8_t len) const void *value, u8_t len)
{ {
struct write_data data; struct write_data data;
@ -1251,10 +1251,10 @@ static uint8_t att_write_rsp(struct bt_conn *conn, uint8_t op, uint8_t rsp,
return 0; return 0;
} }
static uint8_t att_write_req(struct bt_att *att, struct net_buf *buf) static u8_t att_write_req(struct bt_att *att, struct net_buf *buf)
{ {
struct bt_conn *conn = att->chan.chan.conn; struct bt_conn *conn = att->chan.chan.conn;
uint16_t handle; u16_t handle;
handle = net_buf_pull_le16(buf); handle = net_buf_pull_le16(buf);
@ -1269,12 +1269,12 @@ struct prep_data {
struct bt_conn *conn; struct bt_conn *conn;
struct net_buf *buf; struct net_buf *buf;
const void *value; const void *value;
uint8_t len; u8_t len;
uint16_t offset; u16_t offset;
uint8_t err; u8_t err;
}; };
static uint8_t prep_write_cb(const struct bt_gatt_attr *attr, void *user_data) static u8_t prep_write_cb(const struct bt_gatt_attr *attr, void *user_data)
{ {
struct prep_data *data = user_data; struct prep_data *data = user_data;
struct bt_attr_data *attr_data; struct bt_attr_data *attr_data;
@ -1319,9 +1319,9 @@ static uint8_t prep_write_cb(const struct bt_gatt_attr *attr, void *user_data)
return BT_GATT_ITER_CONTINUE; return BT_GATT_ITER_CONTINUE;
} }
static uint8_t att_prep_write_rsp(struct bt_att *att, uint16_t handle, static u8_t att_prep_write_rsp(struct bt_att *att, u16_t handle,
uint16_t offset, const void *value, u16_t offset, const void *value,
uint8_t len) u8_t len)
{ {
struct bt_conn *conn = att->chan.chan.conn; struct bt_conn *conn = att->chan.chan.conn;
struct prep_data data; struct prep_data data;
@ -1371,13 +1371,13 @@ static uint8_t att_prep_write_rsp(struct bt_att *att, uint16_t handle,
} }
#endif /* CONFIG_BLUETOOTH_ATT_PREPARE_COUNT */ #endif /* CONFIG_BLUETOOTH_ATT_PREPARE_COUNT */
static uint8_t att_prepare_write_req(struct bt_att *att, struct net_buf *buf) static u8_t att_prepare_write_req(struct bt_att *att, struct net_buf *buf)
{ {
#if CONFIG_BLUETOOTH_ATT_PREPARE_COUNT == 0 #if CONFIG_BLUETOOTH_ATT_PREPARE_COUNT == 0
return BT_ATT_ERR_NOT_SUPPORTED; return BT_ATT_ERR_NOT_SUPPORTED;
#else #else
struct bt_att_prepare_write_req *req; struct bt_att_prepare_write_req *req;
uint16_t handle, offset; u16_t handle, offset;
req = (void *)buf->data; req = (void *)buf->data;
@ -1392,11 +1392,11 @@ static uint8_t att_prepare_write_req(struct bt_att *att, struct net_buf *buf)
} }
#if CONFIG_BLUETOOTH_ATT_PREPARE_COUNT > 0 #if CONFIG_BLUETOOTH_ATT_PREPARE_COUNT > 0
static uint8_t att_exec_write_rsp(struct bt_att *att, uint8_t flags) static u8_t att_exec_write_rsp(struct bt_att *att, u8_t flags)
{ {
struct bt_conn *conn = att->chan.chan.conn; struct bt_conn *conn = att->chan.chan.conn;
struct net_buf *buf; struct net_buf *buf;
uint8_t err = 0; u8_t err = 0;
while ((buf = net_buf_get(&att->prep_queue, K_NO_WAIT))) { while ((buf = net_buf_get(&att->prep_queue, K_NO_WAIT))) {
struct bt_attr_data *data = net_buf_user_data(buf); struct bt_attr_data *data = net_buf_user_data(buf);
@ -1436,7 +1436,7 @@ static uint8_t att_exec_write_rsp(struct bt_att *att, uint8_t flags)
#endif /* CONFIG_BLUETOOTH_ATT_PREPARE_COUNT */ #endif /* CONFIG_BLUETOOTH_ATT_PREPARE_COUNT */
static uint8_t att_exec_write_req(struct bt_att *att, struct net_buf *buf) static u8_t att_exec_write_req(struct bt_att *att, struct net_buf *buf)
{ {
#if CONFIG_BLUETOOTH_ATT_PREPARE_COUNT == 0 #if CONFIG_BLUETOOTH_ATT_PREPARE_COUNT == 0
return BT_ATT_ERR_NOT_SUPPORTED; return BT_ATT_ERR_NOT_SUPPORTED;
@ -1451,10 +1451,10 @@ static uint8_t att_exec_write_req(struct bt_att *att, struct net_buf *buf)
#endif /* CONFIG_BLUETOOTH_ATT_PREPARE_COUNT */ #endif /* CONFIG_BLUETOOTH_ATT_PREPARE_COUNT */
} }
static uint8_t att_write_cmd(struct bt_att *att, struct net_buf *buf) static u8_t att_write_cmd(struct bt_att *att, struct net_buf *buf)
{ {
struct bt_conn *conn = att->chan.chan.conn; struct bt_conn *conn = att->chan.chan.conn;
uint16_t handle; u16_t handle;
handle = net_buf_pull_le16(buf); handle = net_buf_pull_le16(buf);
@ -1463,11 +1463,11 @@ static uint8_t att_write_cmd(struct bt_att *att, struct net_buf *buf)
return att_write_rsp(conn, 0, 0, handle, 0, buf->data, buf->len); return att_write_rsp(conn, 0, 0, handle, 0, buf->data, buf->len);
} }
static uint8_t att_signed_write_cmd(struct bt_att *att, struct net_buf *buf) static u8_t att_signed_write_cmd(struct bt_att *att, struct net_buf *buf)
{ {
struct bt_conn *conn = att->chan.chan.conn; struct bt_conn *conn = att->chan.chan.conn;
struct bt_att_signed_write_cmd *req; struct bt_att_signed_write_cmd *req;
uint16_t handle; u16_t handle;
int err; int err;
req = (void *)buf->data; req = (void *)buf->data;
@ -1493,7 +1493,7 @@ static uint8_t att_signed_write_cmd(struct bt_att *att, struct net_buf *buf)
} }
#if defined(CONFIG_BLUETOOTH_SMP) #if defined(CONFIG_BLUETOOTH_SMP)
static int att_change_security(struct bt_conn *conn, uint8_t err) static int att_change_security(struct bt_conn *conn, u8_t err)
{ {
bt_security_t sec; bt_security_t sec;
@ -1554,10 +1554,10 @@ static int att_change_security(struct bt_conn *conn, uint8_t err)
} }
#endif /* CONFIG_BLUETOOTH_SMP */ #endif /* CONFIG_BLUETOOTH_SMP */
static uint8_t att_error_rsp(struct bt_att *att, struct net_buf *buf) static u8_t att_error_rsp(struct bt_att *att, struct net_buf *buf)
{ {
struct bt_att_error_rsp *rsp; struct bt_att_error_rsp *rsp;
uint8_t err; u8_t err;
rsp = (void *)buf->data; rsp = (void *)buf->data;
@ -1592,7 +1592,7 @@ done:
return att_handle_rsp(att, NULL, 0, err); return att_handle_rsp(att, NULL, 0, err);
} }
static uint8_t att_handle_find_info_rsp(struct bt_att *att, static u8_t att_handle_find_info_rsp(struct bt_att *att,
struct net_buf *buf) struct net_buf *buf)
{ {
BT_DBG(""); BT_DBG("");
@ -1600,7 +1600,7 @@ static uint8_t att_handle_find_info_rsp(struct bt_att *att,
return att_handle_rsp(att, buf->data, buf->len, 0); return att_handle_rsp(att, buf->data, buf->len, 0);
} }
static uint8_t att_handle_find_type_rsp(struct bt_att *att, static u8_t att_handle_find_type_rsp(struct bt_att *att,
struct net_buf *buf) struct net_buf *buf)
{ {
BT_DBG(""); BT_DBG("");
@ -1608,7 +1608,7 @@ static uint8_t att_handle_find_type_rsp(struct bt_att *att,
return att_handle_rsp(att, buf->data, buf->len, 0); return att_handle_rsp(att, buf->data, buf->len, 0);
} }
static uint8_t att_handle_read_type_rsp(struct bt_att *att, static u8_t att_handle_read_type_rsp(struct bt_att *att,
struct net_buf *buf) struct net_buf *buf)
{ {
BT_DBG(""); BT_DBG("");
@ -1616,7 +1616,7 @@ static uint8_t att_handle_read_type_rsp(struct bt_att *att,
return att_handle_rsp(att, buf->data, buf->len, 0); return att_handle_rsp(att, buf->data, buf->len, 0);
} }
static uint8_t att_handle_read_rsp(struct bt_att *att, static u8_t att_handle_read_rsp(struct bt_att *att,
struct net_buf *buf) struct net_buf *buf)
{ {
BT_DBG(""); BT_DBG("");
@ -1624,7 +1624,7 @@ static uint8_t att_handle_read_rsp(struct bt_att *att,
return att_handle_rsp(att, buf->data, buf->len, 0); return att_handle_rsp(att, buf->data, buf->len, 0);
} }
static uint8_t att_handle_read_blob_rsp(struct bt_att *att, static u8_t att_handle_read_blob_rsp(struct bt_att *att,
struct net_buf *buf) struct net_buf *buf)
{ {
BT_DBG(""); BT_DBG("");
@ -1632,7 +1632,7 @@ static uint8_t att_handle_read_blob_rsp(struct bt_att *att,
return att_handle_rsp(att, buf->data, buf->len, 0); return att_handle_rsp(att, buf->data, buf->len, 0);
} }
static uint8_t att_handle_read_mult_rsp(struct bt_att *att, static u8_t att_handle_read_mult_rsp(struct bt_att *att,
struct net_buf *buf) struct net_buf *buf)
{ {
BT_DBG(""); BT_DBG("");
@ -1640,7 +1640,7 @@ static uint8_t att_handle_read_mult_rsp(struct bt_att *att,
return att_handle_rsp(att, buf->data, buf->len, 0); return att_handle_rsp(att, buf->data, buf->len, 0);
} }
static uint8_t att_handle_write_rsp(struct bt_att *att, static u8_t att_handle_write_rsp(struct bt_att *att,
struct net_buf *buf) struct net_buf *buf)
{ {
BT_DBG(""); BT_DBG("");
@ -1648,7 +1648,7 @@ static uint8_t att_handle_write_rsp(struct bt_att *att,
return att_handle_rsp(att, buf->data, buf->len, 0); return att_handle_rsp(att, buf->data, buf->len, 0);
} }
static uint8_t att_handle_prepare_write_rsp(struct bt_att *att, static u8_t att_handle_prepare_write_rsp(struct bt_att *att,
struct net_buf *buf) struct net_buf *buf)
{ {
BT_DBG(""); BT_DBG("");
@ -1656,7 +1656,7 @@ static uint8_t att_handle_prepare_write_rsp(struct bt_att *att,
return att_handle_rsp(att, buf->data, buf->len, 0); return att_handle_rsp(att, buf->data, buf->len, 0);
} }
static uint8_t att_handle_exec_write_rsp(struct bt_att *att, static u8_t att_handle_exec_write_rsp(struct bt_att *att,
struct net_buf *buf) struct net_buf *buf)
{ {
BT_DBG(""); BT_DBG("");
@ -1664,10 +1664,10 @@ static uint8_t att_handle_exec_write_rsp(struct bt_att *att,
return att_handle_rsp(att, buf->data, buf->len, 0); return att_handle_rsp(att, buf->data, buf->len, 0);
} }
static uint8_t att_notify(struct bt_att *att, struct net_buf *buf) static u8_t att_notify(struct bt_att *att, struct net_buf *buf)
{ {
struct bt_conn *conn = att->chan.chan.conn; struct bt_conn *conn = att->chan.chan.conn;
uint16_t handle; u16_t handle;
handle = net_buf_pull_le16(buf); handle = net_buf_pull_le16(buf);
@ -1678,10 +1678,10 @@ static uint8_t att_notify(struct bt_att *att, struct net_buf *buf)
return 0; return 0;
} }
static uint8_t att_indicate(struct bt_att *att, struct net_buf *buf) static u8_t att_indicate(struct bt_att *att, struct net_buf *buf)
{ {
struct bt_conn *conn = att->chan.chan.conn; struct bt_conn *conn = att->chan.chan.conn;
uint16_t handle; u16_t handle;
handle = net_buf_pull_le16(buf); handle = net_buf_pull_le16(buf);
@ -1699,7 +1699,7 @@ static uint8_t att_indicate(struct bt_att *att, struct net_buf *buf)
return 0; return 0;
} }
static uint8_t att_confirm(struct bt_att *att, struct net_buf *buf) static u8_t att_confirm(struct bt_att *att, struct net_buf *buf)
{ {
BT_DBG(""); BT_DBG("");
@ -1707,10 +1707,10 @@ static uint8_t att_confirm(struct bt_att *att, struct net_buf *buf)
} }
static const struct att_handler { static const struct att_handler {
uint8_t op; u8_t op;
uint8_t expect_len; u8_t expect_len;
att_type_t type; att_type_t type;
uint8_t (*func)(struct bt_att *att, struct net_buf *buf); u8_t (*func)(struct bt_att *att, struct net_buf *buf);
} handlers[] = { } handlers[] = {
{ BT_ATT_OP_ERROR_RSP, { BT_ATT_OP_ERROR_RSP,
sizeof(struct bt_att_error_rsp), sizeof(struct bt_att_error_rsp),
@ -1823,7 +1823,7 @@ static const struct att_handler {
att_signed_write_cmd }, att_signed_write_cmd },
}; };
static att_type_t att_op_get_type(uint8_t op) static att_type_t att_op_get_type(u8_t op)
{ {
const struct att_handler *handler; const struct att_handler *handler;
int i; int i;
@ -1842,7 +1842,7 @@ static void bt_att_recv(struct bt_l2cap_chan *chan, struct net_buf *buf)
struct bt_att *att = ATT_CHAN(chan); struct bt_att *att = ATT_CHAN(chan);
struct bt_att_hdr *hdr = (void *)buf->data; struct bt_att_hdr *hdr = (void *)buf->data;
const struct att_handler *handler; const struct att_handler *handler;
uint8_t err; u8_t err;
size_t i; size_t i;
if (buf->len < sizeof(*hdr)) { if (buf->len < sizeof(*hdr)) {
@ -1917,7 +1917,7 @@ static struct bt_att *att_chan_get(struct bt_conn *conn)
return att; return att;
} }
struct net_buf *bt_att_create_pdu(struct bt_conn *conn, uint8_t op, size_t len) struct net_buf *bt_att_create_pdu(struct bt_conn *conn, u8_t op, size_t len)
{ {
struct bt_att_hdr *hdr; struct bt_att_hdr *hdr;
struct net_buf *buf; struct net_buf *buf;
@ -2039,7 +2039,7 @@ static void bt_att_disconnected(struct bt_l2cap_chan *chan)
#if defined(CONFIG_BLUETOOTH_SMP) #if defined(CONFIG_BLUETOOTH_SMP)
static void bt_att_encrypt_change(struct bt_l2cap_chan *chan, static void bt_att_encrypt_change(struct bt_l2cap_chan *chan,
uint8_t hci_status) u8_t hci_status)
{ {
struct bt_att *att = ATT_CHAN(chan); struct bt_att *att = ATT_CHAN(chan);
struct bt_l2cap_le_chan *ch = BT_L2CAP_LE_CHAN(chan); struct bt_l2cap_le_chan *ch = BT_L2CAP_LE_CHAN(chan);
@ -2127,7 +2127,7 @@ void bt_att_init(void)
bt_l2cap_le_fixed_chan_register(&chan); bt_l2cap_le_fixed_chan_register(&chan);
} }
uint16_t bt_att_get_mtu(struct bt_conn *conn) u16_t bt_att_get_mtu(struct bt_conn *conn)
{ {
struct bt_att *att; struct bt_att *att;

View file

@ -15,31 +15,31 @@
#endif #endif
struct bt_att_hdr { struct bt_att_hdr {
uint8_t code; u8_t code;
} __packed; } __packed;
#define BT_ATT_OP_ERROR_RSP 0x01 #define BT_ATT_OP_ERROR_RSP 0x01
struct bt_att_error_rsp { struct bt_att_error_rsp {
uint8_t request; u8_t request;
uint16_t handle; u16_t handle;
uint8_t error; u8_t error;
} __packed; } __packed;
#define BT_ATT_OP_MTU_REQ 0x02 #define BT_ATT_OP_MTU_REQ 0x02
struct bt_att_exchange_mtu_req { struct bt_att_exchange_mtu_req {
uint16_t mtu; u16_t mtu;
} __packed; } __packed;
#define BT_ATT_OP_MTU_RSP 0x03 #define BT_ATT_OP_MTU_RSP 0x03
struct bt_att_exchange_mtu_rsp { struct bt_att_exchange_mtu_rsp {
uint16_t mtu; u16_t mtu;
} __packed; } __packed;
/* Find Information Request */ /* Find Information Request */
#define BT_ATT_OP_FIND_INFO_REQ 0x04 #define BT_ATT_OP_FIND_INFO_REQ 0x04
struct bt_att_find_info_req { struct bt_att_find_info_req {
uint16_t start_handle; u16_t start_handle;
uint16_t end_handle; u16_t end_handle;
} __packed; } __packed;
/* Format field values for BT_ATT_OP_FIND_INFO_RSP */ /* Format field values for BT_ATT_OP_FIND_INFO_RSP */
@ -47,34 +47,34 @@ struct bt_att_find_info_req {
#define BT_ATT_INFO_128 0x02 #define BT_ATT_INFO_128 0x02
struct bt_att_info_16 { struct bt_att_info_16 {
uint16_t handle; u16_t handle;
uint16_t uuid; u16_t uuid;
} __packed; } __packed;
struct bt_att_info_128 { struct bt_att_info_128 {
uint16_t handle; u16_t handle;
uint8_t uuid[16]; u8_t uuid[16];
} __packed; } __packed;
/* Find Information Response */ /* Find Information Response */
#define BT_ATT_OP_FIND_INFO_RSP 0x05 #define BT_ATT_OP_FIND_INFO_RSP 0x05
struct bt_att_find_info_rsp { struct bt_att_find_info_rsp {
uint8_t format; u8_t format;
uint8_t info[0]; u8_t info[0];
} __packed; } __packed;
/* Find By Type Value Request */ /* Find By Type Value Request */
#define BT_ATT_OP_FIND_TYPE_REQ 0x06 #define BT_ATT_OP_FIND_TYPE_REQ 0x06
struct bt_att_find_type_req { struct bt_att_find_type_req {
uint16_t start_handle; u16_t start_handle;
uint16_t end_handle; u16_t end_handle;
uint16_t type; u16_t type;
uint8_t value[0]; u8_t value[0];
} __packed; } __packed;
struct bt_att_handle_group { struct bt_att_handle_group {
uint16_t start_handle; u16_t start_handle;
uint16_t end_handle; u16_t end_handle;
} __packed; } __packed;
/* Find By Type Value Response */ /* Find By Type Value Response */
@ -86,46 +86,46 @@ struct bt_att_find_type_rsp {
/* Read By Type Request */ /* Read By Type Request */
#define BT_ATT_OP_READ_TYPE_REQ 0x08 #define BT_ATT_OP_READ_TYPE_REQ 0x08
struct bt_att_read_type_req { struct bt_att_read_type_req {
uint16_t start_handle; u16_t start_handle;
uint16_t end_handle; u16_t end_handle;
uint8_t uuid[0]; u8_t uuid[0];
} __packed; } __packed;
struct bt_att_data { struct bt_att_data {
uint16_t handle; u16_t handle;
uint8_t value[0]; u8_t value[0];
} __packed; } __packed;
/* Read By Type Response */ /* Read By Type Response */
#define BT_ATT_OP_READ_TYPE_RSP 0x09 #define BT_ATT_OP_READ_TYPE_RSP 0x09
struct bt_att_read_type_rsp { struct bt_att_read_type_rsp {
uint8_t len; u8_t len;
struct bt_att_data data[0]; struct bt_att_data data[0];
} __packed; } __packed;
/* Read Request */ /* Read Request */
#define BT_ATT_OP_READ_REQ 0x0a #define BT_ATT_OP_READ_REQ 0x0a
struct bt_att_read_req { struct bt_att_read_req {
uint16_t handle; u16_t handle;
} __packed; } __packed;
/* Read Response */ /* Read Response */
#define BT_ATT_OP_READ_RSP 0x0b #define BT_ATT_OP_READ_RSP 0x0b
struct bt_att_read_rsp { struct bt_att_read_rsp {
uint8_t value[0]; u8_t value[0];
} __packed; } __packed;
/* Read Blob Request */ /* Read Blob Request */
#define BT_ATT_OP_READ_BLOB_REQ 0x0c #define BT_ATT_OP_READ_BLOB_REQ 0x0c
struct bt_att_read_blob_req { struct bt_att_read_blob_req {
uint16_t handle; u16_t handle;
uint16_t offset; u16_t offset;
} __packed; } __packed;
/* Read Blob Response */ /* Read Blob Response */
#define BT_ATT_OP_READ_BLOB_RSP 0x0d #define BT_ATT_OP_READ_BLOB_RSP 0x0d
struct bt_att_read_blob_rsp { struct bt_att_read_blob_rsp {
uint8_t value[0]; u8_t value[0];
} __packed; } __packed;
/* Read Multiple Request */ /* Read Multiple Request */
@ -133,41 +133,41 @@ struct bt_att_read_blob_rsp {
#define BT_ATT_OP_READ_MULT_REQ 0x0e #define BT_ATT_OP_READ_MULT_REQ 0x0e
struct bt_att_read_mult_req { struct bt_att_read_mult_req {
uint16_t handles[0]; u16_t handles[0];
} __packed; } __packed;
/* Read Multiple Respose */ /* Read Multiple Respose */
#define BT_ATT_OP_READ_MULT_RSP 0x0f #define BT_ATT_OP_READ_MULT_RSP 0x0f
struct bt_att_read_mult_rsp { struct bt_att_read_mult_rsp {
uint8_t value[0]; u8_t value[0];
} __packed; } __packed;
/* Read by Group Type Request */ /* Read by Group Type Request */
#define BT_ATT_OP_READ_GROUP_REQ 0x10 #define BT_ATT_OP_READ_GROUP_REQ 0x10
struct bt_att_read_group_req { struct bt_att_read_group_req {
uint16_t start_handle; u16_t start_handle;
uint16_t end_handle; u16_t end_handle;
uint8_t uuid[0]; u8_t uuid[0];
} __packed; } __packed;
struct bt_att_group_data { struct bt_att_group_data {
uint16_t start_handle; u16_t start_handle;
uint16_t end_handle; u16_t end_handle;
uint8_t value[0]; u8_t value[0];
} __packed; } __packed;
/* Read by Group Type Response */ /* Read by Group Type Response */
#define BT_ATT_OP_READ_GROUP_RSP 0x11 #define BT_ATT_OP_READ_GROUP_RSP 0x11
struct bt_att_read_group_rsp { struct bt_att_read_group_rsp {
uint8_t len; u8_t len;
struct bt_att_group_data data[0]; struct bt_att_group_data data[0];
} __packed; } __packed;
/* Write Request */ /* Write Request */
#define BT_ATT_OP_WRITE_REQ 0x12 #define BT_ATT_OP_WRITE_REQ 0x12
struct bt_att_write_req { struct bt_att_write_req {
uint16_t handle; u16_t handle;
uint8_t value[0]; u8_t value[0];
} __packed; } __packed;
/* Write Response */ /* Write Response */
@ -176,17 +176,17 @@ struct bt_att_write_req {
/* Prepare Write Request */ /* Prepare Write Request */
#define BT_ATT_OP_PREPARE_WRITE_REQ 0x16 #define BT_ATT_OP_PREPARE_WRITE_REQ 0x16
struct bt_att_prepare_write_req { struct bt_att_prepare_write_req {
uint16_t handle; u16_t handle;
uint16_t offset; u16_t offset;
uint8_t value[0]; u8_t value[0];
} __packed; } __packed;
/* Prepare Write Respond */ /* Prepare Write Respond */
#define BT_ATT_OP_PREPARE_WRITE_RSP 0x17 #define BT_ATT_OP_PREPARE_WRITE_RSP 0x17
struct bt_att_prepare_write_rsp { struct bt_att_prepare_write_rsp {
uint16_t handle; u16_t handle;
uint16_t offset; u16_t offset;
uint8_t value[0]; u8_t value[0];
} __packed; } __packed;
/* Execute Write Request */ /* Execute Write Request */
@ -195,7 +195,7 @@ struct bt_att_prepare_write_rsp {
#define BT_ATT_OP_EXEC_WRITE_REQ 0x18 #define BT_ATT_OP_EXEC_WRITE_REQ 0x18
struct bt_att_exec_write_req { struct bt_att_exec_write_req {
uint8_t flags; u8_t flags;
} __packed; } __packed;
/* Execute Write Response */ /* Execute Write Response */
@ -204,41 +204,41 @@ struct bt_att_exec_write_req {
/* Handle Value Notification */ /* Handle Value Notification */
#define BT_ATT_OP_NOTIFY 0x1b #define BT_ATT_OP_NOTIFY 0x1b
struct bt_att_notify { struct bt_att_notify {
uint16_t handle; u16_t handle;
uint8_t value[0]; u8_t value[0];
} __packed; } __packed;
/* Handle Value Indication */ /* Handle Value Indication */
#define BT_ATT_OP_INDICATE 0x1d #define BT_ATT_OP_INDICATE 0x1d
struct bt_att_indicate { struct bt_att_indicate {
uint16_t handle; u16_t handle;
uint8_t value[0]; u8_t value[0];
} __packed; } __packed;
/* Handle Value Confirm */ /* Handle Value Confirm */
#define BT_ATT_OP_CONFIRM 0x1e #define BT_ATT_OP_CONFIRM 0x1e
struct bt_att_signature { struct bt_att_signature {
uint8_t value[12]; u8_t value[12];
} __packed; } __packed;
/* Write Command */ /* Write Command */
#define BT_ATT_OP_WRITE_CMD 0x52 #define BT_ATT_OP_WRITE_CMD 0x52
struct bt_att_write_cmd { struct bt_att_write_cmd {
uint16_t handle; u16_t handle;
uint8_t value[0]; u8_t value[0];
} __packed; } __packed;
/* Signed Write Command */ /* Signed Write Command */
#define BT_ATT_OP_SIGNED_WRITE_CMD 0xd2 #define BT_ATT_OP_SIGNED_WRITE_CMD 0xd2
struct bt_att_signed_write_cmd { struct bt_att_signed_write_cmd {
uint16_t handle; u16_t handle;
uint8_t value[0]; u8_t value[0];
} __packed; } __packed;
void bt_att_init(void); void bt_att_init(void);
uint16_t bt_att_get_mtu(struct bt_conn *conn); u16_t bt_att_get_mtu(struct bt_conn *conn);
struct net_buf *bt_att_create_pdu(struct bt_conn *conn, uint8_t op, struct net_buf *bt_att_create_pdu(struct bt_conn *conn, u8_t op,
size_t len); size_t len);
/* Send ATT PDU over a connection */ /* Send ATT PDU over a connection */

View file

@ -47,9 +47,9 @@ static struct bt_avdtp_seid_lsep *lseps;
#define AVDTP_TIMEOUT K_SECONDS(6) #define AVDTP_TIMEOUT K_SECONDS(6)
static const struct { static const struct {
uint8_t sig_id; u8_t sig_id;
void (*func)(struct bt_avdtp *session, struct net_buf *buf, void (*func)(struct bt_avdtp *session, struct net_buf *buf,
uint8_t msg_type); u8_t msg_type);
} handler[] = { } handler[] = {
}; };
@ -78,12 +78,12 @@ static int avdtp_send(struct bt_avdtp *session,
return result; return result;
} }
static struct net_buf *avdtp_create_pdu(uint8_t msg_type, static struct net_buf *avdtp_create_pdu(u8_t msg_type,
uint8_t pkt_type, u8_t pkt_type,
uint8_t sig_id) u8_t sig_id)
{ {
struct net_buf *buf; struct net_buf *buf;
static uint8_t tid; static u8_t tid;
struct bt_avdtp_single_sig_hdr *hdr; struct bt_avdtp_single_sig_hdr *hdr;
BT_DBG(""); BT_DBG("");
@ -136,7 +136,7 @@ void bt_avdtp_l2cap_disconnected(struct bt_l2cap_chan *chan)
/* Clear the Pending req if set*/ /* Clear the Pending req if set*/
} }
void bt_avdtp_l2cap_encrypt_changed(struct bt_l2cap_chan *chan, uint8_t status) void bt_avdtp_l2cap_encrypt_changed(struct bt_l2cap_chan *chan, u8_t status)
{ {
BT_DBG(""); BT_DBG("");
} }
@ -145,7 +145,7 @@ void bt_avdtp_l2cap_recv(struct bt_l2cap_chan *chan, struct net_buf *buf)
{ {
struct bt_avdtp_single_sig_hdr *hdr = (void *)buf->data; struct bt_avdtp_single_sig_hdr *hdr = (void *)buf->data;
struct bt_avdtp *session = AVDTP_CHAN(chan); struct bt_avdtp *session = AVDTP_CHAN(chan);
uint8_t i, msgtype, sigid, tid; u8_t i, msgtype, sigid, tid;
if (buf->len < sizeof(*hdr)) { if (buf->len < sizeof(*hdr)) {
BT_ERR("Recvd Wrong AVDTP Header"); BT_ERR("Recvd Wrong AVDTP Header");
@ -256,12 +256,12 @@ int bt_avdtp_register(struct bt_avdtp_event_cb *cb)
return 0; return 0;
} }
int bt_avdtp_register_sep(uint8_t media_type, uint8_t role, int bt_avdtp_register_sep(u8_t media_type, u8_t role,
struct bt_avdtp_seid_lsep *lsep) struct bt_avdtp_seid_lsep *lsep)
{ {
BT_DBG(""); BT_DBG("");
static uint8_t bt_avdtp_seid = BT_AVDTP_MIN_SEID; static u8_t bt_avdtp_seid = BT_AVDTP_MIN_SEID;
if (!lsep) { if (!lsep) {
return -EIO; return -EIO;

View file

@ -94,15 +94,15 @@ typedef int (*bt_avdtp_func_t)(struct bt_avdtp *session,
struct bt_avdtp_req *req); struct bt_avdtp_req *req);
struct bt_avdtp_req { struct bt_avdtp_req {
uint8_t sig; u8_t sig;
uint8_t tid; u8_t tid;
bt_avdtp_func_t func; bt_avdtp_func_t func;
struct k_delayed_work timeout_work; struct k_delayed_work timeout_work;
}; };
struct bt_avdtp_single_sig_hdr { struct bt_avdtp_single_sig_hdr {
uint8_t hdr; u8_t hdr;
uint8_t signal_id; u8_t signal_id;
} __packed; } __packed;
#define BT_AVDTP_SIG_HDR_LEN sizeof(struct bt_avdtp_single_sig_hdr) #define BT_AVDTP_SIG_HDR_LEN sizeof(struct bt_avdtp_single_sig_hdr)
@ -120,20 +120,20 @@ struct bt_avdtp_ind_cb {
}; };
struct bt_avdtp_cap { struct bt_avdtp_cap {
uint8_t cat; u8_t cat;
uint8_t len; u8_t len;
uint8_t data[0]; u8_t data[0];
}; };
struct bt_avdtp_sep { struct bt_avdtp_sep {
uint8_t seid; u8_t seid;
uint8_t len; u8_t len;
struct bt_avdtp_cap caps[0]; struct bt_avdtp_cap caps[0];
}; };
struct bt_avdtp_discover_params { struct bt_avdtp_discover_params {
struct bt_avdtp_req req; struct bt_avdtp_req req;
uint8_t status; u8_t status;
struct bt_avdtp_sep *caps; struct bt_avdtp_sep *caps;
}; };
@ -162,7 +162,7 @@ int bt_avdtp_connect(struct bt_conn *conn, struct bt_avdtp *session);
int bt_avdtp_disconnect(struct bt_avdtp *session); int bt_avdtp_disconnect(struct bt_avdtp *session);
/* AVDTP SEP register function */ /* AVDTP SEP register function */
int bt_avdtp_register_sep(uint8_t media_type, uint8_t role, int bt_avdtp_register_sep(u8_t media_type, u8_t role,
struct bt_avdtp_seid_lsep *sep); struct bt_avdtp_seid_lsep *sep);
/* AVDTP Discover Request */ /* AVDTP Discover Request */

View file

@ -67,7 +67,7 @@ enum pairing_method {
}; };
/* based on table 5.7, Core Spec 4.2, Vol.3 Part C, 5.2.2.6 */ /* based on table 5.7, Core Spec 4.2, Vol.3 Part C, 5.2.2.6 */
static const uint8_t ssp_method[4 /* remote */][4 /* local */] = { static const u8_t ssp_method[4 /* remote */][4 /* local */] = {
{ JUST_WORKS, JUST_WORKS, PASSKEY_INPUT, JUST_WORKS }, { JUST_WORKS, JUST_WORKS, PASSKEY_INPUT, JUST_WORKS },
{ JUST_WORKS, PASSKEY_CONFIRM, PASSKEY_INPUT, JUST_WORKS }, { JUST_WORKS, PASSKEY_CONFIRM, PASSKEY_INPUT, JUST_WORKS },
{ PASSKEY_DISPLAY, PASSKEY_DISPLAY, PASSKEY_INPUT, JUST_WORKS }, { PASSKEY_DISPLAY, PASSKEY_DISPLAY, PASSKEY_INPUT, JUST_WORKS },
@ -458,7 +458,7 @@ static int pin_code_neg_reply(const bt_addr_t *bdaddr)
return bt_hci_cmd_send_sync(BT_HCI_OP_PIN_CODE_NEG_REPLY, buf, NULL); return bt_hci_cmd_send_sync(BT_HCI_OP_PIN_CODE_NEG_REPLY, buf, NULL);
} }
static int pin_code_reply(struct bt_conn *conn, const char *pin, uint8_t len) static int pin_code_reply(struct bt_conn *conn, const char *pin, u8_t len)
{ {
struct bt_hci_cp_pin_code_reply *cp; struct bt_hci_cp_pin_code_reply *cp;
struct net_buf *buf; struct net_buf *buf;
@ -531,7 +531,7 @@ void bt_conn_pin_code_req(struct bt_conn *conn)
} }
} }
uint8_t bt_conn_get_io_capa(void) u8_t bt_conn_get_io_capa(void)
{ {
if (!bt_auth) { if (!bt_auth) {
return BT_IO_NO_INPUT_OUTPUT; return BT_IO_NO_INPUT_OUTPUT;
@ -552,12 +552,12 @@ uint8_t bt_conn_get_io_capa(void)
return BT_IO_NO_INPUT_OUTPUT; return BT_IO_NO_INPUT_OUTPUT;
} }
static uint8_t ssp_pair_method(const struct bt_conn *conn) static u8_t ssp_pair_method(const struct bt_conn *conn)
{ {
return ssp_method[conn->br.remote_io_capa][bt_conn_get_io_capa()]; return ssp_method[conn->br.remote_io_capa][bt_conn_get_io_capa()];
} }
uint8_t bt_conn_ssp_get_auth(const struct bt_conn *conn) u8_t bt_conn_ssp_get_auth(const struct bt_conn *conn)
{ {
/* Validate no bond auth request, and if valid use it. */ /* Validate no bond auth request, and if valid use it. */
if ((conn->br.remote_auth == BT_HCI_NO_BONDING) || if ((conn->br.remote_auth == BT_HCI_NO_BONDING) ||
@ -612,7 +612,7 @@ static int ssp_confirm_neg_reply(struct bt_conn *conn)
NULL); NULL);
} }
void bt_conn_ssp_auth(struct bt_conn *conn, uint32_t passkey) void bt_conn_ssp_auth(struct bt_conn *conn, u32_t passkey)
{ {
conn->br.pairing_method = ssp_pair_method(conn); conn->br.pairing_method = ssp_pair_method(conn);
@ -767,8 +767,8 @@ void bt_conn_identity_resolved(struct bt_conn *conn)
} }
} }
int bt_conn_le_start_encryption(struct bt_conn *conn, uint64_t rand, int bt_conn_le_start_encryption(struct bt_conn *conn, u64_t rand,
uint16_t ediv, const uint8_t *ltk, size_t len) u16_t ediv, const u8_t *ltk, size_t len)
{ {
struct bt_hci_cp_le_start_encryption *cp; struct bt_hci_cp_le_start_encryption *cp;
struct net_buf *buf; struct net_buf *buf;
@ -793,7 +793,7 @@ int bt_conn_le_start_encryption(struct bt_conn *conn, uint64_t rand,
#endif /* CONFIG_BLUETOOTH_SMP */ #endif /* CONFIG_BLUETOOTH_SMP */
#if defined(CONFIG_BLUETOOTH_SMP) || defined(CONFIG_BLUETOOTH_BREDR) #if defined(CONFIG_BLUETOOTH_SMP) || defined(CONFIG_BLUETOOTH_BREDR)
uint8_t bt_conn_enc_key_size(struct bt_conn *conn) u8_t bt_conn_enc_key_size(struct bt_conn *conn)
{ {
if (!conn->encrypt) { if (!conn->encrypt) {
return 0; return 0;
@ -805,7 +805,7 @@ uint8_t bt_conn_enc_key_size(struct bt_conn *conn)
struct bt_hci_rp_read_encryption_key_size *rp; struct bt_hci_rp_read_encryption_key_size *rp;
struct net_buf *buf; struct net_buf *buf;
struct net_buf *rsp; struct net_buf *rsp;
uint8_t key_size; u8_t key_size;
buf = bt_hci_cmd_create(BT_HCI_OP_READ_ENCRYPTION_KEY_SIZE, buf = bt_hci_cmd_create(BT_HCI_OP_READ_ENCRYPTION_KEY_SIZE,
sizeof(*cp)); sizeof(*cp));
@ -965,10 +965,10 @@ static void bt_conn_reset_rx_state(struct bt_conn *conn)
conn->rx_len = 0; conn->rx_len = 0;
} }
void bt_conn_recv(struct bt_conn *conn, struct net_buf *buf, uint8_t flags) void bt_conn_recv(struct bt_conn *conn, struct net_buf *buf, u8_t flags)
{ {
struct bt_l2cap_hdr *hdr; struct bt_l2cap_hdr *hdr;
uint16_t len; u16_t len;
BT_DBG("handle %u len %u flags %02x", conn->handle, buf->len, flags); BT_DBG("handle %u len %u flags %02x", conn->handle, buf->len, flags);
@ -1112,7 +1112,7 @@ static void add_pending_tx(struct bt_conn *conn, bt_conn_tx_cb_t cb)
irq_unlock(key); irq_unlock(key);
} }
static bool send_frag(struct bt_conn *conn, struct net_buf *buf, uint8_t flags, static bool send_frag(struct bt_conn *conn, struct net_buf *buf, u8_t flags,
bool always_consume) bool always_consume)
{ {
struct bt_hci_acl_hdr *hdr; struct bt_hci_acl_hdr *hdr;
@ -1157,7 +1157,7 @@ fail:
return false; return false;
} }
static inline uint16_t conn_mtu(struct bt_conn *conn) static inline u16_t conn_mtu(struct bt_conn *conn)
{ {
#if defined(CONFIG_BLUETOOTH_BREDR) #if defined(CONFIG_BLUETOOTH_BREDR)
if (conn->type == BT_CONN_TYPE_BR || !bt_dev.le.mtu) { if (conn->type == BT_CONN_TYPE_BR || !bt_dev.le.mtu) {
@ -1171,7 +1171,7 @@ static inline uint16_t conn_mtu(struct bt_conn *conn)
static struct net_buf *create_frag(struct bt_conn *conn, struct net_buf *buf) static struct net_buf *create_frag(struct bt_conn *conn, struct net_buf *buf)
{ {
struct net_buf *frag; struct net_buf *frag;
uint16_t frag_len; u16_t frag_len;
frag = bt_conn_create_pdu(NULL, 0); frag = bt_conn_create_pdu(NULL, 0);
@ -1472,7 +1472,7 @@ void bt_conn_set_state(struct bt_conn *conn, bt_conn_state_t state)
} }
} }
struct bt_conn *bt_conn_lookup_handle(uint16_t handle) struct bt_conn *bt_conn_lookup_handle(u16_t handle)
{ {
int i; int i;
@ -1642,7 +1642,7 @@ int bt_conn_get_info(const struct bt_conn *conn, struct bt_conn_info *info)
return -EINVAL; return -EINVAL;
} }
static int bt_hci_disconnect(struct bt_conn *conn, uint8_t reason) static int bt_hci_disconnect(struct bt_conn *conn, u8_t reason)
{ {
struct net_buf *buf; struct net_buf *buf;
struct bt_hci_cp_disconnect *disconn; struct bt_hci_cp_disconnect *disconn;
@ -1700,7 +1700,7 @@ int bt_conn_le_param_update(struct bt_conn *conn,
return bt_l2cap_update_conn_param(conn, param); return bt_l2cap_update_conn_param(conn, param);
} }
int bt_conn_disconnect(struct bt_conn *conn, uint8_t reason) int bt_conn_disconnect(struct bt_conn *conn, u8_t reason)
{ {
/* Disconnection is initiated by us, so auto connection shall /* Disconnection is initiated by us, so auto connection shall
* be disabled. Otherwise the passive scan would be enabled * be disabled. Otherwise the passive scan would be enabled

View file

@ -35,14 +35,14 @@ struct bt_conn_le {
bt_addr_le_t init_addr; bt_addr_le_t init_addr;
bt_addr_le_t resp_addr; bt_addr_le_t resp_addr;
uint16_t interval; u16_t interval;
uint16_t interval_min; u16_t interval_min;
uint16_t interval_max; u16_t interval_max;
uint16_t latency; u16_t latency;
uint16_t timeout; u16_t timeout;
uint8_t features[1][8]; u8_t features[1][8];
struct bt_keys *keys; struct bt_keys *keys;
@ -56,11 +56,11 @@ struct bt_conn_le {
struct bt_conn_br { struct bt_conn_br {
bt_addr_t dst; bt_addr_t dst;
uint8_t remote_io_capa; u8_t remote_io_capa;
uint8_t remote_auth; u8_t remote_auth;
uint8_t pairing_method; u8_t pairing_method;
/* remote LMP features pages per 8 bytes each */ /* remote LMP features pages per 8 bytes each */
uint8_t features[LMP_MAX_PAGES][8]; u8_t features[LMP_MAX_PAGES][8];
struct bt_keys_link_key *link_key; struct bt_keys_link_key *link_key;
}; };
@ -68,7 +68,7 @@ struct bt_conn_br {
struct bt_conn_sco { struct bt_conn_sco {
/* Reference to ACL Connection */ /* Reference to ACL Connection */
struct bt_conn *acl; struct bt_conn *acl;
uint16_t pkt_type; u16_t pkt_type;
}; };
#endif #endif
@ -80,19 +80,19 @@ struct bt_conn_tx {
}; };
struct bt_conn { struct bt_conn {
uint16_t handle; u16_t handle;
uint8_t type; u8_t type;
uint8_t role; u8_t role;
ATOMIC_DEFINE(flags, BT_CONN_NUM_FLAGS); ATOMIC_DEFINE(flags, BT_CONN_NUM_FLAGS);
#if defined(CONFIG_BLUETOOTH_SMP) || defined(CONFIG_BLUETOOTH_BREDR) #if defined(CONFIG_BLUETOOTH_SMP) || defined(CONFIG_BLUETOOTH_BREDR)
bt_security_t sec_level; bt_security_t sec_level;
bt_security_t required_sec_level; bt_security_t required_sec_level;
uint8_t encrypt; u8_t encrypt;
#endif /* CONFIG_BLUETOOTH_SMP || CONFIG_BLUETOOTH_BREDR */ #endif /* CONFIG_BLUETOOTH_SMP || CONFIG_BLUETOOTH_BREDR */
uint16_t rx_len; u16_t rx_len;
struct net_buf *rx; struct net_buf *rx;
/* Sent but not acknowledged TX packets */ /* Sent but not acknowledged TX packets */
@ -109,7 +109,7 @@ struct bt_conn {
atomic_t ref; atomic_t ref;
/* Connection error or reason for disconnect */ /* Connection error or reason for disconnect */
uint8_t err; u8_t err;
bt_conn_state_t state; bt_conn_state_t state;
@ -123,7 +123,7 @@ struct bt_conn {
}; };
/* Process incoming data for a connection */ /* Process incoming data for a connection */
void bt_conn_recv(struct bt_conn *conn, struct net_buf *buf, uint8_t flags); void bt_conn_recv(struct bt_conn *conn, struct net_buf *buf, u8_t flags);
/* Send data over a connection */ /* Send data over a connection */
int bt_conn_send_cb(struct bt_conn *conn, struct net_buf *buf, int bt_conn_send_cb(struct bt_conn *conn, struct net_buf *buf,
@ -153,14 +153,14 @@ struct bt_conn *bt_conn_lookup_addr_sco(const bt_addr_t *peer);
struct bt_conn *bt_conn_lookup_addr_br(const bt_addr_t *peer); struct bt_conn *bt_conn_lookup_addr_br(const bt_addr_t *peer);
void bt_conn_pin_code_req(struct bt_conn *conn); void bt_conn_pin_code_req(struct bt_conn *conn);
uint8_t bt_conn_get_io_capa(void); u8_t bt_conn_get_io_capa(void);
uint8_t bt_conn_ssp_get_auth(const struct bt_conn *conn); u8_t bt_conn_ssp_get_auth(const struct bt_conn *conn);
void bt_conn_ssp_auth(struct bt_conn *conn, uint32_t passkey); void bt_conn_ssp_auth(struct bt_conn *conn, u32_t passkey);
void bt_conn_disconnect_all(void); void bt_conn_disconnect_all(void);
/* Look up an existing connection */ /* Look up an existing connection */
struct bt_conn *bt_conn_lookup_handle(uint16_t handle); struct bt_conn *bt_conn_lookup_handle(u16_t handle);
/* Compare an address with bt_conn destination address */ /* Compare an address with bt_conn destination address */
int bt_conn_addr_le_cmp(const struct bt_conn *conn, const bt_addr_le_t *peer); int bt_conn_addr_le_cmp(const struct bt_conn *conn, const bt_addr_le_t *peer);
@ -183,8 +183,8 @@ bool le_param_req(struct bt_conn *conn, struct bt_le_conn_param *param);
#if defined(CONFIG_BLUETOOTH_SMP) #if defined(CONFIG_BLUETOOTH_SMP)
/* rand and ediv should be in BT order */ /* rand and ediv should be in BT order */
int bt_conn_le_start_encryption(struct bt_conn *conn, uint64_t rand, int bt_conn_le_start_encryption(struct bt_conn *conn, u64_t rand,
uint16_t ediv, const uint8_t *ltk, size_t len); u16_t ediv, const u8_t *ltk, size_t len);
/* Notify higher layers that RPA was resolved */ /* Notify higher layers that RPA was resolved */
void bt_conn_identity_resolved(struct bt_conn *conn); void bt_conn_identity_resolved(struct bt_conn *conn);

View file

@ -29,8 +29,8 @@ static struct tc_hmac_prng_struct prng;
static int prng_reseed(struct tc_hmac_prng_struct *h) static int prng_reseed(struct tc_hmac_prng_struct *h)
{ {
uint8_t seed[32]; u8_t seed[32];
int64_t extra; s64_t extra;
int ret, i; int ret, i;
for (i = 0; i < (sizeof(seed) / 8); i++) { for (i = 0; i < (sizeof(seed) / 8); i++) {
@ -50,7 +50,7 @@ static int prng_reseed(struct tc_hmac_prng_struct *h)
extra = k_uptime_get(); extra = k_uptime_get();
ret = tc_hmac_prng_reseed(h, seed, sizeof(seed), (uint8_t *)&extra, ret = tc_hmac_prng_reseed(h, seed, sizeof(seed), (u8_t *)&extra,
sizeof(extra)); sizeof(extra));
if (ret == TC_CRYPTO_FAIL) { if (ret == TC_CRYPTO_FAIL) {
BT_ERR("Failed to re-seed PRNG"); BT_ERR("Failed to re-seed PRNG");
@ -107,11 +107,11 @@ int bt_rand(void *buf, size_t len)
return -EIO; return -EIO;
} }
int bt_encrypt_le(const uint8_t key[16], const uint8_t plaintext[16], int bt_encrypt_le(const u8_t key[16], const u8_t plaintext[16],
uint8_t enc_data[16]) u8_t enc_data[16])
{ {
struct tc_aes_key_sched_struct s; struct tc_aes_key_sched_struct s;
uint8_t tmp[16]; u8_t tmp[16];
BT_DBG("key %s plaintext %s", bt_hex(key, 16), bt_hex(plaintext, 16)); BT_DBG("key %s plaintext %s", bt_hex(key, 16), bt_hex(plaintext, 16));
@ -134,8 +134,8 @@ int bt_encrypt_le(const uint8_t key[16], const uint8_t plaintext[16],
return 0; return 0;
} }
int bt_encrypt_be(const uint8_t key[16], const uint8_t plaintext[16], int bt_encrypt_be(const u8_t key[16], const u8_t plaintext[16],
uint8_t enc_data[16]) u8_t enc_data[16])
{ {
struct tc_aes_key_sched_struct s; struct tc_aes_key_sched_struct s;

View file

@ -16,7 +16,7 @@ struct bt_pub_key_cb {
* *
* @param key The local public key, or NULL in case of no key. * @param key The local public key, or NULL in case of no key.
*/ */
void (*func)(const uint8_t key[64]); void (*func)(const u8_t key[64]);
struct bt_pub_key_cb *_next; struct bt_pub_key_cb *_next;
}; };
@ -40,7 +40,7 @@ int bt_pub_key_gen(struct bt_pub_key_cb *cb);
* *
* @return Current key, or NULL if not available. * @return Current key, or NULL if not available.
*/ */
const uint8_t *bt_pub_key_get(void); const u8_t *bt_pub_key_get(void);
/* @typedef bt_dh_key_cb_t /* @typedef bt_dh_key_cb_t
* @brief Callback type for DH Key calculation. * @brief Callback type for DH Key calculation.
@ -49,7 +49,7 @@ const uint8_t *bt_pub_key_get(void);
* *
* @param key The DH Key, or NULL in case of failure. * @param key The DH Key, or NULL in case of failure.
*/ */
typedef void (*bt_dh_key_cb_t)(const uint8_t key[32]); typedef void (*bt_dh_key_cb_t)(const u8_t key[32]);
/* @brief Calculate a DH Key from a remote Public Key. /* @brief Calculate a DH Key from a remote Public Key.
* *
@ -60,4 +60,4 @@ typedef void (*bt_dh_key_cb_t)(const uint8_t key[32]);
* *
* @return Zero on success or negative error code otherwise * @return Zero on success or negative error code otherwise
*/ */
int bt_dh_key_gen(const uint8_t remote_pk[64], bt_dh_key_cb_t cb); int bt_dh_key_gen(const u8_t remote_pk[64], bt_dh_key_cb_t cb);

View file

@ -47,7 +47,7 @@ int bt_gatt_register(struct bt_gatt_attr *attrs, size_t count)
sys_slist_t list; sys_slist_t list;
struct bt_gatt_attr *last; struct bt_gatt_attr *last;
#endif /* CONFIG_BLUETOOTH_GATT_DYNAMIC_DB */ #endif /* CONFIG_BLUETOOTH_GATT_DYNAMIC_DB */
uint16_t handle; u16_t handle;
__ASSERT(attrs, "invalid parameters\n"); __ASSERT(attrs, "invalid parameters\n");
__ASSERT(count, "invalid parameters\n"); __ASSERT(count, "invalid parameters\n");
@ -102,10 +102,10 @@ populate:
} }
ssize_t bt_gatt_attr_read(struct bt_conn *conn, const struct bt_gatt_attr *attr, ssize_t bt_gatt_attr_read(struct bt_conn *conn, const struct bt_gatt_attr *attr,
void *buf, uint16_t buf_len, uint16_t offset, void *buf, u16_t buf_len, u16_t offset,
const void *value, uint16_t value_len) const void *value, u16_t value_len)
{ {
uint16_t len; u16_t len;
if (offset > value_len) { if (offset > value_len) {
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
@ -123,12 +123,12 @@ ssize_t bt_gatt_attr_read(struct bt_conn *conn, const struct bt_gatt_attr *attr,
ssize_t bt_gatt_attr_read_service(struct bt_conn *conn, ssize_t bt_gatt_attr_read_service(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const struct bt_gatt_attr *attr,
void *buf, uint16_t len, uint16_t offset) void *buf, u16_t len, u16_t offset)
{ {
struct bt_uuid *uuid = attr->user_data; struct bt_uuid *uuid = attr->user_data;
if (uuid->type == BT_UUID_TYPE_16) { if (uuid->type == BT_UUID_TYPE_16) {
uint16_t uuid16 = sys_cpu_to_le16(BT_UUID_16(uuid)->val); u16_t uuid16 = sys_cpu_to_le16(BT_UUID_16(uuid)->val);
return bt_gatt_attr_read(conn, attr, buf, len, offset, return bt_gatt_attr_read(conn, attr, buf, len, offset,
&uuid16, 2); &uuid16, 2);
@ -139,12 +139,12 @@ ssize_t bt_gatt_attr_read_service(struct bt_conn *conn,
} }
struct gatt_incl { struct gatt_incl {
uint16_t start_handle; u16_t start_handle;
uint16_t end_handle; u16_t end_handle;
uint16_t uuid16; u16_t uuid16;
} __packed; } __packed;
static uint8_t get_service_handles(const struct bt_gatt_attr *attr, static u8_t get_service_handles(const struct bt_gatt_attr *attr,
void *user_data) void *user_data)
{ {
struct gatt_incl *include = user_data; struct gatt_incl *include = user_data;
@ -162,12 +162,12 @@ static uint8_t get_service_handles(const struct bt_gatt_attr *attr,
ssize_t bt_gatt_attr_read_included(struct bt_conn *conn, ssize_t bt_gatt_attr_read_included(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const struct bt_gatt_attr *attr,
void *buf, uint16_t len, uint16_t offset) void *buf, u16_t len, u16_t offset)
{ {
struct bt_gatt_attr *incl = attr->user_data; struct bt_gatt_attr *incl = attr->user_data;
struct bt_uuid *uuid = incl->user_data; struct bt_uuid *uuid = incl->user_data;
struct gatt_incl pdu; struct gatt_incl pdu;
uint8_t value_len; u8_t value_len;
/* first attr points to the start handle */ /* first attr points to the start handle */
pdu.start_handle = sys_cpu_to_le16(incl->handle); pdu.start_handle = sys_cpu_to_le16(incl->handle);
@ -191,22 +191,22 @@ ssize_t bt_gatt_attr_read_included(struct bt_conn *conn,
} }
struct gatt_chrc { struct gatt_chrc {
uint8_t properties; u8_t properties;
uint16_t value_handle; u16_t value_handle;
union { union {
uint16_t uuid16; u16_t uuid16;
uint8_t uuid[16]; u8_t uuid[16];
}; };
} __packed; } __packed;
ssize_t bt_gatt_attr_read_chrc(struct bt_conn *conn, ssize_t bt_gatt_attr_read_chrc(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf, const struct bt_gatt_attr *attr, void *buf,
uint16_t len, uint16_t offset) u16_t len, u16_t offset)
{ {
struct bt_gatt_chrc *chrc = attr->user_data; struct bt_gatt_chrc *chrc = attr->user_data;
struct gatt_chrc pdu; struct gatt_chrc pdu;
const struct bt_gatt_attr *next; const struct bt_gatt_attr *next;
uint8_t value_len; u8_t value_len;
pdu.properties = chrc->properties; pdu.properties = chrc->properties;
/* BLUETOOTH SPECIFICATION Version 4.2 [Vol 3, Part G] page 534: /* BLUETOOTH SPECIFICATION Version 4.2 [Vol 3, Part G] page 534:
@ -236,7 +236,7 @@ ssize_t bt_gatt_attr_read_chrc(struct bt_conn *conn,
return bt_gatt_attr_read(conn, attr, buf, len, offset, &pdu, value_len); return bt_gatt_attr_read(conn, attr, buf, len, offset, &pdu, value_len);
} }
void bt_gatt_foreach_attr(uint16_t start_handle, uint16_t end_handle, void bt_gatt_foreach_attr(u16_t start_handle, u16_t end_handle,
bt_gatt_attr_func_t func, void *user_data) bt_gatt_attr_func_t func, void *user_data)
{ {
struct bt_gatt_attr *attr; struct bt_gatt_attr *attr;
@ -270,10 +270,10 @@ struct bt_gatt_attr *bt_gatt_attr_next(const struct bt_gatt_attr *attr)
ssize_t bt_gatt_attr_read_ccc(struct bt_conn *conn, ssize_t bt_gatt_attr_read_ccc(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf, const struct bt_gatt_attr *attr, void *buf,
uint16_t len, uint16_t offset) u16_t len, u16_t offset)
{ {
struct _bt_gatt_ccc *ccc = attr->user_data; struct _bt_gatt_ccc *ccc = attr->user_data;
uint16_t value; u16_t value;
size_t i; size_t i;
for (i = 0; i < ccc->cfg_len; i++) { for (i = 0; i < ccc->cfg_len; i++) {
@ -298,7 +298,7 @@ static void gatt_ccc_changed(const struct bt_gatt_attr *attr,
struct _bt_gatt_ccc *ccc) struct _bt_gatt_ccc *ccc)
{ {
int i; int i;
uint16_t value = 0x0000; u16_t value = 0x0000;
for (i = 0; i < ccc->cfg_len; i++) { for (i = 0; i < ccc->cfg_len; i++) {
if (ccc->cfg[i].value > value) { if (ccc->cfg[i].value > value) {
@ -316,17 +316,17 @@ static void gatt_ccc_changed(const struct bt_gatt_attr *attr,
ssize_t bt_gatt_attr_write_ccc(struct bt_conn *conn, ssize_t bt_gatt_attr_write_ccc(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const void *buf, const struct bt_gatt_attr *attr, const void *buf,
uint16_t len, uint16_t offset, uint8_t flags) u16_t len, u16_t offset, u8_t flags)
{ {
struct _bt_gatt_ccc *ccc = attr->user_data; struct _bt_gatt_ccc *ccc = attr->user_data;
uint16_t value; u16_t value;
size_t i; size_t i;
if (offset > sizeof(uint16_t)) { if (offset > sizeof(u16_t)) {
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
} }
if (offset + len > sizeof(uint16_t)) { if (offset + len > sizeof(u16_t)) {
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
} }
@ -378,10 +378,10 @@ ssize_t bt_gatt_attr_write_ccc(struct bt_conn *conn,
ssize_t bt_gatt_attr_read_cep(struct bt_conn *conn, ssize_t bt_gatt_attr_read_cep(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf, const struct bt_gatt_attr *attr, void *buf,
uint16_t len, uint16_t offset) u16_t len, u16_t offset)
{ {
struct bt_gatt_cep *value = attr->user_data; struct bt_gatt_cep *value = attr->user_data;
uint16_t props = sys_cpu_to_le16(value->properties); u16_t props = sys_cpu_to_le16(value->properties);
return bt_gatt_attr_read(conn, attr, buf, len, offset, &props, return bt_gatt_attr_read(conn, attr, buf, len, offset, &props,
sizeof(props)); sizeof(props));
@ -389,7 +389,7 @@ ssize_t bt_gatt_attr_read_cep(struct bt_conn *conn,
ssize_t bt_gatt_attr_read_cud(struct bt_conn *conn, ssize_t bt_gatt_attr_read_cud(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf, const struct bt_gatt_attr *attr, void *buf,
uint16_t len, uint16_t offset) u16_t len, u16_t offset)
{ {
char *value = attr->user_data; char *value = attr->user_data;
@ -399,7 +399,7 @@ ssize_t bt_gatt_attr_read_cud(struct bt_conn *conn,
ssize_t bt_gatt_attr_read_cpf(struct bt_conn *conn, ssize_t bt_gatt_attr_read_cpf(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf, const struct bt_gatt_attr *attr, void *buf,
uint16_t len, uint16_t offset) u16_t len, u16_t offset)
{ {
struct bt_gatt_cpf *value = attr->user_data; struct bt_gatt_cpf *value = attr->user_data;
@ -408,14 +408,14 @@ ssize_t bt_gatt_attr_read_cpf(struct bt_conn *conn,
} }
struct notify_data { struct notify_data {
uint16_t type; u16_t type;
const struct bt_gatt_attr *attr; const struct bt_gatt_attr *attr;
const void *data; const void *data;
uint16_t len; u16_t len;
struct bt_gatt_indicate_params *params; struct bt_gatt_indicate_params *params;
}; };
static int gatt_notify(struct bt_conn *conn, uint16_t handle, const void *data, static int gatt_notify(struct bt_conn *conn, u16_t handle, const void *data,
size_t len) size_t len)
{ {
struct net_buf *buf; struct net_buf *buf;
@ -440,8 +440,8 @@ static int gatt_notify(struct bt_conn *conn, uint16_t handle, const void *data,
return 0; return 0;
} }
static void gatt_indicate_rsp(struct bt_conn *conn, uint8_t err, static void gatt_indicate_rsp(struct bt_conn *conn, u8_t err,
const void *pdu, uint16_t length, void *user_data) const void *pdu, u16_t length, void *user_data)
{ {
struct bt_gatt_indicate_params *params = user_data; struct bt_gatt_indicate_params *params = user_data;
@ -498,7 +498,7 @@ static int gatt_indicate(struct bt_conn *conn,
return gatt_send(conn, buf, gatt_indicate_rsp, params, NULL); return gatt_send(conn, buf, gatt_indicate_rsp, params, NULL);
} }
static uint8_t notify_cb(const struct bt_gatt_attr *attr, void *user_data) static u8_t notify_cb(const struct bt_gatt_attr *attr, void *user_data)
{ {
struct notify_data *data = user_data; struct notify_data *data = user_data;
struct _bt_gatt_ccc *ccc; struct _bt_gatt_ccc *ccc;
@ -556,7 +556,7 @@ static uint8_t notify_cb(const struct bt_gatt_attr *attr, void *user_data)
} }
int bt_gatt_notify(struct bt_conn *conn, const struct bt_gatt_attr *attr, int bt_gatt_notify(struct bt_conn *conn, const struct bt_gatt_attr *attr,
const void *data, uint16_t len) const void *data, u16_t len)
{ {
struct notify_data nfy; struct notify_data nfy;
@ -596,12 +596,12 @@ int bt_gatt_indicate(struct bt_conn *conn,
return 0; return 0;
} }
uint16_t bt_gatt_get_mtu(struct bt_conn *conn) u16_t bt_gatt_get_mtu(struct bt_conn *conn)
{ {
return bt_att_get_mtu(conn); return bt_att_get_mtu(conn);
} }
static uint8_t connected_cb(const struct bt_gatt_attr *attr, void *user_data) static u8_t connected_cb(const struct bt_gatt_attr *attr, void *user_data)
{ {
struct bt_conn *conn = user_data; struct bt_conn *conn = user_data;
struct _bt_gatt_ccc *ccc; struct _bt_gatt_ccc *ccc;
@ -634,7 +634,7 @@ static uint8_t connected_cb(const struct bt_gatt_attr *attr, void *user_data)
return BT_GATT_ITER_CONTINUE; return BT_GATT_ITER_CONTINUE;
} }
static uint8_t disconnected_cb(const struct bt_gatt_attr *attr, void *user_data) static u8_t disconnected_cb(const struct bt_gatt_attr *attr, void *user_data)
{ {
struct bt_conn *conn = user_data; struct bt_conn *conn = user_data;
struct _bt_gatt_ccc *ccc; struct _bt_gatt_ccc *ccc;
@ -697,8 +697,8 @@ static uint8_t disconnected_cb(const struct bt_gatt_attr *attr, void *user_data)
} }
#if defined(CONFIG_BLUETOOTH_GATT_CLIENT) #if defined(CONFIG_BLUETOOTH_GATT_CLIENT)
void bt_gatt_notification(struct bt_conn *conn, uint16_t handle, void bt_gatt_notification(struct bt_conn *conn, u16_t handle,
const void *data, uint16_t length) const void *data, u16_t length)
{ {
struct bt_gatt_subscribe_params *params, *tmp; struct bt_gatt_subscribe_params *params, *tmp;
@ -761,8 +761,8 @@ static void remove_subscriptions(struct bt_conn *conn)
} }
} }
static void gatt_mtu_rsp(struct bt_conn *conn, uint8_t err, const void *pdu, static void gatt_mtu_rsp(struct bt_conn *conn, u8_t err, const void *pdu,
uint16_t length, void *user_data) u16_t length, void *user_data)
{ {
struct bt_gatt_exchange_params *params = user_data; struct bt_gatt_exchange_params *params = user_data;
@ -774,7 +774,7 @@ int bt_gatt_exchange_mtu(struct bt_conn *conn,
{ {
struct bt_att_exchange_mtu_req *req; struct bt_att_exchange_mtu_req *req;
struct net_buf *buf; struct net_buf *buf;
uint16_t mtu; u16_t mtu;
__ASSERT(conn, "invalid parameter\n"); __ASSERT(conn, "invalid parameter\n");
__ASSERT(params && params->func, "invalid parameters\n"); __ASSERT(params && params->func, "invalid parameters\n");
@ -798,7 +798,7 @@ int bt_gatt_exchange_mtu(struct bt_conn *conn,
return gatt_send(conn, buf, gatt_mtu_rsp, params, NULL); return gatt_send(conn, buf, gatt_mtu_rsp, params, NULL);
} }
static void gatt_discover_next(struct bt_conn *conn, uint16_t last_handle, static void gatt_discover_next(struct bt_conn *conn, u16_t last_handle,
struct bt_gatt_discover_params *params) struct bt_gatt_discover_params *params)
{ {
/* Skip if last_handle is not set */ /* Skip if last_handle is not set */
@ -826,14 +826,14 @@ done:
params->func(conn, NULL, params); params->func(conn, NULL, params);
} }
static void gatt_find_type_rsp(struct bt_conn *conn, uint8_t err, static void gatt_find_type_rsp(struct bt_conn *conn, u8_t err,
const void *pdu, uint16_t length, const void *pdu, u16_t length,
void *user_data) void *user_data)
{ {
const struct bt_att_find_type_rsp *rsp = pdu; const struct bt_att_find_type_rsp *rsp = pdu;
struct bt_gatt_discover_params *params = user_data; struct bt_gatt_discover_params *params = user_data;
uint8_t i; u8_t i;
uint16_t end_handle = 0, start_handle; u16_t end_handle = 0, start_handle;
BT_DBG("err 0x%02x", err); BT_DBG("err 0x%02x", err);
@ -923,8 +923,8 @@ static int gatt_find_type(struct bt_conn *conn,
return gatt_send(conn, buf, gatt_find_type_rsp, params, NULL); return gatt_send(conn, buf, gatt_find_type_rsp, params, NULL);
} }
static void read_included_uuid_cb(struct bt_conn *conn, uint8_t err, static void read_included_uuid_cb(struct bt_conn *conn, u8_t err,
const void *pdu, uint16_t length, const void *pdu, u16_t length,
void *user_data) void *user_data)
{ {
struct bt_gatt_discover_params *params = user_data; struct bt_gatt_discover_params *params = user_data;
@ -989,12 +989,12 @@ static int read_included_uuid(struct bt_conn *conn,
return gatt_send(conn, buf, read_included_uuid_cb, params, NULL); return gatt_send(conn, buf, read_included_uuid_cb, params, NULL);
} }
static uint16_t parse_include(struct bt_conn *conn, const void *pdu, static u16_t parse_include(struct bt_conn *conn, const void *pdu,
struct bt_gatt_discover_params *params, struct bt_gatt_discover_params *params,
uint16_t length) u16_t length)
{ {
const struct bt_att_read_type_rsp *rsp = pdu; const struct bt_att_read_type_rsp *rsp = pdu;
uint16_t handle = 0; u16_t handle = 0;
struct bt_gatt_include value; struct bt_gatt_include value;
union { union {
struct bt_uuid uuid; struct bt_uuid uuid;
@ -1081,12 +1081,12 @@ done:
return 0; return 0;
} }
static uint16_t parse_characteristic(struct bt_conn *conn, const void *pdu, static u16_t parse_characteristic(struct bt_conn *conn, const void *pdu,
struct bt_gatt_discover_params *params, struct bt_gatt_discover_params *params,
uint16_t length) u16_t length)
{ {
const struct bt_att_read_type_rsp *rsp = pdu; const struct bt_att_read_type_rsp *rsp = pdu;
uint16_t handle = 0; u16_t handle = 0;
union { union {
struct bt_uuid uuid; struct bt_uuid uuid;
struct bt_uuid_16 u16; struct bt_uuid_16 u16;
@ -1155,12 +1155,12 @@ done:
return 0; return 0;
} }
static void gatt_read_type_rsp(struct bt_conn *conn, uint8_t err, static void gatt_read_type_rsp(struct bt_conn *conn, u8_t err,
const void *pdu, uint16_t length, const void *pdu, u16_t length,
void *user_data) void *user_data)
{ {
struct bt_gatt_discover_params *params = user_data; struct bt_gatt_discover_params *params = user_data;
uint16_t handle; u16_t handle;
BT_DBG("err 0x%02x", err); BT_DBG("err 0x%02x", err);
@ -1209,14 +1209,14 @@ static int gatt_read_type(struct bt_conn *conn,
return gatt_send(conn, buf, gatt_read_type_rsp, params, NULL); return gatt_send(conn, buf, gatt_read_type_rsp, params, NULL);
} }
static void gatt_find_info_rsp(struct bt_conn *conn, uint8_t err, static void gatt_find_info_rsp(struct bt_conn *conn, u8_t err,
const void *pdu, uint16_t length, const void *pdu, u16_t length,
void *user_data) void *user_data)
{ {
const struct bt_att_find_info_rsp *rsp = pdu; const struct bt_att_find_info_rsp *rsp = pdu;
struct bt_gatt_discover_params *params = user_data; struct bt_gatt_discover_params *params = user_data;
uint16_t handle = 0; u16_t handle = 0;
uint8_t len; u8_t len;
union { union {
const struct bt_att_info_16 *i16; const struct bt_att_info_16 *i16;
const struct bt_att_info_128 *i128; const struct bt_att_info_128 *i128;
@ -1345,8 +1345,8 @@ int bt_gatt_discover(struct bt_conn *conn,
return -EINVAL; return -EINVAL;
} }
static void gatt_read_rsp(struct bt_conn *conn, uint8_t err, const void *pdu, static void gatt_read_rsp(struct bt_conn *conn, u8_t err, const void *pdu,
uint16_t length, void *user_data) u16_t length, void *user_data)
{ {
struct bt_gatt_read_params *params = user_data; struct bt_gatt_read_params *params = user_data;
@ -1401,8 +1401,8 @@ static int gatt_read_blob(struct bt_conn *conn,
return gatt_send(conn, buf, gatt_read_rsp, params, NULL); return gatt_send(conn, buf, gatt_read_rsp, params, NULL);
} }
static void gatt_read_multiple_rsp(struct bt_conn *conn, uint8_t err, static void gatt_read_multiple_rsp(struct bt_conn *conn, u8_t err,
const void *pdu, uint16_t length, const void *pdu, u16_t length,
void *user_data) void *user_data)
{ {
struct bt_gatt_read_params *params = user_data; struct bt_gatt_read_params *params = user_data;
@ -1424,10 +1424,10 @@ static int gatt_read_multiple(struct bt_conn *conn,
struct bt_gatt_read_params *params) struct bt_gatt_read_params *params)
{ {
struct net_buf *buf; struct net_buf *buf;
uint8_t i; u8_t i;
buf = bt_att_create_pdu(conn, BT_ATT_OP_READ_MULT_REQ, buf = bt_att_create_pdu(conn, BT_ATT_OP_READ_MULT_REQ,
params->handle_count * sizeof(uint16_t)); params->handle_count * sizeof(u16_t));
if (!buf) { if (!buf) {
return -ENOMEM; return -ENOMEM;
} }
@ -1473,8 +1473,8 @@ int bt_gatt_read(struct bt_conn *conn, struct bt_gatt_read_params *params)
return gatt_send(conn, buf, gatt_read_rsp, params, NULL); return gatt_send(conn, buf, gatt_read_rsp, params, NULL);
} }
static void gatt_write_rsp(struct bt_conn *conn, uint8_t err, const void *pdu, static void gatt_write_rsp(struct bt_conn *conn, u8_t err, const void *pdu,
uint16_t length, void *user_data) u16_t length, void *user_data)
{ {
struct bt_gatt_write_params *params = user_data; struct bt_gatt_write_params *params = user_data;
@ -1483,8 +1483,8 @@ static void gatt_write_rsp(struct bt_conn *conn, uint8_t err, const void *pdu,
params->func(conn, err, params); params->func(conn, err, params);
} }
int bt_gatt_write_without_response(struct bt_conn *conn, uint16_t handle, int bt_gatt_write_without_response(struct bt_conn *conn, u16_t handle,
const void *data, uint16_t length, bool sign) const void *data, u16_t length, bool sign)
{ {
struct net_buf *buf; struct net_buf *buf;
struct bt_att_write_cmd *cmd; struct bt_att_write_cmd *cmd;
@ -1543,8 +1543,8 @@ static int gatt_exec_write(struct bt_conn *conn,
return gatt_send(conn, buf, gatt_write_rsp, params, NULL); return gatt_send(conn, buf, gatt_write_rsp, params, NULL);
} }
static void gatt_prepare_write_rsp(struct bt_conn *conn, uint8_t err, static void gatt_prepare_write_rsp(struct bt_conn *conn, u8_t err,
const void *pdu, uint16_t length, const void *pdu, u16_t length,
void *user_data) void *user_data)
{ {
struct bt_gatt_write_params *params = user_data; struct bt_gatt_write_params *params = user_data;
@ -1573,7 +1573,7 @@ static int gatt_prepare_write(struct bt_conn *conn,
{ {
struct net_buf *buf; struct net_buf *buf;
struct bt_att_prepare_write_req *req; struct bt_att_prepare_write_req *req;
uint16_t len; u16_t len;
len = min(params->length, bt_att_get_mtu(conn) - sizeof(*req) - 1); len = min(params->length, bt_att_get_mtu(conn) - sizeof(*req) - 1);
@ -1644,8 +1644,8 @@ static void gatt_subscription_add(struct bt_conn *conn,
sys_slist_prepend(&subscriptions, &params->node); sys_slist_prepend(&subscriptions, &params->node);
} }
static void gatt_write_ccc_rsp(struct bt_conn *conn, uint8_t err, static void gatt_write_ccc_rsp(struct bt_conn *conn, u8_t err,
const void *pdu, uint16_t length, const void *pdu, u16_t length,
void *user_data) void *user_data)
{ {
struct bt_gatt_subscribe_params *params = user_data; struct bt_gatt_subscribe_params *params = user_data;
@ -1667,7 +1667,7 @@ static void gatt_write_ccc_rsp(struct bt_conn *conn, uint8_t err,
} }
} }
static int gatt_write_ccc(struct bt_conn *conn, uint16_t handle, uint16_t value, static int gatt_write_ccc(struct bt_conn *conn, u16_t handle, u16_t value,
bt_att_func_t func, bt_att_func_t func,
struct bt_gatt_subscribe_params *params) struct bt_gatt_subscribe_params *params)
{ {
@ -1675,7 +1675,7 @@ static int gatt_write_ccc(struct bt_conn *conn, uint16_t handle, uint16_t value,
struct bt_att_write_req *req; struct bt_att_write_req *req;
buf = bt_att_create_pdu(conn, BT_ATT_OP_WRITE_REQ, buf = bt_att_create_pdu(conn, BT_ATT_OP_WRITE_REQ,
sizeof(*req) + sizeof(uint16_t)); sizeof(*req) + sizeof(u16_t));
if (!buf) { if (!buf) {
return -ENOMEM; return -ENOMEM;
} }

View file

@ -12,11 +12,11 @@ void bt_gatt_connected(struct bt_conn *conn);
void bt_gatt_disconnected(struct bt_conn *conn); void bt_gatt_disconnected(struct bt_conn *conn);
#if defined(CONFIG_BLUETOOTH_GATT_CLIENT) #if defined(CONFIG_BLUETOOTH_GATT_CLIENT)
void bt_gatt_notification(struct bt_conn *conn, uint16_t handle, void bt_gatt_notification(struct bt_conn *conn, u16_t handle,
const void *data, uint16_t length); const void *data, u16_t length);
#else #else
static inline void bt_gatt_notification(struct bt_conn *conn, uint16_t handle, static inline void bt_gatt_notification(struct bt_conn *conn, u16_t handle,
const void *data, uint16_t length) const void *data, u16_t length)
{ {
} }
#endif /* CONFIG_BLUETOOTH_GATT_CLIENT */ #endif /* CONFIG_BLUETOOTH_GATT_CLIENT */

View file

@ -78,7 +78,7 @@ const struct bt_storage *bt_storage;
static bt_le_scan_cb_t *scan_dev_found_cb; static bt_le_scan_cb_t *scan_dev_found_cb;
static uint8_t pub_key[64]; static u8_t pub_key[64];
static struct bt_pub_key_cb *pub_key_cb; static struct bt_pub_key_cb *pub_key_cb;
static bt_dh_key_cb_t dh_key_cb; static bt_dh_key_cb_t dh_key_cb;
@ -91,13 +91,13 @@ static size_t discovery_results_count;
struct cmd_data { struct cmd_data {
/** BT_BUF_CMD */ /** BT_BUF_CMD */
uint8_t type; u8_t type;
/** HCI status of the command completion */ /** HCI status of the command completion */
uint8_t status; u8_t status;
/** The command OpCode that the buffer contains */ /** The command OpCode that the buffer contains */
uint16_t opcode; u16_t opcode;
/** Used by bt_hci_cmd_send_sync. */ /** Used by bt_hci_cmd_send_sync. */
struct k_sem *sync; struct k_sem *sync;
@ -105,10 +105,10 @@ struct cmd_data {
struct acl_data { struct acl_data {
/** BT_BUF_ACL_IN */ /** BT_BUF_ACL_IN */
uint8_t type; u8_t type;
/** ACL connection handle */ /** ACL connection handle */
uint16_t handle; u16_t handle;
}; };
#define cmd(buf) ((struct cmd_data *)net_buf_user_data(buf)) #define cmd(buf) ((struct cmd_data *)net_buf_user_data(buf))
@ -128,7 +128,7 @@ NET_BUF_POOL_DEFINE(hci_rx_pool, CONFIG_BLUETOOTH_RX_BUF_COUNT,
const char *bt_addr_str(const bt_addr_t *addr) const char *bt_addr_str(const bt_addr_t *addr)
{ {
static char bufs[2][18]; static char bufs[2][18];
static uint8_t cur; static u8_t cur;
char *str; char *str;
str = bufs[cur++]; str = bufs[cur++];
@ -141,7 +141,7 @@ const char *bt_addr_str(const bt_addr_t *addr)
const char *bt_addr_le_str(const bt_addr_le_t *addr) const char *bt_addr_le_str(const bt_addr_le_t *addr)
{ {
static char bufs[2][27]; static char bufs[2][27];
static uint8_t cur; static u8_t cur;
char *str; char *str;
str = bufs[cur++]; str = bufs[cur++];
@ -152,7 +152,7 @@ const char *bt_addr_le_str(const bt_addr_le_t *addr)
} }
#endif /* CONFIG_BLUETOOTH_DEBUG */ #endif /* CONFIG_BLUETOOTH_DEBUG */
struct net_buf *bt_hci_cmd_create(uint16_t opcode, uint8_t param_len) struct net_buf *bt_hci_cmd_create(u16_t opcode, u8_t param_len)
{ {
struct bt_hci_cmd_hdr *hdr; struct bt_hci_cmd_hdr *hdr;
struct net_buf *buf; struct net_buf *buf;
@ -177,7 +177,7 @@ struct net_buf *bt_hci_cmd_create(uint16_t opcode, uint8_t param_len)
return buf; return buf;
} }
int bt_hci_cmd_send(uint16_t opcode, struct net_buf *buf) int bt_hci_cmd_send(u16_t opcode, struct net_buf *buf)
{ {
if (!buf) { if (!buf) {
buf = bt_hci_cmd_create(opcode, 0); buf = bt_hci_cmd_create(opcode, 0);
@ -208,7 +208,7 @@ int bt_hci_cmd_send(uint16_t opcode, struct net_buf *buf)
return 0; return 0;
} }
int bt_hci_cmd_send_sync(uint16_t opcode, struct net_buf *buf, int bt_hci_cmd_send_sync(u16_t opcode, struct net_buf *buf,
struct net_buf **rsp) struct net_buf **rsp)
{ {
struct k_sem sync_sem; struct k_sem sync_sem;
@ -435,9 +435,9 @@ static int le_set_private_addr(void)
static void hci_acl(struct net_buf *buf) static void hci_acl(struct net_buf *buf)
{ {
struct bt_hci_acl_hdr *hdr = (void *)buf->data; struct bt_hci_acl_hdr *hdr = (void *)buf->data;
uint16_t handle, len = sys_le16_to_cpu(hdr->len); u16_t handle, len = sys_le16_to_cpu(hdr->len);
struct bt_conn *conn; struct bt_conn *conn;
uint8_t flags; u8_t flags;
BT_DBG("buf %p", buf); BT_DBG("buf %p", buf);
@ -470,12 +470,12 @@ static void hci_acl(struct net_buf *buf)
static void hci_num_completed_packets(struct net_buf *buf) static void hci_num_completed_packets(struct net_buf *buf)
{ {
struct bt_hci_evt_num_completed_packets *evt = (void *)buf->data; struct bt_hci_evt_num_completed_packets *evt = (void *)buf->data;
uint16_t i, num_handles = sys_le16_to_cpu(evt->num_handles); u16_t i, num_handles = sys_le16_to_cpu(evt->num_handles);
BT_DBG("num_handles %u", num_handles); BT_DBG("num_handles %u", num_handles);
for (i = 0; i < num_handles; i++) { for (i = 0; i < num_handles; i++) {
uint16_t handle, count; u16_t handle, count;
struct bt_conn *conn; struct bt_conn *conn;
unsigned int key; unsigned int key;
@ -545,7 +545,7 @@ static int hci_le_create_conn(const struct bt_conn *conn)
static void hci_disconn_complete(struct net_buf *buf) static void hci_disconn_complete(struct net_buf *buf)
{ {
struct bt_hci_evt_disconn_complete *evt = (void *)buf->data; struct bt_hci_evt_disconn_complete *evt = (void *)buf->data;
uint16_t handle = sys_le16_to_cpu(evt->handle); u16_t handle = sys_le16_to_cpu(evt->handle);
struct bt_conn *conn; struct bt_conn *conn;
BT_DBG("status %u handle %u reason %u", evt->status, handle, BT_DBG("status %u handle %u reason %u", evt->status, handle,
@ -643,7 +643,7 @@ static void update_conn_param(struct bt_conn *conn)
static void le_conn_complete(struct net_buf *buf) static void le_conn_complete(struct net_buf *buf)
{ {
struct bt_hci_evt_le_conn_complete *evt = (void *)buf->data; struct bt_hci_evt_le_conn_complete *evt = (void *)buf->data;
uint16_t handle = sys_le16_to_cpu(evt->handle); u16_t handle = sys_le16_to_cpu(evt->handle);
const bt_addr_le_t *id_addr; const bt_addr_le_t *id_addr;
struct bt_conn *conn; struct bt_conn *conn;
int err; int err;
@ -775,7 +775,7 @@ done:
static void le_remote_feat_complete(struct net_buf *buf) static void le_remote_feat_complete(struct net_buf *buf)
{ {
struct bt_hci_ev_le_remote_feat_complete *evt = (void *)buf->data; struct bt_hci_ev_le_remote_feat_complete *evt = (void *)buf->data;
uint16_t handle = sys_le16_to_cpu(evt->handle); u16_t handle = sys_le16_to_cpu(evt->handle);
struct bt_conn *conn; struct bt_conn *conn;
conn = bt_conn_lookup_handle(handle); conn = bt_conn_lookup_handle(handle);
@ -816,7 +816,7 @@ bool bt_le_conn_params_valid(const struct bt_le_conn_param *param)
return true; return true;
} }
static int le_conn_param_neg_reply(uint16_t handle, uint8_t reason) static int le_conn_param_neg_reply(u16_t handle, u8_t reason)
{ {
struct bt_hci_cp_le_conn_param_req_neg_reply *cp; struct bt_hci_cp_le_conn_param_req_neg_reply *cp;
struct net_buf *buf; struct net_buf *buf;
@ -834,7 +834,7 @@ static int le_conn_param_neg_reply(uint16_t handle, uint8_t reason)
return bt_hci_cmd_send(BT_HCI_OP_LE_CONN_PARAM_REQ_NEG_REPLY, buf); return bt_hci_cmd_send(BT_HCI_OP_LE_CONN_PARAM_REQ_NEG_REPLY, buf);
} }
static int le_conn_param_req_reply(uint16_t handle, static int le_conn_param_req_reply(u16_t handle,
const struct bt_le_conn_param *param) const struct bt_le_conn_param *param)
{ {
struct bt_hci_cp_le_conn_param_req_reply *cp; struct bt_hci_cp_le_conn_param_req_reply *cp;
@ -862,7 +862,7 @@ static int le_conn_param_req(struct net_buf *buf)
struct bt_hci_evt_le_conn_param_req *evt = (void *)buf->data; struct bt_hci_evt_le_conn_param_req *evt = (void *)buf->data;
struct bt_le_conn_param param; struct bt_le_conn_param param;
struct bt_conn *conn; struct bt_conn *conn;
uint16_t handle; u16_t handle;
int err; int err;
handle = sys_le16_to_cpu(evt->handle); handle = sys_le16_to_cpu(evt->handle);
@ -893,7 +893,7 @@ static void le_conn_update_complete(struct net_buf *buf)
{ {
struct bt_hci_evt_le_conn_update_complete *evt = (void *)buf->data; struct bt_hci_evt_le_conn_update_complete *evt = (void *)buf->data;
struct bt_conn *conn; struct bt_conn *conn;
uint16_t handle; u16_t handle;
handle = sys_le16_to_cpu(evt->handle); handle = sys_le16_to_cpu(evt->handle);
@ -916,7 +916,7 @@ static void le_conn_update_complete(struct net_buf *buf)
} }
static void check_pending_conn(const bt_addr_le_t *id_addr, static void check_pending_conn(const bt_addr_le_t *id_addr,
const bt_addr_le_t *addr, uint8_t evtype) const bt_addr_le_t *addr, u8_t evtype)
{ {
struct bt_conn *conn; struct bt_conn *conn;
@ -986,7 +986,7 @@ static void reset_pairing(struct bt_conn *conn)
conn->required_sec_level = conn->sec_level; conn->required_sec_level = conn->sec_level;
} }
static int reject_conn(const bt_addr_t *bdaddr, uint8_t reason) static int reject_conn(const bt_addr_t *bdaddr, u8_t reason)
{ {
struct bt_hci_cp_reject_conn_req *cp; struct bt_hci_cp_reject_conn_req *cp;
struct net_buf *buf; struct net_buf *buf;
@ -1141,7 +1141,7 @@ static void synchronous_conn_complete(struct net_buf *buf)
{ {
struct bt_hci_evt_sync_conn_complete *evt = (void *)buf->data; struct bt_hci_evt_sync_conn_complete *evt = (void *)buf->data;
struct bt_conn *sco_conn; struct bt_conn *sco_conn;
uint16_t handle = sys_le16_to_cpu(evt->handle); u16_t handle = sys_le16_to_cpu(evt->handle);
BT_DBG("status 0x%02x, handle %u, type 0x%02x", evt->status, handle, BT_DBG("status 0x%02x, handle %u, type 0x%02x", evt->status, handle,
evt->link_type); evt->link_type);
@ -1169,7 +1169,7 @@ static void conn_complete(struct net_buf *buf)
struct bt_hci_evt_conn_complete *evt = (void *)buf->data; struct bt_hci_evt_conn_complete *evt = (void *)buf->data;
struct bt_conn *conn; struct bt_conn *conn;
struct bt_hci_cp_read_remote_features *cp; struct bt_hci_cp_read_remote_features *cp;
uint16_t handle = sys_le16_to_cpu(evt->handle); u16_t handle = sys_le16_to_cpu(evt->handle);
BT_DBG("status 0x%02x, handle %u, type 0x%02x", evt->status, handle, BT_DBG("status 0x%02x, handle %u, type 0x%02x", evt->status, handle,
evt->link_type); evt->link_type);
@ -1313,7 +1313,7 @@ static void link_key_neg_reply(const bt_addr_t *bdaddr)
bt_hci_cmd_send_sync(BT_HCI_OP_LINK_KEY_NEG_REPLY, buf, NULL); bt_hci_cmd_send_sync(BT_HCI_OP_LINK_KEY_NEG_REPLY, buf, NULL);
} }
static void link_key_reply(const bt_addr_t *bdaddr, const uint8_t *lk) static void link_key_reply(const bt_addr_t *bdaddr, const u8_t *lk)
{ {
struct bt_hci_cp_link_key_reply *cp; struct bt_hci_cp_link_key_reply *cp;
struct net_buf *buf; struct net_buf *buf;
@ -1372,7 +1372,7 @@ static void link_key_req(struct net_buf *buf)
bt_conn_unref(conn); bt_conn_unref(conn);
} }
static void io_capa_neg_reply(const bt_addr_t *bdaddr, const uint8_t reason) static void io_capa_neg_reply(const bt_addr_t *bdaddr, const u8_t reason)
{ {
struct bt_hci_cp_io_capability_neg_reply *cp; struct bt_hci_cp_io_capability_neg_reply *cp;
struct net_buf *resp_buf; struct net_buf *resp_buf;
@ -1430,7 +1430,7 @@ static void io_capa_req(struct net_buf *buf)
struct net_buf *resp_buf; struct net_buf *resp_buf;
struct bt_conn *conn; struct bt_conn *conn;
struct bt_hci_cp_io_capability_reply *cp; struct bt_hci_cp_io_capability_reply *cp;
uint8_t auth; u8_t auth;
BT_DBG(""); BT_DBG("");
@ -1541,12 +1541,12 @@ static void user_passkey_req(struct net_buf *buf)
} }
struct discovery_priv { struct discovery_priv {
uint16_t clock_offset; u16_t clock_offset;
uint8_t pscan_rep_mode; u8_t pscan_rep_mode;
uint8_t resolving; u8_t resolving;
} __packed; } __packed;
static int request_name(const bt_addr_t *addr, uint8_t pscan, uint16_t offset) static int request_name(const bt_addr_t *addr, u8_t pscan, u16_t offset)
{ {
struct bt_hci_cp_remote_name_request *cp; struct bt_hci_cp_remote_name_request *cp;
struct net_buf *buf; struct net_buf *buf;
@ -1569,7 +1569,7 @@ static int request_name(const bt_addr_t *addr, uint8_t pscan, uint16_t offset)
#define EIR_SHORT_NAME 0x08 #define EIR_SHORT_NAME 0x08
#define EIR_COMPLETE_NAME 0x09 #define EIR_COMPLETE_NAME 0x09
static bool eir_has_name(const uint8_t *eir) static bool eir_has_name(const u8_t *eir)
{ {
int len = 240; int len = 240;
@ -1656,7 +1656,7 @@ static void inquiry_complete(struct net_buf *buf)
} }
static struct bt_br_discovery_result *get_result_slot(const bt_addr_t *addr, static struct bt_br_discovery_result *get_result_slot(const bt_addr_t *addr,
int8_t rssi) s8_t rssi)
{ {
struct bt_br_discovery_result *result = NULL; struct bt_br_discovery_result *result = NULL;
size_t i; size_t i;
@ -1707,7 +1707,7 @@ static struct bt_br_discovery_result *get_result_slot(const bt_addr_t *addr,
static void inquiry_result_with_rssi(struct net_buf *buf) static void inquiry_result_with_rssi(struct net_buf *buf)
{ {
struct bt_hci_evt_inquiry_result_with_rssi *evt; struct bt_hci_evt_inquiry_result_with_rssi *evt;
uint8_t num_reports = net_buf_pull_u8(buf); u8_t num_reports = net_buf_pull_u8(buf);
if (!atomic_test_bit(bt_dev.flags, BT_DEV_INQUIRY)) { if (!atomic_test_bit(bt_dev.flags, BT_DEV_INQUIRY)) {
return; return;
@ -1777,7 +1777,7 @@ static void remote_name_request_complete(struct net_buf *buf)
struct bt_br_discovery_result *result; struct bt_br_discovery_result *result;
struct discovery_priv *priv; struct discovery_priv *priv;
int eir_len = 240; int eir_len = 240;
uint8_t *eir; u8_t *eir;
int i; int i;
result = get_result_slot(&evt->bdaddr, 0xff); result = get_result_slot(&evt->bdaddr, 0xff);
@ -1854,7 +1854,7 @@ check_names:
discovery_results_count = 0; discovery_results_count = 0;
} }
static void link_encr(const uint16_t handle) static void link_encr(const u16_t handle)
{ {
struct bt_hci_cp_set_conn_encrypt *encr; struct bt_hci_cp_set_conn_encrypt *encr;
struct net_buf *buf; struct net_buf *buf;
@ -1878,7 +1878,7 @@ static void auth_complete(struct net_buf *buf)
{ {
struct bt_hci_evt_auth_complete *evt = (void *)buf->data; struct bt_hci_evt_auth_complete *evt = (void *)buf->data;
struct bt_conn *conn; struct bt_conn *conn;
uint16_t handle = sys_le16_to_cpu(evt->handle); u16_t handle = sys_le16_to_cpu(evt->handle);
BT_DBG("status %u, handle %u", evt->status, handle); BT_DBG("status %u, handle %u", evt->status, handle);
@ -1907,7 +1907,7 @@ static void auth_complete(struct net_buf *buf)
static void read_remote_features_complete(struct net_buf *buf) static void read_remote_features_complete(struct net_buf *buf)
{ {
struct bt_hci_evt_remote_features *evt = (void *)buf->data; struct bt_hci_evt_remote_features *evt = (void *)buf->data;
uint16_t handle = sys_le16_to_cpu(evt->handle); u16_t handle = sys_le16_to_cpu(evt->handle);
struct bt_hci_cp_read_remote_ext_features *cp; struct bt_hci_cp_read_remote_ext_features *cp;
struct bt_conn *conn; struct bt_conn *conn;
@ -1949,7 +1949,7 @@ done:
static void read_remote_ext_features_complete(struct net_buf *buf) static void read_remote_ext_features_complete(struct net_buf *buf)
{ {
struct bt_hci_evt_remote_ext_features *evt = (void *)buf->data; struct bt_hci_evt_remote_ext_features *evt = (void *)buf->data;
uint16_t handle = sys_le16_to_cpu(evt->handle); u16_t handle = sys_le16_to_cpu(evt->handle);
struct bt_conn *conn; struct bt_conn *conn;
BT_DBG("status %u handle %u", evt->status, handle); BT_DBG("status %u handle %u", evt->status, handle);
@ -2026,7 +2026,7 @@ static void update_sec_level(struct bt_conn *conn)
static void hci_encrypt_change(struct net_buf *buf) static void hci_encrypt_change(struct net_buf *buf)
{ {
struct bt_hci_evt_encrypt_change *evt = (void *)buf->data; struct bt_hci_evt_encrypt_change *evt = (void *)buf->data;
uint16_t handle = sys_le16_to_cpu(evt->handle); u16_t handle = sys_le16_to_cpu(evt->handle);
struct bt_conn *conn; struct bt_conn *conn;
BT_DBG("status %u handle %u encrypt 0x%02x", evt->status, handle, BT_DBG("status %u handle %u encrypt 0x%02x", evt->status, handle,
@ -2100,7 +2100,7 @@ static void hci_encrypt_key_refresh_complete(struct net_buf *buf)
{ {
struct bt_hci_evt_encrypt_key_refresh_complete *evt = (void *)buf->data; struct bt_hci_evt_encrypt_key_refresh_complete *evt = (void *)buf->data;
struct bt_conn *conn; struct bt_conn *conn;
uint16_t handle; u16_t handle;
handle = sys_le16_to_cpu(evt->handle); handle = sys_le16_to_cpu(evt->handle);
@ -2147,8 +2147,8 @@ static void le_ltk_request(struct net_buf *buf)
struct bt_hci_evt_le_ltk_request *evt = (void *)buf->data; struct bt_hci_evt_le_ltk_request *evt = (void *)buf->data;
struct bt_hci_cp_le_ltk_req_neg_reply *cp; struct bt_hci_cp_le_ltk_req_neg_reply *cp;
struct bt_conn *conn; struct bt_conn *conn;
uint16_t handle; u16_t handle;
uint8_t tk[16]; u8_t tk[16];
handle = sys_le16_to_cpu(evt->handle); handle = sys_le16_to_cpu(evt->handle);
@ -2297,7 +2297,7 @@ static void le_dhkey_complete(struct net_buf *buf)
static void hci_reset_complete(struct net_buf *buf) static void hci_reset_complete(struct net_buf *buf)
{ {
uint8_t status = buf->data[0]; u8_t status = buf->data[0];
BT_DBG("status %u", status); BT_DBG("status %u", status);
@ -2317,7 +2317,7 @@ static void hci_reset_complete(struct net_buf *buf)
atomic_set(bt_dev.flags, BIT(BT_DEV_ENABLE)); atomic_set(bt_dev.flags, BIT(BT_DEV_ENABLE));
} }
static void hci_cmd_done(uint16_t opcode, uint8_t status, struct net_buf *buf) static void hci_cmd_done(u16_t opcode, u8_t status, struct net_buf *buf)
{ {
BT_DBG("opcode 0x%04x status 0x%02x buf %p", opcode, status, buf); BT_DBG("opcode 0x%04x status 0x%02x buf %p", opcode, status, buf);
@ -2340,8 +2340,8 @@ static void hci_cmd_done(uint16_t opcode, uint8_t status, struct net_buf *buf)
static void hci_cmd_complete(struct net_buf *buf) static void hci_cmd_complete(struct net_buf *buf)
{ {
struct bt_hci_evt_cmd_complete *evt = (void *)buf->data; struct bt_hci_evt_cmd_complete *evt = (void *)buf->data;
uint16_t opcode = sys_le16_to_cpu(evt->opcode); u16_t opcode = sys_le16_to_cpu(evt->opcode);
uint8_t status, ncmd = evt->ncmd; u8_t status, ncmd = evt->ncmd;
BT_DBG("opcode 0x%04x", opcode); BT_DBG("opcode 0x%04x", opcode);
@ -2363,8 +2363,8 @@ static void hci_cmd_complete(struct net_buf *buf)
static void hci_cmd_status(struct net_buf *buf) static void hci_cmd_status(struct net_buf *buf)
{ {
struct bt_hci_evt_cmd_status *evt = (void *)buf->data; struct bt_hci_evt_cmd_status *evt = (void *)buf->data;
uint16_t opcode = sys_le16_to_cpu(evt->opcode); u16_t opcode = sys_le16_to_cpu(evt->opcode);
uint8_t ncmd = evt->ncmd; u8_t ncmd = evt->ncmd;
BT_DBG("opcode 0x%04x", opcode); BT_DBG("opcode 0x%04x", opcode);
@ -2378,8 +2378,8 @@ static void hci_cmd_status(struct net_buf *buf)
} }
} }
static int start_le_scan(uint8_t scan_type, uint16_t interval, uint16_t window, static int start_le_scan(u8_t scan_type, u16_t interval, u16_t window,
uint8_t filter_dup) u8_t filter_dup)
{ {
struct net_buf *buf, *rsp; struct net_buf *buf, *rsp;
struct bt_hci_cp_le_set_scan_param *set_param; struct bt_hci_cp_le_set_scan_param *set_param;
@ -2474,7 +2474,7 @@ int bt_le_scan_update(bool fast_scan)
} }
if (IS_ENABLED(CONFIG_BLUETOOTH_CENTRAL)) { if (IS_ENABLED(CONFIG_BLUETOOTH_CENTRAL)) {
uint16_t interval, window; u16_t interval, window;
struct bt_conn *conn; struct bt_conn *conn;
conn = bt_conn_lookup_state_le(NULL, BT_CONN_CONNECT_SCAN); conn = bt_conn_lookup_state_le(NULL, BT_CONN_CONNECT_SCAN);
@ -2501,14 +2501,14 @@ int bt_le_scan_update(bool fast_scan)
static void le_adv_report(struct net_buf *buf) static void le_adv_report(struct net_buf *buf)
{ {
uint8_t num_reports = net_buf_pull_u8(buf); u8_t num_reports = net_buf_pull_u8(buf);
struct bt_hci_ev_le_advertising_info *info; struct bt_hci_ev_le_advertising_info *info;
BT_DBG("Adv number of reports %u", num_reports); BT_DBG("Adv number of reports %u", num_reports);
while (num_reports--) { while (num_reports--) {
const bt_addr_le_t *addr; const bt_addr_le_t *addr;
int8_t rssi; s8_t rssi;
info = (void *)buf->data; info = (void *)buf->data;
net_buf_pull(buf, sizeof(*info)); net_buf_pull(buf, sizeof(*info));
@ -2840,7 +2840,7 @@ static void read_le_features_complete(struct net_buf *buf)
static void read_buffer_size_complete(struct net_buf *buf) static void read_buffer_size_complete(struct net_buf *buf)
{ {
struct bt_hci_rp_read_buffer_size *rp = (void *)buf->data; struct bt_hci_rp_read_buffer_size *rp = (void *)buf->data;
uint16_t pkts; u16_t pkts;
BT_DBG("status %u", rp->status); BT_DBG("status %u", rp->status);
@ -2855,7 +2855,7 @@ static void read_buffer_size_complete(struct net_buf *buf)
static void read_buffer_size_complete(struct net_buf *buf) static void read_buffer_size_complete(struct net_buf *buf)
{ {
struct bt_hci_rp_read_buffer_size *rp = (void *)buf->data; struct bt_hci_rp_read_buffer_size *rp = (void *)buf->data;
uint16_t pkts; u16_t pkts;
BT_DBG("status %u", rp->status); BT_DBG("status %u", rp->status);
@ -2879,7 +2879,7 @@ static void read_buffer_size_complete(struct net_buf *buf)
static void le_read_buffer_size_complete(struct net_buf *buf) static void le_read_buffer_size_complete(struct net_buf *buf)
{ {
struct bt_hci_rp_le_read_buffer_size *rp = (void *)buf->data; struct bt_hci_rp_le_read_buffer_size *rp = (void *)buf->data;
uint8_t le_max_num; u8_t le_max_num;
BT_DBG("status %u", rp->status); BT_DBG("status %u", rp->status);
@ -2999,7 +2999,7 @@ static int le_init(void)
struct bt_hci_cp_le_set_event_mask *cp_mask; struct bt_hci_cp_le_set_event_mask *cp_mask;
struct net_buf *buf; struct net_buf *buf;
struct net_buf *rsp; struct net_buf *rsp;
uint64_t mask = 0; u64_t mask = 0;
int err; int err;
/* For now we only support LE capable controllers */ /* For now we only support LE capable controllers */
@ -3248,7 +3248,7 @@ static int br_init(void)
} }
/* Set page timeout*/ /* Set page timeout*/
buf = bt_hci_cmd_create(BT_HCI_OP_WRITE_PAGE_TIMEOUT, sizeof(uint16_t)); buf = bt_hci_cmd_create(BT_HCI_OP_WRITE_PAGE_TIMEOUT, sizeof(u16_t));
if (!buf) { if (!buf) {
return -ENOBUFS; return -ENOBUFS;
} }
@ -3311,7 +3311,7 @@ static int set_event_mask(void)
{ {
struct bt_hci_cp_set_event_mask *ev; struct bt_hci_cp_set_event_mask *ev;
struct net_buf *buf; struct net_buf *buf;
uint64_t mask = 0; u64_t mask = 0;
buf = bt_hci_cmd_create(BT_HCI_OP_SET_EVENT_MASK, sizeof(*ev)); buf = bt_hci_cmd_create(BT_HCI_OP_SET_EVENT_MASK, sizeof(*ev));
if (!buf) { if (!buf) {
@ -3471,7 +3471,7 @@ set_addr:
} }
#if defined(CONFIG_BLUETOOTH_DEBUG) #if defined(CONFIG_BLUETOOTH_DEBUG)
static const char *ver_str(uint8_t ver) static const char *ver_str(u8_t ver)
{ {
const char * const str[] = { const char * const str[] = {
"1.0b", "1.1", "1.2", "2.0", "2.1", "3.0", "4.0", "4.1", "4.2", "1.0b", "1.1", "1.2", "2.0", "2.1", "3.0", "4.0", "4.1", "4.2",
@ -3846,7 +3846,7 @@ static bool valid_adv_param(const struct bt_le_adv_param *param)
return true; return true;
} }
static int set_ad(uint16_t hci_op, const struct bt_data *ad, size_t ad_len) static int set_ad(u16_t hci_op, const struct bt_data *ad, size_t ad_len)
{ {
struct bt_hci_cp_le_set_adv_data *set_data; struct bt_hci_cp_le_set_adv_data *set_data;
struct net_buf *buf; struct net_buf *buf;
@ -4101,7 +4101,7 @@ int bt_le_scan_stop(void)
return bt_le_scan_update(false); return bt_le_scan_update(false);
} }
struct net_buf *bt_buf_get_rx(int32_t timeout) struct net_buf *bt_buf_get_rx(s32_t timeout)
{ {
struct net_buf *buf; struct net_buf *buf;
@ -4113,7 +4113,7 @@ struct net_buf *bt_buf_get_rx(int32_t timeout)
return buf; return buf;
} }
struct net_buf *bt_buf_get_cmd_complete(int32_t timeout) struct net_buf *bt_buf_get_cmd_complete(s32_t timeout)
{ {
struct net_buf *buf; struct net_buf *buf;
unsigned int key; unsigned int key;
@ -4144,7 +4144,7 @@ struct net_buf *bt_buf_get_cmd_complete(int32_t timeout)
#if defined(CONFIG_BLUETOOTH_BREDR) #if defined(CONFIG_BLUETOOTH_BREDR)
static int br_start_inquiry(const struct bt_br_discovery_param *param) static int br_start_inquiry(const struct bt_br_discovery_param *param)
{ {
const uint8_t iac[3] = { 0x33, 0x8b, 0x9e }; const u8_t iac[3] = { 0x33, 0x8b, 0x9e };
struct bt_hci_op_inquiry *cp; struct bt_hci_op_inquiry *cp;
struct net_buf *buf; struct net_buf *buf;
@ -4262,7 +4262,7 @@ int bt_br_discovery_stop(void)
return 0; return 0;
} }
static int write_scan_enable(uint8_t scan) static int write_scan_enable(u8_t scan)
{ {
struct net_buf *buf; struct net_buf *buf;
int err; int err;
@ -4397,7 +4397,7 @@ int bt_storage_clear(const bt_addr_le_t *addr)
return 0; return 0;
} }
uint16_t bt_hci_get_cmd_opcode(struct net_buf *buf) u16_t bt_hci_get_cmd_opcode(struct net_buf *buf)
{ {
return cmd(buf)->opcode; return cmd(buf)->opcode;
} }
@ -4445,7 +4445,7 @@ int bt_pub_key_gen(struct bt_pub_key_cb *new_cb)
return 0; return 0;
} }
const uint8_t *bt_pub_key_get(void) const u8_t *bt_pub_key_get(void)
{ {
if (atomic_test_bit(bt_dev.flags, BT_DEV_HAS_PUB_KEY)) { if (atomic_test_bit(bt_dev.flags, BT_DEV_HAS_PUB_KEY)) {
return pub_key; return pub_key;
@ -4454,7 +4454,7 @@ const uint8_t *bt_pub_key_get(void)
return NULL; return NULL;
} }
int bt_dh_key_gen(const uint8_t remote_pk[64], bt_dh_key_cb_t cb) int bt_dh_key_gen(const u8_t remote_pk[64], bt_dh_key_cb_t cb)
{ {
struct bt_hci_cp_le_generate_dhkey *cp; struct bt_hci_cp_le_generate_dhkey *cp;
struct net_buf *buf; struct net_buf *buf;

View file

@ -54,25 +54,25 @@ enum {
struct bt_dev_le { struct bt_dev_le {
/* LE features */ /* LE features */
uint8_t features[1][8]; u8_t features[1][8];
/* LE states */ /* LE states */
uint64_t states; u64_t states;
#if defined(CONFIG_BLUETOOTH_CONN) #if defined(CONFIG_BLUETOOTH_CONN)
/* Controller buffer information */ /* Controller buffer information */
uint16_t mtu; u16_t mtu;
struct k_sem pkts; struct k_sem pkts;
#endif /* CONFIG_BLUETOOTH_CONN */ #endif /* CONFIG_BLUETOOTH_CONN */
}; };
#if defined(CONFIG_BLUETOOTH_BREDR) #if defined(CONFIG_BLUETOOTH_BREDR)
struct bt_dev_esco { struct bt_dev_esco {
uint16_t pkt_type; u16_t pkt_type;
}; };
struct bt_dev_br { struct bt_dev_br {
/* Max controller's acceptable ACL packet length */ /* Max controller's acceptable ACL packet length */
uint16_t mtu; u16_t mtu;
struct k_sem pkts; struct k_sem pkts;
}; };
#endif #endif
@ -86,17 +86,17 @@ struct bt_dev {
bt_addr_le_t random_addr; bt_addr_le_t random_addr;
/* Controller version & manufacturer information */ /* Controller version & manufacturer information */
uint8_t hci_version; u8_t hci_version;
uint8_t lmp_version; u8_t lmp_version;
uint16_t hci_revision; u16_t hci_revision;
uint16_t lmp_subversion; u16_t lmp_subversion;
uint16_t manufacturer; u16_t manufacturer;
/* LMP features (pages 0, 1, 2) */ /* LMP features (pages 0, 1, 2) */
uint8_t features[LMP_FEAT_PAGES_COUNT][8]; u8_t features[LMP_FEAT_PAGES_COUNT][8];
/* Supported commands */ /* Supported commands */
uint8_t supported_commands[64]; u8_t supported_commands[64];
struct k_work init; struct k_work init;
@ -136,7 +136,7 @@ struct bt_dev {
#if defined(CONFIG_BLUETOOTH_PRIVACY) #if defined(CONFIG_BLUETOOTH_PRIVACY)
/* Local Identity Resolving Key */ /* Local Identity Resolving Key */
uint8_t irk[16]; u8_t irk[16];
/* Work used for RPA rotation */ /* Work used for RPA rotation */
struct k_delayed_work rpa_update; struct k_delayed_work rpa_update;
@ -151,9 +151,9 @@ extern const struct bt_conn_auth_cb *bt_auth;
bool bt_le_conn_params_valid(const struct bt_le_conn_param *param); bool bt_le_conn_params_valid(const struct bt_le_conn_param *param);
struct net_buf *bt_hci_cmd_create(uint16_t opcode, uint8_t param_len); struct net_buf *bt_hci_cmd_create(u16_t opcode, u8_t param_len);
int bt_hci_cmd_send(uint16_t opcode, struct net_buf *buf); int bt_hci_cmd_send(u16_t opcode, struct net_buf *buf);
int bt_hci_cmd_send_sync(uint16_t opcode, struct net_buf *buf, int bt_hci_cmd_send_sync(u16_t opcode, struct net_buf *buf,
struct net_buf **rsp); struct net_buf **rsp);
/* The helper is only safe to be called from internal threads as it's /* The helper is only safe to be called from internal threads as it's
@ -168,4 +168,4 @@ bool bt_addr_le_is_bonded(const bt_addr_le_t *addr);
int bt_send(struct net_buf *buf); int bt_send(struct net_buf *buf);
uint16_t bt_hci_get_cmd_opcode(struct net_buf *buf); u16_t bt_hci_get_cmd_opcode(struct net_buf *buf);

View file

@ -36,13 +36,13 @@
static BT_STACK_NOINIT(ecc_thread_stack, 1060); static BT_STACK_NOINIT(ecc_thread_stack, 1060);
/* based on Core Specification 4.2 Vol 3. Part H 2.3.5.6.1 */ /* based on Core Specification 4.2 Vol 3. Part H 2.3.5.6.1 */
static const uint32_t debug_private_key[8] = { static const u32_t debug_private_key[8] = {
0xcd3c1abd, 0x5899b8a6, 0xeb40b799, 0x4aff607b, 0xd2103f50, 0x74c9b3e3, 0xcd3c1abd, 0x5899b8a6, 0xeb40b799, 0x4aff607b, 0xd2103f50, 0x74c9b3e3,
0xa3c55f38, 0x3f49f6d4 0xa3c55f38, 0x3f49f6d4
}; };
#if defined(CONFIG_BLUETOOTH_USE_DEBUG_KEYS) #if defined(CONFIG_BLUETOOTH_USE_DEBUG_KEYS)
static const uint8_t debug_public_key[64] = { static const u8_t debug_public_key[64] = {
0xe6, 0x9d, 0x35, 0x0e, 0x48, 0x01, 0x03, 0xcc, 0xdb, 0xfd, 0xf4, 0xac, 0xe6, 0x9d, 0x35, 0x0e, 0x48, 0x01, 0x03, 0xcc, 0xdb, 0xfd, 0xf4, 0xac,
0x11, 0x91, 0xf4, 0xef, 0xb9, 0xa5, 0xf9, 0xe9, 0xa7, 0x83, 0x2c, 0x5e, 0x11, 0x91, 0xf4, 0xef, 0xb9, 0xa5, 0xf9, 0xe9, 0xa7, 0x83, 0x2c, 0x5e,
0x2c, 0xbe, 0x97, 0xf2, 0xd2, 0x03, 0xb0, 0x20, 0x8b, 0xd2, 0x89, 0x15, 0x2c, 0xbe, 0x97, 0xf2, 0xd2, 0x03, 0xb0, 0x20, 0x8b, 0xd2, 0x89, 0x15,
@ -66,17 +66,17 @@ static struct {
* for the private_key and random to occupy the same memory area. * for the private_key and random to occupy the same memory area.
*/ */
union { union {
uint32_t private_key[NUM_ECC_DIGITS]; u32_t private_key[NUM_ECC_DIGITS];
uint32_t random[NUM_ECC_DIGITS * 2]; u32_t random[NUM_ECC_DIGITS * 2];
}; };
union { union {
EccPoint pk; EccPoint pk;
uint32_t dhkey[NUM_ECC_DIGITS]; u32_t dhkey[NUM_ECC_DIGITS];
}; };
} ecc; } ecc;
static void send_cmd_status(uint16_t opcode, uint8_t status) static void send_cmd_status(u16_t opcode, u8_t status)
{ {
struct bt_hci_evt_cmd_status *evt; struct bt_hci_evt_cmd_status *evt;
struct bt_hci_evt_hdr *hdr; struct bt_hci_evt_hdr *hdr;
@ -99,13 +99,13 @@ static void send_cmd_status(uint16_t opcode, uint8_t status)
bt_recv_prio(buf); bt_recv_prio(buf);
} }
static uint8_t generate_keys(void) static u8_t generate_keys(void)
{ {
#if !defined(CONFIG_BLUETOOTH_USE_DEBUG_KEYS) #if !defined(CONFIG_BLUETOOTH_USE_DEBUG_KEYS)
do { do {
int rc; int rc;
if (bt_rand((uint8_t *)ecc.random, sizeof(ecc.random))) { if (bt_rand((u8_t *)ecc.random, sizeof(ecc.random))) {
BT_ERR("Failed to get random bytes for ECC keys"); BT_ERR("Failed to get random bytes for ECC keys");
return BT_HCI_ERR_UNSPECIFIED; return BT_HCI_ERR_UNSPECIFIED;
} }
@ -131,7 +131,7 @@ static void emulate_le_p256_public_key_cmd(void)
struct bt_hci_evt_le_meta_event *meta; struct bt_hci_evt_le_meta_event *meta;
struct bt_hci_evt_hdr *hdr; struct bt_hci_evt_hdr *hdr;
struct net_buf *buf; struct net_buf *buf;
uint8_t status; u8_t status;
BT_DBG(""); BT_DBG("");
@ -168,7 +168,7 @@ static void emulate_le_generate_dhkey(void)
struct bt_hci_evt_le_meta_event *meta; struct bt_hci_evt_le_meta_event *meta;
struct bt_hci_evt_hdr *hdr; struct bt_hci_evt_hdr *hdr;
struct net_buf *buf; struct net_buf *buf;
int32_t ret; s32_t ret;
if (ecc_valid_public_key(&ecc.pk) < 0) { if (ecc_valid_public_key(&ecc.pk) < 0) {
ret = TC_CRYPTO_FAIL; ret = TC_CRYPTO_FAIL;
@ -236,7 +236,7 @@ static void clear_ecc_events(struct net_buf *buf)
static void le_gen_dhkey(struct net_buf *buf) static void le_gen_dhkey(struct net_buf *buf)
{ {
struct bt_hci_cp_le_generate_dhkey *cmd; struct bt_hci_cp_le_generate_dhkey *cmd;
uint8_t status; u8_t status;
if (atomic_test_bit(&flags, PENDING_PUB_KEY)) { if (atomic_test_bit(&flags, PENDING_PUB_KEY)) {
status = BT_HCI_ERR_CMD_DISALLOWED; status = BT_HCI_ERR_CMD_DISALLOWED;
@ -266,7 +266,7 @@ send_status:
static void le_p256_pub_key(struct net_buf *buf) static void le_p256_pub_key(struct net_buf *buf)
{ {
uint8_t status; u8_t status;
net_buf_unref(buf); net_buf_unref(buf);

View file

@ -45,12 +45,12 @@ int bt_hci_driver_register(const struct bt_hci_driver *drv)
return 0; return 0;
} }
struct net_buf *bt_buf_get_rx(int32_t timeout) struct net_buf *bt_buf_get_rx(s32_t timeout)
{ {
return net_buf_alloc(&hci_rx_pool, timeout); return net_buf_alloc(&hci_rx_pool, timeout);
} }
struct net_buf *bt_buf_get_cmd_complete(int32_t timeout) struct net_buf *bt_buf_get_cmd_complete(s32_t timeout)
{ {
struct net_buf *buf; struct net_buf *buf;
@ -62,7 +62,7 @@ struct net_buf *bt_buf_get_cmd_complete(int32_t timeout)
return buf; return buf;
} }
struct net_buf *bt_buf_get_evt(uint8_t opcode, int timeout) struct net_buf *bt_buf_get_evt(u8_t opcode, int timeout)
{ {
struct net_buf *buf; struct net_buf *buf;
@ -74,7 +74,7 @@ struct net_buf *bt_buf_get_evt(uint8_t opcode, int timeout)
return buf; return buf;
} }
struct net_buf *bt_buf_get_acl(int32_t timeout) struct net_buf *bt_buf_get_acl(s32_t timeout)
{ {
struct net_buf *buf; struct net_buf *buf;

View file

@ -38,8 +38,8 @@ static struct bt_hfp_hf bt_hfp_hf_pool[CONFIG_BLUETOOTH_MAX_CONN];
/* The order should follow the enum hfp_hf_ag_indicators */ /* The order should follow the enum hfp_hf_ag_indicators */
static const struct { static const struct {
char *name; char *name;
uint32_t min; u32_t min;
uint32_t max; u32_t max;
} ag_ind[] = { } ag_ind[] = {
{"service", 0, 1}, /* HF_SERVICE_IND */ {"service", 0, 1}, /* HF_SERVICE_IND */
{"call", 0, 1}, /* HF_CALL_IND */ {"call", 0, 1}, /* HF_CALL_IND */
@ -101,7 +101,7 @@ int hfp_hf_send_cmd(struct bt_hfp_hf *hf, at_resp_cb_t resp,
int brsf_handle(struct at_client *hf_at) int brsf_handle(struct at_client *hf_at)
{ {
struct bt_hfp_hf *hf = CONTAINER_OF(hf_at, struct bt_hfp_hf, at); struct bt_hfp_hf *hf = CONTAINER_OF(hf_at, struct bt_hfp_hf, at);
uint32_t val; u32_t val;
int ret; int ret;
ret = at_get_number(hf_at, &val); ret = at_get_number(hf_at, &val);
@ -134,8 +134,8 @@ int brsf_resp(struct at_client *hf_at, struct net_buf *buf)
return 0; return 0;
} }
static void cind_handle_values(struct at_client *hf_at, uint32_t index, static void cind_handle_values(struct at_client *hf_at, u32_t index,
char *name, uint32_t min, uint32_t max) char *name, u32_t min, u32_t max)
{ {
struct bt_hfp_hf *hf = CONTAINER_OF(hf_at, struct bt_hfp_hf, at); struct bt_hfp_hf *hf = CONTAINER_OF(hf_at, struct bt_hfp_hf, at);
int i; int i;
@ -157,12 +157,12 @@ static void cind_handle_values(struct at_client *hf_at, uint32_t index,
int cind_handle(struct at_client *hf_at) int cind_handle(struct at_client *hf_at)
{ {
uint32_t index = 0; u32_t index = 0;
/* Parsing Example: CIND: ("call",(0,1)) etc.. */ /* Parsing Example: CIND: ("call",(0,1)) etc.. */
while (at_has_next_list(hf_at)) { while (at_has_next_list(hf_at)) {
char name[MAX_IND_STR_LEN]; char name[MAX_IND_STR_LEN];
uint32_t min, max; u32_t min, max;
if (at_open_list(hf_at) < 0) { if (at_open_list(hf_at) < 0) {
BT_ERR("Could not get open list"); BT_ERR("Could not get open list");
@ -219,8 +219,8 @@ int cind_resp(struct at_client *hf_at, struct net_buf *buf)
return 0; return 0;
} }
void ag_indicator_handle_values(struct at_client *hf_at, uint32_t index, void ag_indicator_handle_values(struct at_client *hf_at, u32_t index,
uint32_t value) u32_t value)
{ {
struct bt_hfp_hf *hf = CONTAINER_OF(hf_at, struct bt_hfp_hf, at); struct bt_hfp_hf *hf = CONTAINER_OF(hf_at, struct bt_hfp_hf, at);
struct bt_conn *conn = hf->rfcomm_dlc.session->br_chan.chan.conn; struct bt_conn *conn = hf->rfcomm_dlc.session->br_chan.chan.conn;
@ -283,10 +283,10 @@ void ag_indicator_handle_values(struct at_client *hf_at, uint32_t index,
int cind_status_handle(struct at_client *hf_at) int cind_status_handle(struct at_client *hf_at)
{ {
uint32_t index = 0; u32_t index = 0;
while (at_has_next_list(hf_at)) { while (at_has_next_list(hf_at)) {
uint32_t value; u32_t value;
int ret; int ret;
ret = at_get_number(hf_at, &value); ret = at_get_number(hf_at, &value);
@ -319,7 +319,7 @@ int cind_status_resp(struct at_client *hf_at, struct net_buf *buf)
int ciev_handle(struct at_client *hf_at) int ciev_handle(struct at_client *hf_at)
{ {
uint32_t index, value; u32_t index, value;
int ret; int ret;
ret = at_get_number(hf_at, &index); ret = at_get_number(hf_at, &index);

View file

@ -48,9 +48,9 @@ struct bt_hfp_hf {
struct bt_rfcomm_dlc rfcomm_dlc; struct bt_rfcomm_dlc rfcomm_dlc;
char hf_buffer[HF_MAX_BUF_LEN]; char hf_buffer[HF_MAX_BUF_LEN];
struct at_client at; struct at_client at;
uint32_t hf_features; u32_t hf_features;
uint32_t ag_features; u32_t ag_features;
int8_t ind_table[HF_MAX_AG_INDICATORS]; s8_t ind_table[HF_MAX_AG_INDICATORS];
}; };
enum hfp_hf_ag_indicators { enum hfp_hf_ag_indicators {

View file

@ -28,26 +28,26 @@ enum {
}; };
struct bt_ltk { struct bt_ltk {
uint64_t rand; u64_t rand;
uint16_t ediv; u16_t ediv;
uint8_t val[16]; u8_t val[16];
}; };
struct bt_irk { struct bt_irk {
uint8_t val[16]; u8_t val[16];
bt_addr_t rpa; bt_addr_t rpa;
}; };
struct bt_csrk { struct bt_csrk {
uint8_t val[16]; u8_t val[16];
uint32_t cnt; u32_t cnt;
}; };
struct bt_keys { struct bt_keys {
bt_addr_le_t addr; bt_addr_le_t addr;
uint8_t enc_size; u8_t enc_size;
ATOMIC_DEFINE(flags, BT_KEYS_NUM_FLAGS); ATOMIC_DEFINE(flags, BT_KEYS_NUM_FLAGS);
uint16_t keys; u16_t keys;
struct bt_ltk ltk; struct bt_ltk ltk;
struct bt_irk irk; struct bt_irk irk;
#if defined(CONFIG_BLUETOOTH_SIGNING) #if defined(CONFIG_BLUETOOTH_SIGNING)
@ -81,7 +81,7 @@ enum {
struct bt_keys_link_key { struct bt_keys_link_key {
bt_addr_t addr; bt_addr_t addr;
ATOMIC_DEFINE(flags, BT_LINK_KEY_NUM_FLAGS); ATOMIC_DEFINE(flags, BT_LINK_KEY_NUM_FLAGS);
uint8_t val[16]; u8_t val[16];
}; };
struct bt_keys_link_key *bt_keys_get_link_key(const bt_addr_t *addr); struct bt_keys_link_key *bt_keys_get_link_key(const bt_addr_t *addr);

View file

@ -73,9 +73,9 @@ struct bt_l2cap {
static struct bt_l2cap bt_l2cap_pool[CONFIG_BLUETOOTH_MAX_CONN]; static struct bt_l2cap bt_l2cap_pool[CONFIG_BLUETOOTH_MAX_CONN];
static uint8_t get_ident(void) static u8_t get_ident(void)
{ {
static uint8_t ident; static u8_t ident;
ident++; ident++;
/* handle integer overflow (0 is not valid) */ /* handle integer overflow (0 is not valid) */
@ -98,7 +98,7 @@ static struct bt_l2cap_le_chan *l2cap_chan_alloc_cid(struct bt_conn *conn,
struct bt_l2cap_chan *chan) struct bt_l2cap_chan *chan)
{ {
struct bt_l2cap_le_chan *ch = BT_L2CAP_LE_CHAN(chan); struct bt_l2cap_le_chan *ch = BT_L2CAP_LE_CHAN(chan);
uint16_t cid; u16_t cid;
/* /*
* No action needed if there's already a CID allocated, e.g. in * No action needed if there's already a CID allocated, e.g. in
@ -119,7 +119,7 @@ static struct bt_l2cap_le_chan *l2cap_chan_alloc_cid(struct bt_conn *conn,
} }
static struct bt_l2cap_le_chan * static struct bt_l2cap_le_chan *
__l2cap_lookup_ident(struct bt_conn *conn, uint16_t ident, bool remove) __l2cap_lookup_ident(struct bt_conn *conn, u16_t ident, bool remove)
{ {
struct bt_l2cap_chan *chan; struct bt_l2cap_chan *chan;
sys_snode_t *prev = NULL; sys_snode_t *prev = NULL;
@ -347,8 +347,8 @@ void bt_l2cap_disconnected(struct bt_conn *conn)
} }
static struct net_buf *l2cap_create_le_sig_pdu(struct net_buf *buf, static struct net_buf *l2cap_create_le_sig_pdu(struct net_buf *buf,
uint8_t code, uint8_t ident, u8_t code, u8_t ident,
uint16_t len) u16_t len)
{ {
struct bt_l2cap_sig_hdr *hdr; struct bt_l2cap_sig_hdr *hdr;
@ -364,7 +364,7 @@ static struct net_buf *l2cap_create_le_sig_pdu(struct net_buf *buf,
#if defined(CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL) #if defined(CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL)
static void l2cap_chan_send_req(struct bt_l2cap_le_chan *chan, static void l2cap_chan_send_req(struct bt_l2cap_le_chan *chan,
struct net_buf *buf, int32_t timeout) struct net_buf *buf, s32_t timeout)
{ {
/* BLUETOOTH SPECIFICATION Version 4.2 [Vol 3, Part A] page 126: /* BLUETOOTH SPECIFICATION Version 4.2 [Vol 3, Part A] page 126:
* *
@ -406,7 +406,7 @@ static int l2cap_le_conn_req(struct bt_l2cap_le_chan *ch)
return 0; return 0;
} }
static void l2cap_le_encrypt_change(struct bt_l2cap_chan *chan, uint8_t status) static void l2cap_le_encrypt_change(struct bt_l2cap_chan *chan, u8_t status)
{ {
/* Skip channels already connected or with a pending request */ /* Skip channels already connected or with a pending request */
if (chan->state != BT_L2CAP_CONNECT || chan->ident) { if (chan->state != BT_L2CAP_CONNECT || chan->ident) {
@ -424,7 +424,7 @@ static void l2cap_le_encrypt_change(struct bt_l2cap_chan *chan, uint8_t status)
} }
#endif /* CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL */ #endif /* CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL */
void bt_l2cap_encrypt_change(struct bt_conn *conn, uint8_t hci_status) void bt_l2cap_encrypt_change(struct bt_conn *conn, u8_t hci_status)
{ {
struct bt_l2cap_chan *chan; struct bt_l2cap_chan *chan;
@ -464,7 +464,7 @@ struct net_buf *bt_l2cap_create_pdu(struct net_buf_pool *pool, size_t reserve)
return bt_conn_create_pdu(pool, sizeof(struct bt_l2cap_hdr) + reserve); return bt_conn_create_pdu(pool, sizeof(struct bt_l2cap_hdr) + reserve);
} }
void bt_l2cap_send_cb(struct bt_conn *conn, uint16_t cid, struct net_buf *buf, void bt_l2cap_send_cb(struct bt_conn *conn, u16_t cid, struct net_buf *buf,
bt_conn_tx_cb_t cb) bt_conn_tx_cb_t cb)
{ {
struct bt_l2cap_hdr *hdr; struct bt_l2cap_hdr *hdr;
@ -478,8 +478,8 @@ void bt_l2cap_send_cb(struct bt_conn *conn, uint16_t cid, struct net_buf *buf,
bt_conn_send_cb(conn, buf, cb); bt_conn_send_cb(conn, buf, cb);
} }
static void l2cap_send_reject(struct bt_conn *conn, uint8_t ident, static void l2cap_send_reject(struct bt_conn *conn, u8_t ident,
uint16_t reason, void *data, uint8_t data_len) u16_t reason, void *data, u8_t data_len)
{ {
struct bt_l2cap_cmd_reject *rej; struct bt_l2cap_cmd_reject *rej;
struct net_buf *buf; struct net_buf *buf;
@ -510,7 +510,7 @@ static void le_conn_param_rsp(struct bt_l2cap *l2cap, struct net_buf *buf)
} }
#if defined(CONFIG_BLUETOOTH_CENTRAL) #if defined(CONFIG_BLUETOOTH_CENTRAL)
static void le_conn_param_update_req(struct bt_l2cap *l2cap, uint8_t ident, static void le_conn_param_update_req(struct bt_l2cap *l2cap, u8_t ident,
struct net_buf *buf) struct net_buf *buf)
{ {
struct bt_conn *conn = l2cap->chan.chan.conn; struct bt_conn *conn = l2cap->chan.chan.conn;
@ -560,7 +560,7 @@ static void le_conn_param_update_req(struct bt_l2cap *l2cap, uint8_t ident,
#endif /* CONFIG_BLUETOOTH_CENTRAL */ #endif /* CONFIG_BLUETOOTH_CENTRAL */
struct bt_l2cap_chan *bt_l2cap_le_lookup_tx_cid(struct bt_conn *conn, struct bt_l2cap_chan *bt_l2cap_le_lookup_tx_cid(struct bt_conn *conn,
uint16_t cid) u16_t cid)
{ {
struct bt_l2cap_chan *chan; struct bt_l2cap_chan *chan;
@ -574,7 +574,7 @@ struct bt_l2cap_chan *bt_l2cap_le_lookup_tx_cid(struct bt_conn *conn,
} }
struct bt_l2cap_chan *bt_l2cap_le_lookup_rx_cid(struct bt_conn *conn, struct bt_l2cap_chan *bt_l2cap_le_lookup_rx_cid(struct bt_conn *conn,
uint16_t cid) u16_t cid)
{ {
struct bt_l2cap_chan *chan; struct bt_l2cap_chan *chan;
@ -588,7 +588,7 @@ struct bt_l2cap_chan *bt_l2cap_le_lookup_rx_cid(struct bt_conn *conn,
} }
#if defined(CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL) #if defined(CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL)
static struct bt_l2cap_server *l2cap_server_lookup_psm(uint16_t psm) static struct bt_l2cap_server *l2cap_server_lookup_psm(u16_t psm)
{ {
struct bt_l2cap_server *server; struct bt_l2cap_server *server;
@ -662,7 +662,7 @@ static void l2cap_chan_tx_init(struct bt_l2cap_le_chan *chan)
} }
static void l2cap_chan_tx_give_credits(struct bt_l2cap_le_chan *chan, static void l2cap_chan_tx_give_credits(struct bt_l2cap_le_chan *chan,
uint16_t credits) u16_t credits)
{ {
BT_DBG("chan %p credits %u", chan, credits); BT_DBG("chan %p credits %u", chan, credits);
@ -672,7 +672,7 @@ static void l2cap_chan_tx_give_credits(struct bt_l2cap_le_chan *chan,
} }
static void l2cap_chan_rx_give_credits(struct bt_l2cap_le_chan *chan, static void l2cap_chan_rx_give_credits(struct bt_l2cap_le_chan *chan,
uint16_t credits) u16_t credits)
{ {
BT_DBG("chan %p credits %u", chan, credits); BT_DBG("chan %p credits %u", chan, credits);
@ -704,7 +704,7 @@ static void l2cap_chan_destroy(struct bt_l2cap_chan *chan)
} }
} }
static void le_conn_req(struct bt_l2cap *l2cap, uint8_t ident, static void le_conn_req(struct bt_l2cap *l2cap, u8_t ident,
struct net_buf *buf) struct net_buf *buf)
{ {
struct bt_conn *conn = l2cap->chan.chan.conn; struct bt_conn *conn = l2cap->chan.chan.conn;
@ -712,7 +712,7 @@ static void le_conn_req(struct bt_l2cap *l2cap, uint8_t ident,
struct bt_l2cap_server *server; struct bt_l2cap_server *server;
struct bt_l2cap_le_conn_req *req = (void *)buf->data; struct bt_l2cap_le_conn_req *req = (void *)buf->data;
struct bt_l2cap_le_conn_rsp *rsp; struct bt_l2cap_le_conn_rsp *rsp;
uint16_t psm, scid, mtu, mps, credits; u16_t psm, scid, mtu, mps, credits;
if (buf->len < sizeof(*req)) { if (buf->len < sizeof(*req)) {
BT_ERR("Too small LE conn req packet size"); BT_ERR("Too small LE conn req packet size");
@ -814,7 +814,7 @@ rsp:
} }
static struct bt_l2cap_le_chan *l2cap_remove_tx_cid(struct bt_conn *conn, static struct bt_l2cap_le_chan *l2cap_remove_tx_cid(struct bt_conn *conn,
uint16_t cid) u16_t cid)
{ {
struct bt_l2cap_chan *chan; struct bt_l2cap_chan *chan;
sys_snode_t *prev = NULL; sys_snode_t *prev = NULL;
@ -836,14 +836,14 @@ static struct bt_l2cap_le_chan *l2cap_remove_tx_cid(struct bt_conn *conn,
return NULL; return NULL;
} }
static void le_disconn_req(struct bt_l2cap *l2cap, uint8_t ident, static void le_disconn_req(struct bt_l2cap *l2cap, u8_t ident,
struct net_buf *buf) struct net_buf *buf)
{ {
struct bt_conn *conn = l2cap->chan.chan.conn; struct bt_conn *conn = l2cap->chan.chan.conn;
struct bt_l2cap_le_chan *chan; struct bt_l2cap_le_chan *chan;
struct bt_l2cap_disconn_req *req = (void *)buf->data; struct bt_l2cap_disconn_req *req = (void *)buf->data;
struct bt_l2cap_disconn_rsp *rsp; struct bt_l2cap_disconn_rsp *rsp;
uint16_t scid; u16_t scid;
if (buf->len < sizeof(*req)) { if (buf->len < sizeof(*req)) {
BT_ERR("Too small LE conn req packet size"); BT_ERR("Too small LE conn req packet size");
@ -878,7 +878,7 @@ static void le_disconn_req(struct bt_l2cap *l2cap, uint8_t ident,
bt_l2cap_send(conn, BT_L2CAP_CID_LE_SIG, buf); bt_l2cap_send(conn, BT_L2CAP_CID_LE_SIG, buf);
} }
static int l2cap_change_security(struct bt_l2cap_le_chan *chan, uint16_t err) static int l2cap_change_security(struct bt_l2cap_le_chan *chan, u16_t err)
{ {
switch (err) { switch (err) {
case BT_L2CAP_ERR_ENCRYPTION: case BT_L2CAP_ERR_ENCRYPTION:
@ -905,13 +905,13 @@ static int l2cap_change_security(struct bt_l2cap_le_chan *chan, uint16_t err)
return bt_conn_security(chan->chan.conn, chan->chan.required_sec_level); return bt_conn_security(chan->chan.conn, chan->chan.required_sec_level);
} }
static void le_conn_rsp(struct bt_l2cap *l2cap, uint8_t ident, static void le_conn_rsp(struct bt_l2cap *l2cap, u8_t ident,
struct net_buf *buf) struct net_buf *buf)
{ {
struct bt_conn *conn = l2cap->chan.chan.conn; struct bt_conn *conn = l2cap->chan.chan.conn;
struct bt_l2cap_le_chan *chan; struct bt_l2cap_le_chan *chan;
struct bt_l2cap_le_conn_rsp *rsp = (void *)buf->data; struct bt_l2cap_le_conn_rsp *rsp = (void *)buf->data;
uint16_t dcid, mtu, mps, credits, result; u16_t dcid, mtu, mps, credits, result;
if (buf->len < sizeof(*rsp)) { if (buf->len < sizeof(*rsp)) {
BT_ERR("Too small LE conn rsp packet size"); BT_ERR("Too small LE conn rsp packet size");
@ -977,13 +977,13 @@ static void le_conn_rsp(struct bt_l2cap *l2cap, uint8_t ident,
} }
} }
static void le_disconn_rsp(struct bt_l2cap *l2cap, uint8_t ident, static void le_disconn_rsp(struct bt_l2cap *l2cap, u8_t ident,
struct net_buf *buf) struct net_buf *buf)
{ {
struct bt_conn *conn = l2cap->chan.chan.conn; struct bt_conn *conn = l2cap->chan.chan.conn;
struct bt_l2cap_le_chan *chan; struct bt_l2cap_le_chan *chan;
struct bt_l2cap_disconn_rsp *rsp = (void *)buf->data; struct bt_l2cap_disconn_rsp *rsp = (void *)buf->data;
uint16_t dcid; u16_t dcid;
if (buf->len < sizeof(*rsp)) { if (buf->len < sizeof(*rsp)) {
BT_ERR("Too small LE disconn rsp packet size"); BT_ERR("Too small LE disconn rsp packet size");
@ -1024,8 +1024,8 @@ static struct net_buf *l2cap_chan_create_seg(struct bt_l2cap_le_chan *ch,
size_t sdu_hdr_len) size_t sdu_hdr_len)
{ {
struct net_buf *seg; struct net_buf *seg;
uint16_t headroom; u16_t headroom;
uint16_t len; u16_t len;
/* Segment if data (+ data headroom) is bigger than MPS */ /* Segment if data (+ data headroom) is bigger than MPS */
if (buf->len + sdu_hdr_len > ch->tx.mps) { if (buf->len + sdu_hdr_len > ch->tx.mps) {
@ -1072,7 +1072,7 @@ segment:
} }
static int l2cap_chan_le_send(struct bt_l2cap_le_chan *ch, struct net_buf *buf, static int l2cap_chan_le_send(struct bt_l2cap_le_chan *ch, struct net_buf *buf,
uint16_t sdu_hdr_len) u16_t sdu_hdr_len)
{ {
int len; int len;
@ -1194,14 +1194,14 @@ static void l2cap_chan_le_send_resume(struct bt_l2cap_le_chan *ch)
} }
} }
static void le_credits(struct bt_l2cap *l2cap, uint8_t ident, static void le_credits(struct bt_l2cap *l2cap, u8_t ident,
struct net_buf *buf) struct net_buf *buf)
{ {
struct bt_conn *conn = l2cap->chan.chan.conn; struct bt_conn *conn = l2cap->chan.chan.conn;
struct bt_l2cap_chan *chan; struct bt_l2cap_chan *chan;
struct bt_l2cap_le_credits *ev = (void *)buf->data; struct bt_l2cap_le_credits *ev = (void *)buf->data;
struct bt_l2cap_le_chan *ch; struct bt_l2cap_le_chan *ch;
uint16_t credits, cid; u16_t credits, cid;
if (buf->len < sizeof(*ev)) { if (buf->len < sizeof(*ev)) {
BT_ERR("Too small LE Credits packet size"); BT_ERR("Too small LE Credits packet size");
@ -1235,7 +1235,7 @@ static void le_credits(struct bt_l2cap *l2cap, uint8_t ident,
l2cap_chan_le_send_resume(ch); l2cap_chan_le_send_resume(ch);
} }
static void reject_cmd(struct bt_l2cap *l2cap, uint8_t ident, static void reject_cmd(struct bt_l2cap *l2cap, u8_t ident,
struct net_buf *buf) struct net_buf *buf)
{ {
struct bt_conn *conn = l2cap->chan.chan.conn; struct bt_conn *conn = l2cap->chan.chan.conn;
@ -1255,7 +1255,7 @@ static void l2cap_recv(struct bt_l2cap_chan *chan, struct net_buf *buf)
{ {
struct bt_l2cap *l2cap = CONTAINER_OF(chan, struct bt_l2cap, chan); struct bt_l2cap *l2cap = CONTAINER_OF(chan, struct bt_l2cap, chan);
struct bt_l2cap_sig_hdr *hdr = (void *)buf->data; struct bt_l2cap_sig_hdr *hdr = (void *)buf->data;
uint16_t len; u16_t len;
if (buf->len < sizeof(*hdr)) { if (buf->len < sizeof(*hdr)) {
BT_ERR("Too small L2CAP signaling PDU"); BT_ERR("Too small L2CAP signaling PDU");
@ -1324,7 +1324,7 @@ static void l2cap_chan_update_credits(struct bt_l2cap_le_chan *chan,
struct net_buf *buf) struct net_buf *buf)
{ {
struct bt_l2cap_le_credits *ev; struct bt_l2cap_le_credits *ev;
uint16_t credits; u16_t credits;
/* Only give more credits if it went bellow the defined threshold */ /* Only give more credits if it went bellow the defined threshold */
if (k_sem_count_get(&chan->rx.credits) > if (k_sem_count_get(&chan->rx.credits) >
@ -1369,7 +1369,7 @@ static void l2cap_chan_le_recv_sdu(struct bt_l2cap_le_chan *chan,
struct net_buf *buf) struct net_buf *buf)
{ {
struct net_buf *frag; struct net_buf *frag;
uint16_t len; u16_t len;
BT_DBG("chan %p len %u sdu %zu", chan, buf->len, BT_DBG("chan %p len %u sdu %zu", chan, buf->len,
net_buf_frags_len(chan->_sdu)); net_buf_frags_len(chan->_sdu));
@ -1415,7 +1415,7 @@ static void l2cap_chan_le_recv_sdu(struct bt_l2cap_le_chan *chan,
static void l2cap_chan_le_recv(struct bt_l2cap_le_chan *chan, static void l2cap_chan_le_recv(struct bt_l2cap_le_chan *chan,
struct net_buf *buf) struct net_buf *buf)
{ {
uint16_t sdu_len; u16_t sdu_len;
if (k_sem_take(&chan->rx.credits, K_NO_WAIT)) { if (k_sem_take(&chan->rx.credits, K_NO_WAIT)) {
BT_ERR("No credits to receive packet"); BT_ERR("No credits to receive packet");
@ -1478,7 +1478,7 @@ void bt_l2cap_recv(struct bt_conn *conn, struct net_buf *buf)
{ {
struct bt_l2cap_hdr *hdr = (void *)buf->data; struct bt_l2cap_hdr *hdr = (void *)buf->data;
struct bt_l2cap_chan *chan; struct bt_l2cap_chan *chan;
uint16_t cid; u16_t cid;
if (IS_ENABLED(CONFIG_BLUETOOTH_BREDR) && if (IS_ENABLED(CONFIG_BLUETOOTH_BREDR) &&
conn->type == BT_CONN_TYPE_BR) { conn->type == BT_CONN_TYPE_BR) {
@ -1585,7 +1585,7 @@ void bt_l2cap_init(void)
#if defined(CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL) #if defined(CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL)
static int l2cap_le_connect(struct bt_conn *conn, struct bt_l2cap_le_chan *ch, static int l2cap_le_connect(struct bt_conn *conn, struct bt_l2cap_le_chan *ch,
uint16_t psm) u16_t psm)
{ {
if (psm < L2CAP_LE_PSM_START || psm > L2CAP_LE_PSM_END) { if (psm < L2CAP_LE_PSM_START || psm > L2CAP_LE_PSM_END) {
return -EINVAL; return -EINVAL;
@ -1604,7 +1604,7 @@ static int l2cap_le_connect(struct bt_conn *conn, struct bt_l2cap_le_chan *ch,
} }
int bt_l2cap_chan_connect(struct bt_conn *conn, struct bt_l2cap_chan *chan, int bt_l2cap_chan_connect(struct bt_conn *conn, struct bt_l2cap_chan *chan,
uint16_t psm) u16_t psm)
{ {
BT_DBG("conn %p chan %p psm 0x%04x", conn, chan, psm); BT_DBG("conn %p chan %p psm 0x%04x", conn, chan, psm);

View file

@ -87,15 +87,15 @@ NET_BUF_POOL_DEFINE(br_sig_pool, CONFIG_BLUETOOTH_MAX_CONN,
struct bt_l2cap_br { struct bt_l2cap_br {
/* The channel this context is associated with */ /* The channel this context is associated with */
struct bt_l2cap_br_chan chan; struct bt_l2cap_br_chan chan;
uint8_t info_ident; u8_t info_ident;
uint8_t info_fixed_chan; u8_t info_fixed_chan;
uint32_t info_feat_mask; u32_t info_feat_mask;
}; };
static struct bt_l2cap_br bt_l2cap_br_pool[CONFIG_BLUETOOTH_MAX_CONN]; static struct bt_l2cap_br bt_l2cap_br_pool[CONFIG_BLUETOOTH_MAX_CONN];
struct bt_l2cap_chan *bt_l2cap_br_lookup_rx_cid(struct bt_conn *conn, struct bt_l2cap_chan *bt_l2cap_br_lookup_rx_cid(struct bt_conn *conn,
uint16_t cid) u16_t cid)
{ {
struct bt_l2cap_chan *chan; struct bt_l2cap_chan *chan;
@ -109,7 +109,7 @@ struct bt_l2cap_chan *bt_l2cap_br_lookup_rx_cid(struct bt_conn *conn,
} }
struct bt_l2cap_chan *bt_l2cap_br_lookup_tx_cid(struct bt_conn *conn, struct bt_l2cap_chan *bt_l2cap_br_lookup_tx_cid(struct bt_conn *conn,
uint16_t cid) u16_t cid)
{ {
struct bt_l2cap_chan *chan; struct bt_l2cap_chan *chan;
@ -126,7 +126,7 @@ static struct bt_l2cap_br_chan*
l2cap_br_chan_alloc_cid(struct bt_conn *conn, struct bt_l2cap_chan *chan) l2cap_br_chan_alloc_cid(struct bt_conn *conn, struct bt_l2cap_chan *chan)
{ {
struct bt_l2cap_br_chan *ch = BR_CHAN(chan); struct bt_l2cap_br_chan *ch = BR_CHAN(chan);
uint16_t cid; u16_t cid;
/* /*
* No action needed if there's already a CID allocated, e.g. in * No action needed if there's already a CID allocated, e.g. in
@ -138,7 +138,7 @@ l2cap_br_chan_alloc_cid(struct bt_conn *conn, struct bt_l2cap_chan *chan)
/* /*
* L2CAP_BR_CID_DYN_END is 0xffff so we don't check against it since * L2CAP_BR_CID_DYN_END is 0xffff so we don't check against it since
* cid is uint16_t, just check against uint16_t overflow * cid is u16_t, just check against u16_t overflow
*/ */
for (cid = L2CAP_BR_CID_DYN_START; cid; cid++) { for (cid = L2CAP_BR_CID_DYN_START; cid; cid++) {
if (!bt_l2cap_br_lookup_rx_cid(conn, cid)) { if (!bt_l2cap_br_lookup_rx_cid(conn, cid)) {
@ -211,9 +211,9 @@ static bool l2cap_br_chan_add(struct bt_conn *conn, struct bt_l2cap_chan *chan,
return true; return true;
} }
static uint8_t l2cap_br_get_ident(void) static u8_t l2cap_br_get_ident(void)
{ {
static uint8_t ident; static u8_t ident;
ident++; ident++;
/* handle integer overflow (0 is not valid) */ /* handle integer overflow (0 is not valid) */
@ -225,7 +225,7 @@ static uint8_t l2cap_br_get_ident(void)
} }
static void l2cap_br_chan_send_req(struct bt_l2cap_br_chan *chan, static void l2cap_br_chan_send_req(struct bt_l2cap_br_chan *chan,
struct net_buf *buf, int32_t timeout) struct net_buf *buf, s32_t timeout)
{ {
/* BLUETOOTH SPECIFICATION Version 4.2 [Vol 3, Part A] page 126: /* BLUETOOTH SPECIFICATION Version 4.2 [Vol 3, Part A] page 126:
* *
@ -245,7 +245,7 @@ static void l2cap_br_chan_send_req(struct bt_l2cap_br_chan *chan,
bt_l2cap_send(chan->chan.conn, BT_L2CAP_CID_BR_SIG, buf); bt_l2cap_send(chan->chan.conn, BT_L2CAP_CID_BR_SIG, buf);
} }
static void l2cap_br_get_info(struct bt_l2cap_br *l2cap, uint16_t info_type) static void l2cap_br_get_info(struct bt_l2cap_br *l2cap, u16_t info_type)
{ {
struct bt_l2cap_info_req *info; struct bt_l2cap_info_req *info;
struct net_buf *buf; struct net_buf *buf;
@ -307,11 +307,11 @@ static void connect_optional_fixed_channels(struct bt_l2cap_br *l2cap)
} }
} }
static int l2cap_br_info_rsp(struct bt_l2cap_br *l2cap, uint8_t ident, static int l2cap_br_info_rsp(struct bt_l2cap_br *l2cap, u8_t ident,
struct net_buf *buf) struct net_buf *buf)
{ {
struct bt_l2cap_info_rsp *rsp = (void *)buf->data; struct bt_l2cap_info_rsp *rsp = (void *)buf->data;
uint16_t type, result; u16_t type, result;
int err = 0; int err = 0;
if (atomic_test_bit(l2cap->chan.flags, L2CAP_FLAG_SIG_INFO_DONE)) { if (atomic_test_bit(l2cap->chan.flags, L2CAP_FLAG_SIG_INFO_DONE)) {
@ -379,10 +379,10 @@ done:
return err; return err;
} }
static uint8_t get_fixed_channels_mask(void) static u8_t get_fixed_channels_mask(void)
{ {
struct bt_l2cap_fixed_chan *fchan; struct bt_l2cap_fixed_chan *fchan;
uint8_t mask = 0; u8_t mask = 0;
/* this needs to be enhanced if AMP Test Manager support is added */ /* this needs to be enhanced if AMP Test Manager support is added */
SYS_SLIST_FOR_EACH_CONTAINER(&br_fixed_channels, fchan, node) { SYS_SLIST_FOR_EACH_CONTAINER(&br_fixed_channels, fchan, node) {
@ -392,7 +392,7 @@ static uint8_t get_fixed_channels_mask(void)
return mask; return mask;
} }
static int l2cap_br_info_req(struct bt_l2cap_br *l2cap, uint8_t ident, static int l2cap_br_info_req(struct bt_l2cap_br *l2cap, u8_t ident,
struct net_buf *buf) struct net_buf *buf)
{ {
struct bt_conn *conn = l2cap->chan.chan.conn; struct bt_conn *conn = l2cap->chan.chan.conn;
@ -400,7 +400,7 @@ static int l2cap_br_info_req(struct bt_l2cap_br *l2cap, uint8_t ident,
struct bt_l2cap_info_rsp *rsp; struct bt_l2cap_info_rsp *rsp;
struct net_buf *rsp_buf; struct net_buf *rsp_buf;
struct bt_l2cap_sig_hdr *hdr_info; struct bt_l2cap_sig_hdr *hdr_info;
uint16_t type; u16_t type;
if (buf->len < sizeof(*req)) { if (buf->len < sizeof(*req)) {
BT_ERR("Too small info req packet size"); BT_ERR("Too small info req packet size");
@ -423,7 +423,7 @@ static int l2cap_br_info_req(struct bt_l2cap_br *l2cap, uint8_t ident,
rsp->type = sys_cpu_to_le16(BT_L2CAP_INFO_FEAT_MASK); rsp->type = sys_cpu_to_le16(BT_L2CAP_INFO_FEAT_MASK);
rsp->result = sys_cpu_to_le16(BT_L2CAP_INFO_SUCCESS); rsp->result = sys_cpu_to_le16(BT_L2CAP_INFO_SUCCESS);
net_buf_add_le32(rsp_buf, L2CAP_FEAT_FIXED_CHAN_MASK); net_buf_add_le32(rsp_buf, L2CAP_FEAT_FIXED_CHAN_MASK);
hdr_info->len = sys_cpu_to_le16(sizeof(*rsp) + sizeof(uint32_t)); hdr_info->len = sys_cpu_to_le16(sizeof(*rsp) + sizeof(u32_t));
break; break;
case BT_L2CAP_INFO_FIXED_CHAN: case BT_L2CAP_INFO_FIXED_CHAN:
rsp->type = sys_cpu_to_le16(BT_L2CAP_INFO_FIXED_CHAN); rsp->type = sys_cpu_to_le16(BT_L2CAP_INFO_FIXED_CHAN);
@ -486,7 +486,7 @@ void bt_l2cap_br_connected(struct bt_conn *conn)
} }
} }
static struct bt_l2cap_server *l2cap_br_server_lookup_psm(uint16_t psm) static struct bt_l2cap_server *l2cap_br_server_lookup_psm(u16_t psm)
{ {
struct bt_l2cap_server *server; struct bt_l2cap_server *server;
@ -499,7 +499,7 @@ static struct bt_l2cap_server *l2cap_br_server_lookup_psm(uint16_t psm)
return NULL; return NULL;
} }
static void l2cap_br_conf_add_mtu(struct net_buf *buf, const uint16_t mtu) static void l2cap_br_conf_add_mtu(struct net_buf *buf, const u16_t mtu)
{ {
net_buf_add_u8(buf, BT_L2CAP_CONF_OPT_MTU); net_buf_add_u8(buf, BT_L2CAP_CONF_OPT_MTU);
net_buf_add_u8(buf, sizeof(mtu)); net_buf_add_u8(buf, sizeof(mtu));
@ -559,7 +559,7 @@ enum l2cap_br_conn_security_result {
*/ */
static enum l2cap_br_conn_security_result static enum l2cap_br_conn_security_result
l2cap_br_conn_security(struct bt_l2cap_chan *chan, const uint16_t psm) l2cap_br_conn_security(struct bt_l2cap_chan *chan, const u16_t psm)
{ {
int check; int check;
@ -625,8 +625,8 @@ l2cap_br_conn_security(struct bt_l2cap_chan *chan, const uint16_t psm)
return L2CAP_CONN_SECURITY_REJECT; return L2CAP_CONN_SECURITY_REJECT;
} }
static void l2cap_br_send_conn_rsp(struct bt_conn *conn, uint16_t scid, static void l2cap_br_send_conn_rsp(struct bt_conn *conn, u16_t scid,
uint16_t dcid, uint8_t ident, uint16_t result) u16_t dcid, u8_t ident, u16_t result)
{ {
struct net_buf *buf; struct net_buf *buf;
struct bt_l2cap_conn_rsp *rsp; struct bt_l2cap_conn_rsp *rsp;
@ -653,7 +653,7 @@ static void l2cap_br_send_conn_rsp(struct bt_conn *conn, uint16_t scid,
bt_l2cap_send(conn, BT_L2CAP_CID_BR_SIG, buf); bt_l2cap_send(conn, BT_L2CAP_CID_BR_SIG, buf);
} }
static int l2cap_br_conn_req_reply(struct bt_l2cap_chan *chan, uint16_t result) static int l2cap_br_conn_req_reply(struct bt_l2cap_chan *chan, u16_t result)
{ {
/* Send response to connection request only when in acceptor role */ /* Send response to connection request only when in acceptor role */
if (!atomic_test_bit(BR_CHAN(chan)->flags, L2CAP_FLAG_CONN_ACCEPTOR)) { if (!atomic_test_bit(BR_CHAN(chan)->flags, L2CAP_FLAG_CONN_ACCEPTOR)) {
@ -667,14 +667,14 @@ static int l2cap_br_conn_req_reply(struct bt_l2cap_chan *chan, uint16_t result)
return 0; return 0;
} }
static void l2cap_br_conn_req(struct bt_l2cap_br *l2cap, uint8_t ident, static void l2cap_br_conn_req(struct bt_l2cap_br *l2cap, u8_t ident,
struct net_buf *buf) struct net_buf *buf)
{ {
struct bt_conn *conn = l2cap->chan.chan.conn; struct bt_conn *conn = l2cap->chan.chan.conn;
struct bt_l2cap_chan *chan; struct bt_l2cap_chan *chan;
struct bt_l2cap_server *server; struct bt_l2cap_server *server;
struct bt_l2cap_conn_req *req = (void *)buf->data; struct bt_l2cap_conn_req *req = (void *)buf->data;
uint16_t psm, scid, result; u16_t psm, scid, result;
if (buf->len < sizeof(*req)) { if (buf->len < sizeof(*req)) {
BT_ERR("Too small L2CAP conn req packet size"); BT_ERR("Too small L2CAP conn req packet size");
@ -774,13 +774,13 @@ no_chan:
l2cap_br_send_conn_rsp(conn, scid, 0, ident, result); l2cap_br_send_conn_rsp(conn, scid, 0, ident, result);
} }
static void l2cap_br_conf_rsp(struct bt_l2cap_br *l2cap, uint8_t ident, static void l2cap_br_conf_rsp(struct bt_l2cap_br *l2cap, u8_t ident,
uint16_t len, struct net_buf *buf) u16_t len, struct net_buf *buf)
{ {
struct bt_conn *conn = l2cap->chan.chan.conn; struct bt_conn *conn = l2cap->chan.chan.conn;
struct bt_l2cap_chan *chan; struct bt_l2cap_chan *chan;
struct bt_l2cap_conf_rsp *rsp = (void *)buf->data; struct bt_l2cap_conf_rsp *rsp = (void *)buf->data;
uint16_t flags, scid, result, opt_len; u16_t flags, scid, result, opt_len;
if (buf->len < sizeof(*rsp)) { if (buf->len < sizeof(*rsp)) {
BT_ERR("Too small L2CAP conf rsp packet size"); BT_ERR("Too small L2CAP conf rsp packet size");
@ -863,8 +863,8 @@ int bt_l2cap_br_server_register(struct bt_l2cap_server *server)
return 0; return 0;
} }
static void l2cap_br_send_reject(struct bt_conn *conn, uint8_t ident, static void l2cap_br_send_reject(struct bt_conn *conn, u8_t ident,
uint16_t reason, void *data, uint8_t data_len) u16_t reason, void *data, u8_t data_len)
{ {
struct bt_l2cap_cmd_reject *rej; struct bt_l2cap_cmd_reject *rej;
struct bt_l2cap_sig_hdr *hdr; struct bt_l2cap_sig_hdr *hdr;
@ -892,10 +892,10 @@ static void l2cap_br_send_reject(struct bt_conn *conn, uint8_t ident,
bt_l2cap_send(conn, BT_L2CAP_CID_BR_SIG, buf); bt_l2cap_send(conn, BT_L2CAP_CID_BR_SIG, buf);
} }
static uint16_t l2cap_br_conf_opt_mtu(struct bt_l2cap_chan *chan, static u16_t l2cap_br_conf_opt_mtu(struct bt_l2cap_chan *chan,
struct net_buf *buf, size_t len) struct net_buf *buf, size_t len)
{ {
uint16_t mtu, result = BT_L2CAP_CONF_SUCCESS; u16_t mtu, result = BT_L2CAP_CONF_SUCCESS;
/* Core 4.2 [Vol 3, Part A, 5.1] MTU payload length */ /* Core 4.2 [Vol 3, Part A, 5.1] MTU payload length */
if (len != 2) { if (len != 2) {
@ -919,8 +919,8 @@ done:
return result; return result;
} }
static void l2cap_br_conf_req(struct bt_l2cap_br *l2cap, uint8_t ident, static void l2cap_br_conf_req(struct bt_l2cap_br *l2cap, u8_t ident,
uint16_t len, struct net_buf *buf) u16_t len, struct net_buf *buf)
{ {
struct bt_conn *conn = l2cap->chan.chan.conn; struct bt_conn *conn = l2cap->chan.chan.conn;
struct bt_l2cap_chan *chan; struct bt_l2cap_chan *chan;
@ -928,7 +928,7 @@ static void l2cap_br_conf_req(struct bt_l2cap_br *l2cap, uint8_t ident,
struct bt_l2cap_sig_hdr *hdr; struct bt_l2cap_sig_hdr *hdr;
struct bt_l2cap_conf_rsp *rsp; struct bt_l2cap_conf_rsp *rsp;
struct bt_l2cap_conf_opt *opt; struct bt_l2cap_conf_opt *opt;
uint16_t flags, dcid, opt_len, hint, result = BT_L2CAP_CONF_SUCCESS; u16_t flags, dcid, opt_len, hint, result = BT_L2CAP_CONF_SUCCESS;
if (buf->len < sizeof(*req)) { if (buf->len < sizeof(*req)) {
BT_ERR("Too small L2CAP conf req packet size"); BT_ERR("Too small L2CAP conf req packet size");
@ -1046,7 +1046,7 @@ send_rsp:
} }
static struct bt_l2cap_br_chan *l2cap_br_remove_tx_cid(struct bt_conn *conn, static struct bt_l2cap_br_chan *l2cap_br_remove_tx_cid(struct bt_conn *conn,
uint16_t cid) u16_t cid)
{ {
struct bt_l2cap_chan *chan; struct bt_l2cap_chan *chan;
sys_snode_t *prev = NULL; sys_snode_t *prev = NULL;
@ -1068,7 +1068,7 @@ static struct bt_l2cap_br_chan *l2cap_br_remove_tx_cid(struct bt_conn *conn,
return NULL; return NULL;
} }
static void l2cap_br_disconn_req(struct bt_l2cap_br *l2cap, uint8_t ident, static void l2cap_br_disconn_req(struct bt_l2cap_br *l2cap, u8_t ident,
struct net_buf *buf) struct net_buf *buf)
{ {
struct bt_conn *conn = l2cap->chan.chan.conn; struct bt_conn *conn = l2cap->chan.chan.conn;
@ -1076,7 +1076,7 @@ static void l2cap_br_disconn_req(struct bt_l2cap_br *l2cap, uint8_t ident,
struct bt_l2cap_disconn_req *req = (void *)buf->data; struct bt_l2cap_disconn_req *req = (void *)buf->data;
struct bt_l2cap_disconn_rsp *rsp; struct bt_l2cap_disconn_rsp *rsp;
struct bt_l2cap_sig_hdr *hdr; struct bt_l2cap_sig_hdr *hdr;
uint16_t scid, dcid; u16_t scid, dcid;
if (buf->len < sizeof(*req)) { if (buf->len < sizeof(*req)) {
BT_ERR("Too small disconn req packet size"); BT_ERR("Too small disconn req packet size");
@ -1169,13 +1169,13 @@ int bt_l2cap_br_chan_disconnect(struct bt_l2cap_chan *chan)
return 0; return 0;
} }
static void l2cap_br_disconn_rsp(struct bt_l2cap_br *l2cap, uint8_t ident, static void l2cap_br_disconn_rsp(struct bt_l2cap_br *l2cap, u8_t ident,
struct net_buf *buf) struct net_buf *buf)
{ {
struct bt_conn *conn = l2cap->chan.chan.conn; struct bt_conn *conn = l2cap->chan.chan.conn;
struct bt_l2cap_br_chan *chan; struct bt_l2cap_br_chan *chan;
struct bt_l2cap_disconn_rsp *rsp = (void *)buf->data; struct bt_l2cap_disconn_rsp *rsp = (void *)buf->data;
uint16_t dcid, scid; u16_t dcid, scid;
if (buf->len < sizeof(*rsp)) { if (buf->len < sizeof(*rsp)) {
BT_ERR("Too small disconn rsp packet size"); BT_ERR("Too small disconn rsp packet size");
@ -1197,7 +1197,7 @@ static void l2cap_br_disconn_rsp(struct bt_l2cap_br *l2cap, uint8_t ident,
} }
int bt_l2cap_br_chan_connect(struct bt_conn *conn, struct bt_l2cap_chan *chan, int bt_l2cap_br_chan_connect(struct bt_conn *conn, struct bt_l2cap_chan *chan,
uint16_t psm) u16_t psm)
{ {
struct net_buf *buf; struct net_buf *buf;
struct bt_l2cap_sig_hdr *hdr; struct bt_l2cap_sig_hdr *hdr;
@ -1276,13 +1276,13 @@ int bt_l2cap_br_chan_connect(struct bt_conn *conn, struct bt_l2cap_chan *chan,
return 0; return 0;
} }
static void l2cap_br_conn_rsp(struct bt_l2cap_br *l2cap, uint8_t ident, static void l2cap_br_conn_rsp(struct bt_l2cap_br *l2cap, u8_t ident,
struct net_buf *buf) struct net_buf *buf)
{ {
struct bt_conn *conn = l2cap->chan.chan.conn; struct bt_conn *conn = l2cap->chan.chan.conn;
struct bt_l2cap_chan *chan; struct bt_l2cap_chan *chan;
struct bt_l2cap_conn_rsp *rsp = (void *)buf->data; struct bt_l2cap_conn_rsp *rsp = (void *)buf->data;
uint16_t dcid, scid, result, status; u16_t dcid, scid, result, status;
if (buf->len < sizeof(*rsp)) { if (buf->len < sizeof(*rsp)) {
BT_ERR("Too small L2CAP conn rsp packet size"); BT_ERR("Too small L2CAP conn rsp packet size");
@ -1346,7 +1346,7 @@ static void l2cap_br_recv(struct bt_l2cap_chan *chan, struct net_buf *buf)
{ {
struct bt_l2cap_br *l2cap = CONTAINER_OF(chan, struct bt_l2cap_br, chan); struct bt_l2cap_br *l2cap = CONTAINER_OF(chan, struct bt_l2cap_br, chan);
struct bt_l2cap_sig_hdr *hdr = (void *)buf->data; struct bt_l2cap_sig_hdr *hdr = (void *)buf->data;
uint16_t len; u16_t len;
if (buf->len < sizeof(*hdr)) { if (buf->len < sizeof(*hdr)) {
BT_ERR("Too small L2CAP signaling PDU"); BT_ERR("Too small L2CAP signaling PDU");
@ -1402,7 +1402,7 @@ static void l2cap_br_recv(struct bt_l2cap_chan *chan, struct net_buf *buf)
} }
} }
static void l2cap_br_conn_pend(struct bt_l2cap_chan *chan, uint8_t status) static void l2cap_br_conn_pend(struct bt_l2cap_chan *chan, u8_t status)
{ {
struct net_buf *buf; struct net_buf *buf;
struct bt_l2cap_sig_hdr *hdr; struct bt_l2cap_sig_hdr *hdr;
@ -1464,7 +1464,7 @@ static void l2cap_br_conn_pend(struct bt_l2cap_chan *chan, uint8_t status)
} }
} }
void l2cap_br_encrypt_change(struct bt_conn *conn, uint8_t hci_status) void l2cap_br_encrypt_change(struct bt_conn *conn, u8_t hci_status)
{ {
struct bt_l2cap_chan *chan; struct bt_l2cap_chan *chan;
@ -1490,7 +1490,7 @@ void bt_l2cap_br_recv(struct bt_conn *conn, struct net_buf *buf)
{ {
struct bt_l2cap_hdr *hdr = (void *)buf->data; struct bt_l2cap_hdr *hdr = (void *)buf->data;
struct bt_l2cap_chan *chan; struct bt_l2cap_chan *chan;
uint16_t cid; u16_t cid;
if (buf->len < sizeof(*hdr)) { if (buf->len < sizeof(*hdr)) {
BT_ERR("Too small L2CAP PDU received"); BT_ERR("Too small L2CAP PDU received");

View file

@ -24,14 +24,14 @@ enum l2cap_conn_list_action {
#define BT_L2CAP_PSM_RFCOMM 0x0003 #define BT_L2CAP_PSM_RFCOMM 0x0003
struct bt_l2cap_hdr { struct bt_l2cap_hdr {
uint16_t len; u16_t len;
uint16_t cid; u16_t cid;
} __packed; } __packed;
struct bt_l2cap_sig_hdr { struct bt_l2cap_sig_hdr {
uint8_t code; u8_t code;
uint8_t ident; u8_t ident;
uint16_t len; u16_t len;
} __packed; } __packed;
#define BT_L2CAP_REJ_NOT_UNDERSTOOD 0x0000 #define BT_L2CAP_REJ_NOT_UNDERSTOOD 0x0000
@ -40,19 +40,19 @@ struct bt_l2cap_sig_hdr {
#define BT_L2CAP_CMD_REJECT 0x01 #define BT_L2CAP_CMD_REJECT 0x01
struct bt_l2cap_cmd_reject { struct bt_l2cap_cmd_reject {
uint16_t reason; u16_t reason;
uint8_t data[0]; u8_t data[0];
} __packed; } __packed;
struct bt_l2cap_cmd_reject_cid_data { struct bt_l2cap_cmd_reject_cid_data {
uint16_t scid; u16_t scid;
uint16_t dcid; u16_t dcid;
} __packed; } __packed;
#define BT_L2CAP_CONN_REQ 0x02 #define BT_L2CAP_CONN_REQ 0x02
struct bt_l2cap_conn_req { struct bt_l2cap_conn_req {
uint16_t psm; u16_t psm;
uint16_t scid; u16_t scid;
} __packed; } __packed;
/* command statuses in reposnse */ /* command statuses in reposnse */
@ -70,10 +70,10 @@ struct bt_l2cap_conn_req {
#define BT_L2CAP_CONN_RSP 0x03 #define BT_L2CAP_CONN_RSP 0x03
struct bt_l2cap_conn_rsp { struct bt_l2cap_conn_rsp {
uint16_t dcid; u16_t dcid;
uint16_t scid; u16_t scid;
uint16_t result; u16_t result;
uint16_t status; u16_t status;
} __packed; } __packed;
#define BT_L2CAP_CONF_SUCCESS 0x0000 #define BT_L2CAP_CONF_SUCCESS 0x0000
@ -82,17 +82,17 @@ struct bt_l2cap_conn_rsp {
#define BT_L2CAP_CONF_REQ 0x04 #define BT_L2CAP_CONF_REQ 0x04
struct bt_l2cap_conf_req { struct bt_l2cap_conf_req {
uint16_t dcid; u16_t dcid;
uint16_t flags; u16_t flags;
uint8_t data[0]; u8_t data[0];
} __packed; } __packed;
#define BT_L2CAP_CONF_RSP 0x05 #define BT_L2CAP_CONF_RSP 0x05
struct bt_l2cap_conf_rsp { struct bt_l2cap_conf_rsp {
uint16_t scid; u16_t scid;
uint16_t flags; u16_t flags;
uint16_t result; u16_t result;
uint8_t data[0]; u8_t data[0];
} __packed; } __packed;
/* Option type used by MTU config request data */ /* Option type used by MTU config request data */
@ -102,21 +102,21 @@ struct bt_l2cap_conf_rsp {
#define BT_L2CAP_CONF_MASK 0x7f #define BT_L2CAP_CONF_MASK 0x7f
struct bt_l2cap_conf_opt { struct bt_l2cap_conf_opt {
uint8_t type; u8_t type;
uint8_t len; u8_t len;
uint8_t data[0]; u8_t data[0];
} __packed; } __packed;
#define BT_L2CAP_DISCONN_REQ 0x06 #define BT_L2CAP_DISCONN_REQ 0x06
struct bt_l2cap_disconn_req { struct bt_l2cap_disconn_req {
uint16_t dcid; u16_t dcid;
uint16_t scid; u16_t scid;
} __packed; } __packed;
#define BT_L2CAP_DISCONN_RSP 0x07 #define BT_L2CAP_DISCONN_RSP 0x07
struct bt_l2cap_disconn_rsp { struct bt_l2cap_disconn_rsp {
uint16_t dcid; u16_t dcid;
uint16_t scid; u16_t scid;
} __packed; } __packed;
#define BT_L2CAP_INFO_FEAT_MASK 0x0002 #define BT_L2CAP_INFO_FEAT_MASK 0x0002
@ -124,7 +124,7 @@ struct bt_l2cap_disconn_rsp {
#define BT_L2CAP_INFO_REQ 0x0a #define BT_L2CAP_INFO_REQ 0x0a
struct bt_l2cap_info_req { struct bt_l2cap_info_req {
uint16_t type; u16_t type;
} __packed; } __packed;
/* info result */ /* info result */
@ -133,17 +133,17 @@ struct bt_l2cap_info_req {
#define BT_L2CAP_INFO_RSP 0x0b #define BT_L2CAP_INFO_RSP 0x0b
struct bt_l2cap_info_rsp { struct bt_l2cap_info_rsp {
uint16_t type; u16_t type;
uint16_t result; u16_t result;
uint8_t data[0]; u8_t data[0];
} __packed; } __packed;
#define BT_L2CAP_CONN_PARAM_REQ 0x12 #define BT_L2CAP_CONN_PARAM_REQ 0x12
struct bt_l2cap_conn_param_req { struct bt_l2cap_conn_param_req {
uint16_t min_interval; u16_t min_interval;
uint16_t max_interval; u16_t max_interval;
uint16_t latency; u16_t latency;
uint16_t timeout; u16_t timeout;
} __packed; } __packed;
#define BT_L2CAP_CONN_PARAM_ACCEPTED 0x0000 #define BT_L2CAP_CONN_PARAM_ACCEPTED 0x0000
@ -151,16 +151,16 @@ struct bt_l2cap_conn_param_req {
#define BT_L2CAP_CONN_PARAM_RSP 0x13 #define BT_L2CAP_CONN_PARAM_RSP 0x13
struct bt_l2cap_conn_param_rsp { struct bt_l2cap_conn_param_rsp {
uint16_t result; u16_t result;
} __packed; } __packed;
#define BT_L2CAP_LE_CONN_REQ 0x14 #define BT_L2CAP_LE_CONN_REQ 0x14
struct bt_l2cap_le_conn_req { struct bt_l2cap_le_conn_req {
uint16_t psm; u16_t psm;
uint16_t scid; u16_t scid;
uint16_t mtu; u16_t mtu;
uint16_t mps; u16_t mps;
uint16_t credits; u16_t credits;
} __packed; } __packed;
#define BT_L2CAP_SUCCESS 0x0000 #define BT_L2CAP_SUCCESS 0x0000
@ -177,17 +177,17 @@ struct bt_l2cap_le_conn_req {
#define BT_L2CAP_LE_CONN_RSP 0x15 #define BT_L2CAP_LE_CONN_RSP 0x15
struct bt_l2cap_le_conn_rsp { struct bt_l2cap_le_conn_rsp {
uint16_t dcid; u16_t dcid;
uint16_t mtu; u16_t mtu;
uint16_t mps; u16_t mps;
uint16_t credits; u16_t credits;
uint16_t result; u16_t result;
}; };
#define BT_L2CAP_LE_CREDITS 0x16 #define BT_L2CAP_LE_CREDITS 0x16
struct bt_l2cap_le_credits { struct bt_l2cap_le_credits {
uint16_t cid; u16_t cid;
uint16_t credits; u16_t credits;
} __packed; } __packed;
#define BT_L2CAP_SDU_HDR_LEN 2 #define BT_L2CAP_SDU_HDR_LEN 2
@ -196,7 +196,7 @@ struct bt_l2cap_le_credits {
BT_HCI_ACL_HDR_SIZE - BT_L2CAP_HDR_SIZE) BT_HCI_ACL_HDR_SIZE - BT_L2CAP_HDR_SIZE)
struct bt_l2cap_fixed_chan { struct bt_l2cap_fixed_chan {
uint16_t cid; u16_t cid;
int (*accept)(struct bt_conn *conn, struct bt_l2cap_chan **chan); int (*accept)(struct bt_conn *conn, struct bt_l2cap_chan **chan);
sys_snode_t node; sys_snode_t node;
@ -238,7 +238,7 @@ void bt_l2cap_chan_set_state(struct bt_l2cap_chan *chan,
* Notify L2CAP channels of a change in encryption state passing additionally * Notify L2CAP channels of a change in encryption state passing additionally
* HCI status of performed security procedure. * HCI status of performed security procedure.
*/ */
void bt_l2cap_encrypt_change(struct bt_conn *conn, uint8_t hci_status); void bt_l2cap_encrypt_change(struct bt_conn *conn, u8_t hci_status);
/* Prepare an L2CAP PDU to be sent over a connection */ /* Prepare an L2CAP PDU to be sent over a connection */
struct net_buf *bt_l2cap_create_pdu(struct net_buf_pool *pool, size_t reserve); struct net_buf *bt_l2cap_create_pdu(struct net_buf_pool *pool, size_t reserve);
@ -247,10 +247,10 @@ struct net_buf *bt_l2cap_create_pdu(struct net_buf_pool *pool, size_t reserve);
struct net_buf *bt_l2cap_create_rsp(struct net_buf *buf, size_t reserve); struct net_buf *bt_l2cap_create_rsp(struct net_buf *buf, size_t reserve);
/* Send L2CAP PDU over a connection */ /* Send L2CAP PDU over a connection */
void bt_l2cap_send_cb(struct bt_conn *conn, uint16_t cid, struct net_buf *buf, void bt_l2cap_send_cb(struct bt_conn *conn, u16_t cid, struct net_buf *buf,
bt_conn_tx_cb_t cb); bt_conn_tx_cb_t cb);
static inline void bt_l2cap_send(struct bt_conn *conn, uint16_t cid, static inline void bt_l2cap_send(struct bt_conn *conn, u16_t cid,
struct net_buf *buf) struct net_buf *buf)
{ {
bt_l2cap_send_cb(conn, cid, buf, NULL); bt_l2cap_send_cb(conn, cid, buf, NULL);
@ -268,11 +268,11 @@ void bt_l2cap_init(void);
/* Lookup channel by Transmission CID */ /* Lookup channel by Transmission CID */
struct bt_l2cap_chan *bt_l2cap_le_lookup_tx_cid(struct bt_conn *conn, struct bt_l2cap_chan *bt_l2cap_le_lookup_tx_cid(struct bt_conn *conn,
uint16_t cid); u16_t cid);
/* Lookup channel by Receiver CID */ /* Lookup channel by Receiver CID */
struct bt_l2cap_chan *bt_l2cap_le_lookup_rx_cid(struct bt_conn *conn, struct bt_l2cap_chan *bt_l2cap_le_lookup_rx_cid(struct bt_conn *conn,
uint16_t cid); u16_t cid);
/* Initialize BR/EDR L2CAP signal layer */ /* Initialize BR/EDR L2CAP signal layer */
void bt_l2cap_br_init(void); void bt_l2cap_br_init(void);
@ -285,14 +285,14 @@ void bt_l2cap_br_connected(struct bt_conn *conn);
/* Lookup BR/EDR L2CAP channel by Receiver CID */ /* Lookup BR/EDR L2CAP channel by Receiver CID */
struct bt_l2cap_chan *bt_l2cap_br_lookup_rx_cid(struct bt_conn *conn, struct bt_l2cap_chan *bt_l2cap_br_lookup_rx_cid(struct bt_conn *conn,
uint16_t cid); u16_t cid);
/* Disconnects dynamic channel */ /* Disconnects dynamic channel */
int bt_l2cap_br_chan_disconnect(struct bt_l2cap_chan *chan); int bt_l2cap_br_chan_disconnect(struct bt_l2cap_chan *chan);
/* Make connection to peer psm server */ /* Make connection to peer psm server */
int bt_l2cap_br_chan_connect(struct bt_conn *conn, struct bt_l2cap_chan *chan, int bt_l2cap_br_chan_connect(struct bt_conn *conn, struct bt_l2cap_chan *chan,
uint16_t psm); u16_t psm);
/* Send packet data to connected peer */ /* Send packet data to connected peer */
int bt_l2cap_br_chan_send(struct bt_l2cap_chan *chan, struct net_buf *buf); int bt_l2cap_br_chan_send(struct bt_l2cap_chan *chan, struct net_buf *buf);
@ -301,7 +301,7 @@ int bt_l2cap_br_chan_send(struct bt_l2cap_chan *chan, struct net_buf *buf);
* Handle security level changed on link passing HCI status of performed * Handle security level changed on link passing HCI status of performed
* security procedure. * security procedure.
*/ */
void l2cap_br_encrypt_change(struct bt_conn *conn, uint8_t hci_status); void l2cap_br_encrypt_change(struct bt_conn *conn, u8_t hci_status);
/* Handle received data */ /* Handle received data */
void bt_l2cap_br_recv(struct bt_conn *conn, struct net_buf *buf); void bt_l2cap_br_recv(struct bt_conn *conn, struct net_buf *buf);

View file

@ -20,8 +20,8 @@ const char *bt_hex(const void *buf, size_t len)
{ {
static const char hex[] = "0123456789abcdef"; static const char hex[] = "0123456789abcdef";
static char hexbufs[4][129]; static char hexbufs[4][129];
static uint8_t curbuf; static u8_t curbuf;
const uint8_t *b = buf; const u8_t *b = buf;
unsigned int mask; unsigned int mask;
char *str; char *str;
int i; int i;

View file

@ -54,14 +54,14 @@ extern int _prf(int (*func)(), void *dest,
static void monitor_send(const void *data, size_t len) static void monitor_send(const void *data, size_t len)
{ {
const uint8_t *buf = data; const u8_t *buf = data;
while (len--) { while (len--) {
uart_poll_out(monitor_dev, *buf++); uart_poll_out(monitor_dev, *buf++);
} }
} }
static void encode_drops(struct bt_monitor_hdr *hdr, uint8_t type, static void encode_drops(struct bt_monitor_hdr *hdr, u8_t type,
atomic_t *val) atomic_t *val)
{ {
atomic_val_t count; atomic_val_t count;
@ -73,8 +73,8 @@ static void encode_drops(struct bt_monitor_hdr *hdr, uint8_t type,
} }
} }
static inline void encode_hdr(struct bt_monitor_hdr *hdr, uint16_t opcode, static inline void encode_hdr(struct bt_monitor_hdr *hdr, u16_t opcode,
uint16_t len) u16_t len)
{ {
struct bt_monitor_ts32 *ts; struct bt_monitor_ts32 *ts;
@ -105,7 +105,7 @@ static int log_out(int c, void *unused)
return 0; return 0;
} }
static void drop_add(uint16_t opcode) static void drop_add(u16_t opcode)
{ {
switch (opcode) { switch (opcode) {
case BT_MONITOR_COMMAND_PKT: case BT_MONITOR_COMMAND_PKT:
@ -175,7 +175,7 @@ void bt_log(int prio, const char *fmt, ...)
atomic_clear_bit(&flags, BT_LOG_BUSY); atomic_clear_bit(&flags, BT_LOG_BUSY);
} }
void bt_monitor_send(uint16_t opcode, const void *data, size_t len) void bt_monitor_send(u16_t opcode, const void *data, size_t len)
{ {
struct bt_monitor_hdr hdr; struct bt_monitor_hdr hdr;
@ -192,7 +192,7 @@ void bt_monitor_send(uint16_t opcode, const void *data, size_t len)
atomic_clear_bit(&flags, BT_LOG_BUSY); atomic_clear_bit(&flags, BT_LOG_BUSY);
} }
void bt_monitor_new_index(uint8_t type, uint8_t bus, bt_addr_t *addr, void bt_monitor_new_index(u8_t type, u8_t bus, bt_addr_t *addr,
const char *name) const char *name)
{ {
struct bt_monitor_new_index pkt; struct bt_monitor_new_index pkt;

View file

@ -48,32 +48,32 @@
#endif #endif
struct bt_monitor_hdr { struct bt_monitor_hdr {
uint16_t data_len; u16_t data_len;
uint16_t opcode; u16_t opcode;
uint8_t flags; u8_t flags;
uint8_t hdr_len; u8_t hdr_len;
uint8_t ext[BT_MONITOR_EXT_HDR_MAX]; u8_t ext[BT_MONITOR_EXT_HDR_MAX];
} __packed; } __packed;
struct bt_monitor_ts32 { struct bt_monitor_ts32 {
uint8_t type; u8_t type;
uint32_t ts32; u32_t ts32;
} __packed; } __packed;
struct bt_monitor_new_index { struct bt_monitor_new_index {
uint8_t type; u8_t type;
uint8_t bus; u8_t bus;
uint8_t bdaddr[6]; u8_t bdaddr[6];
char name[8]; char name[8];
} __packed; } __packed;
struct bt_monitor_user_logging { struct bt_monitor_user_logging {
uint8_t priority; u8_t priority;
uint8_t ident_len; u8_t ident_len;
} __packed; } __packed;
static inline uint8_t bt_monitor_opcode(struct net_buf *buf) static inline u8_t bt_monitor_opcode(struct net_buf *buf)
{ {
switch (bt_buf_get_type(buf)) { switch (bt_buf_get_type(buf)) {
case BT_BUF_CMD: case BT_BUF_CMD:
@ -89,9 +89,9 @@ static inline uint8_t bt_monitor_opcode(struct net_buf *buf)
} }
} }
void bt_monitor_send(uint16_t opcode, const void *data, size_t len); void bt_monitor_send(u16_t opcode, const void *data, size_t len);
void bt_monitor_new_index(uint8_t type, uint8_t bus, bt_addr_t *addr, void bt_monitor_new_index(u8_t type, u8_t bus, bt_addr_t *addr,
const char *name); const char *name);
#else /* !CONFIG_BLUETOOTH_DEBUG_MONITOR */ #else /* !CONFIG_BLUETOOTH_DEBUG_MONITOR */

View file

@ -57,7 +57,7 @@ NET_BUF_POOL_DEFINE(dummy_pool, CONFIG_BLUETOOTH_MAX_CONN, 0, 0, NULL);
static struct bt_rfcomm_session bt_rfcomm_pool[CONFIG_BLUETOOTH_MAX_CONN]; static struct bt_rfcomm_session bt_rfcomm_pool[CONFIG_BLUETOOTH_MAX_CONN];
/* reversed, 8-bit, poly=0x07 */ /* reversed, 8-bit, poly=0x07 */
static const uint8_t rfcomm_crc_table[256] = { static const u8_t rfcomm_crc_table[256] = {
0x00, 0x91, 0xe3, 0x72, 0x07, 0x96, 0xe4, 0x75, 0x00, 0x91, 0xe3, 0x72, 0x07, 0x96, 0xe4, 0x75,
0x0e, 0x9f, 0xed, 0x7c, 0x09, 0x98, 0xea, 0x7b, 0x0e, 0x9f, 0xed, 0x7c, 0x09, 0x98, 0xea, 0x7b,
0x1c, 0x8d, 0xff, 0x6e, 0x1b, 0x8a, 0xf8, 0x69, 0x1c, 0x8d, 0xff, 0x6e, 0x1b, 0x8a, 0xf8, 0x69,
@ -99,9 +99,9 @@ static const uint8_t rfcomm_crc_table[256] = {
0xba, 0x2b, 0x59, 0xc8, 0xbd, 0x2c, 0x5e, 0xcf 0xba, 0x2b, 0x59, 0xc8, 0xbd, 0x2c, 0x5e, 0xcf
}; };
static uint8_t rfcomm_calc_fcs(uint16_t len, const uint8_t *data) static u8_t rfcomm_calc_fcs(u16_t len, const u8_t *data)
{ {
uint8_t fcs = 0xff; u8_t fcs = 0xff;
while (len--) { while (len--) {
fcs = rfcomm_crc_table[fcs ^ *data++]; fcs = rfcomm_crc_table[fcs ^ *data++];
@ -111,10 +111,10 @@ static uint8_t rfcomm_calc_fcs(uint16_t len, const uint8_t *data)
return (0xff - fcs); return (0xff - fcs);
} }
static bool rfcomm_check_fcs(uint16_t len, const uint8_t *data, static bool rfcomm_check_fcs(u16_t len, const u8_t *data,
uint8_t recvd_fcs) u8_t recvd_fcs)
{ {
uint8_t fcs = 0xff; u8_t fcs = 0xff;
while (len--) { while (len--) {
fcs = rfcomm_crc_table[fcs ^ *data++]; fcs = rfcomm_crc_table[fcs ^ *data++];
@ -128,7 +128,7 @@ static bool rfcomm_check_fcs(uint16_t len, const uint8_t *data,
} }
static struct bt_rfcomm_dlc *rfcomm_dlcs_lookup_dlci(struct bt_rfcomm_dlc *dlcs, static struct bt_rfcomm_dlc *rfcomm_dlcs_lookup_dlci(struct bt_rfcomm_dlc *dlcs,
uint8_t dlci) u8_t dlci)
{ {
for (; dlcs; dlcs = dlcs->_next) { for (; dlcs; dlcs = dlcs->_next) {
if (dlcs->dlci == dlci) { if (dlcs->dlci == dlci) {
@ -140,7 +140,7 @@ static struct bt_rfcomm_dlc *rfcomm_dlcs_lookup_dlci(struct bt_rfcomm_dlc *dlcs,
} }
static struct bt_rfcomm_dlc *rfcomm_dlcs_remove_dlci(struct bt_rfcomm_dlc *dlcs, static struct bt_rfcomm_dlc *rfcomm_dlcs_remove_dlci(struct bt_rfcomm_dlc *dlcs,
uint8_t dlci) u8_t dlci)
{ {
struct bt_rfcomm_dlc *tmp; struct bt_rfcomm_dlc *tmp;
@ -165,7 +165,7 @@ static struct bt_rfcomm_dlc *rfcomm_dlcs_remove_dlci(struct bt_rfcomm_dlc *dlcs,
return NULL; return NULL;
} }
static struct bt_rfcomm_server *rfcomm_server_lookup_channel(uint8_t channel) static struct bt_rfcomm_server *rfcomm_server_lookup_channel(u8_t channel)
{ {
struct bt_rfcomm_server *server; struct bt_rfcomm_server *server;
@ -216,7 +216,7 @@ int bt_rfcomm_server_register(struct bt_rfcomm_server *server)
} }
static void rfcomm_dlc_tx_give_credits(struct bt_rfcomm_dlc *dlc, static void rfcomm_dlc_tx_give_credits(struct bt_rfcomm_dlc *dlc,
uint8_t credits) u8_t credits)
{ {
BT_DBG("dlc %p credits %u", dlc, credits); BT_DBG("dlc %p credits %u", dlc, credits);
@ -245,7 +245,7 @@ static void rfcomm_dlc_destroy(struct bt_rfcomm_dlc *dlc)
static void rfcomm_dlc_disconnect(struct bt_rfcomm_dlc *dlc) static void rfcomm_dlc_disconnect(struct bt_rfcomm_dlc *dlc)
{ {
uint8_t old_state = dlc->state; u8_t old_state = dlc->state;
BT_DBG("dlc %p", dlc); BT_DBG("dlc %p", dlc);
@ -311,11 +311,11 @@ struct net_buf *bt_rfcomm_create_pdu(struct net_buf_pool *pool)
sizeof(struct bt_rfcomm_hdr) + 1); sizeof(struct bt_rfcomm_hdr) + 1);
} }
static int rfcomm_send_sabm(struct bt_rfcomm_session *session, uint8_t dlci) static int rfcomm_send_sabm(struct bt_rfcomm_session *session, u8_t dlci)
{ {
struct bt_rfcomm_hdr *hdr; struct bt_rfcomm_hdr *hdr;
struct net_buf *buf; struct net_buf *buf;
uint8_t cr, fcs; u8_t cr, fcs;
buf = bt_l2cap_create_pdu(NULL, 0); buf = bt_l2cap_create_pdu(NULL, 0);
@ -331,11 +331,11 @@ static int rfcomm_send_sabm(struct bt_rfcomm_session *session, uint8_t dlci)
return bt_l2cap_chan_send(&session->br_chan.chan, buf); return bt_l2cap_chan_send(&session->br_chan.chan, buf);
} }
static int rfcomm_send_disc(struct bt_rfcomm_session *session, uint8_t dlci) static int rfcomm_send_disc(struct bt_rfcomm_session *session, u8_t dlci)
{ {
struct bt_rfcomm_hdr *hdr; struct bt_rfcomm_hdr *hdr;
struct net_buf *buf; struct net_buf *buf;
uint8_t fcs, cr; u8_t fcs, cr;
BT_DBG("dlci %d", dlci); BT_DBG("dlci %d", dlci);
@ -364,13 +364,13 @@ static void rfcomm_session_disconnect(struct bt_rfcomm_session *session)
} }
static struct net_buf *rfcomm_make_uih_msg(struct bt_rfcomm_session *session, static struct net_buf *rfcomm_make_uih_msg(struct bt_rfcomm_session *session,
uint8_t cr, uint8_t type, u8_t cr, u8_t type,
uint8_t len) u8_t len)
{ {
struct bt_rfcomm_hdr *hdr; struct bt_rfcomm_hdr *hdr;
struct bt_rfcomm_msg_hdr *msg_hdr; struct bt_rfcomm_msg_hdr *msg_hdr;
struct net_buf *buf; struct net_buf *buf;
uint8_t hdr_cr; u8_t hdr_cr;
buf = bt_l2cap_create_pdu(NULL, 0); buf = bt_l2cap_create_pdu(NULL, 0);
@ -428,7 +428,7 @@ static void rfcomm_dlc_rtx_timeout(struct k_work *work)
static void rfcomm_dlc_init(struct bt_rfcomm_dlc *dlc, static void rfcomm_dlc_init(struct bt_rfcomm_dlc *dlc,
struct bt_rfcomm_session *session, struct bt_rfcomm_session *session,
uint8_t dlci, u8_t dlci,
bt_rfcomm_role_t role) bt_rfcomm_role_t role)
{ {
BT_DBG("dlc %p", dlc); BT_DBG("dlc %p", dlc);
@ -448,11 +448,11 @@ static void rfcomm_dlc_init(struct bt_rfcomm_dlc *dlc,
} }
static struct bt_rfcomm_dlc *rfcomm_dlc_accept(struct bt_rfcomm_session *session, static struct bt_rfcomm_dlc *rfcomm_dlc_accept(struct bt_rfcomm_session *session,
uint8_t dlci) u8_t dlci)
{ {
struct bt_rfcomm_server *server; struct bt_rfcomm_server *server;
struct bt_rfcomm_dlc *dlc; struct bt_rfcomm_dlc *dlc;
uint8_t channel; u8_t channel;
channel = BT_RFCOMM_GET_CHANNEL(dlci); channel = BT_RFCOMM_GET_CHANNEL(dlci);
server = rfcomm_server_lookup_channel(channel); server = rfcomm_server_lookup_channel(channel);
@ -477,11 +477,11 @@ static struct bt_rfcomm_dlc *rfcomm_dlc_accept(struct bt_rfcomm_session *session
return dlc; return dlc;
} }
static int rfcomm_send_dm(struct bt_rfcomm_session *session, uint8_t dlci) static int rfcomm_send_dm(struct bt_rfcomm_session *session, u8_t dlci)
{ {
struct bt_rfcomm_hdr *hdr; struct bt_rfcomm_hdr *hdr;
struct net_buf *buf; struct net_buf *buf;
uint8_t fcs, cr; u8_t fcs, cr;
BT_DBG("dlci %d", dlci); BT_DBG("dlci %d", dlci);
@ -525,7 +525,7 @@ static void rfcomm_check_fc(struct bt_rfcomm_dlc *dlc)
static void rfcomm_dlc_tx_thread(void *p1, void *p2, void *p3) static void rfcomm_dlc_tx_thread(void *p1, void *p2, void *p3)
{ {
struct bt_rfcomm_dlc *dlc = p1; struct bt_rfcomm_dlc *dlc = p1;
int32_t timeout = K_FOREVER; s32_t timeout = K_FOREVER;
struct net_buf *buf; struct net_buf *buf;
BT_DBG("Started for dlc %p", dlc); BT_DBG("Started for dlc %p", dlc);
@ -585,11 +585,11 @@ static void rfcomm_dlc_tx_thread(void *p1, void *p2, void *p3)
BT_DBG("dlc %p exiting", dlc); BT_DBG("dlc %p exiting", dlc);
} }
static int rfcomm_send_ua(struct bt_rfcomm_session *session, uint8_t dlci) static int rfcomm_send_ua(struct bt_rfcomm_session *session, u8_t dlci)
{ {
struct bt_rfcomm_hdr *hdr; struct bt_rfcomm_hdr *hdr;
struct net_buf *buf; struct net_buf *buf;
uint8_t cr, fcs; u8_t cr, fcs;
buf = bt_l2cap_create_pdu(NULL, 0); buf = bt_l2cap_create_pdu(NULL, 0);
@ -605,12 +605,12 @@ static int rfcomm_send_ua(struct bt_rfcomm_session *session, uint8_t dlci)
return bt_l2cap_chan_send(&session->br_chan.chan, buf); return bt_l2cap_chan_send(&session->br_chan.chan, buf);
} }
static int rfcomm_send_msc(struct bt_rfcomm_dlc *dlc, uint8_t cr, static int rfcomm_send_msc(struct bt_rfcomm_dlc *dlc, u8_t cr,
uint8_t v24_signal) u8_t v24_signal)
{ {
struct bt_rfcomm_msc *msc; struct bt_rfcomm_msc *msc;
struct net_buf *buf; struct net_buf *buf;
uint8_t fcs; u8_t fcs;
buf = rfcomm_make_uih_msg(dlc->session, cr, BT_RFCOMM_MSC, buf = rfcomm_make_uih_msg(dlc->session, cr, BT_RFCOMM_MSC,
sizeof(*msc)); sizeof(*msc));
@ -626,12 +626,12 @@ static int rfcomm_send_msc(struct bt_rfcomm_dlc *dlc, uint8_t cr,
return bt_l2cap_chan_send(&dlc->session->br_chan.chan, buf); return bt_l2cap_chan_send(&dlc->session->br_chan.chan, buf);
} }
static int rfcomm_send_rls(struct bt_rfcomm_dlc *dlc, uint8_t cr, static int rfcomm_send_rls(struct bt_rfcomm_dlc *dlc, u8_t cr,
uint8_t line_status) u8_t line_status)
{ {
struct bt_rfcomm_rls *rls; struct bt_rfcomm_rls *rls;
struct net_buf *buf; struct net_buf *buf;
uint8_t fcs; u8_t fcs;
buf = rfcomm_make_uih_msg(dlc->session, cr, BT_RFCOMM_RLS, buf = rfcomm_make_uih_msg(dlc->session, cr, BT_RFCOMM_RLS,
sizeof(*rls)); sizeof(*rls));
@ -647,11 +647,11 @@ static int rfcomm_send_rls(struct bt_rfcomm_dlc *dlc, uint8_t cr,
return bt_l2cap_chan_send(&dlc->session->br_chan.chan, buf); return bt_l2cap_chan_send(&dlc->session->br_chan.chan, buf);
} }
static int rfcomm_send_rpn(struct bt_rfcomm_session *session, uint8_t cr, static int rfcomm_send_rpn(struct bt_rfcomm_session *session, u8_t cr,
struct bt_rfcomm_rpn *rpn) struct bt_rfcomm_rpn *rpn)
{ {
struct net_buf *buf; struct net_buf *buf;
uint8_t fcs; u8_t fcs;
buf = rfcomm_make_uih_msg(session, cr, BT_RFCOMM_RPN, sizeof(*rpn)); buf = rfcomm_make_uih_msg(session, cr, BT_RFCOMM_RPN, sizeof(*rpn));
@ -663,11 +663,11 @@ static int rfcomm_send_rpn(struct bt_rfcomm_session *session, uint8_t cr,
return bt_l2cap_chan_send(&session->br_chan.chan, buf); return bt_l2cap_chan_send(&session->br_chan.chan, buf);
} }
static int rfcomm_send_test(struct bt_rfcomm_session *session, uint8_t cr, static int rfcomm_send_test(struct bt_rfcomm_session *session, u8_t cr,
uint8_t *pattern, uint8_t len) u8_t *pattern, u8_t len)
{ {
struct net_buf *buf; struct net_buf *buf;
uint8_t fcs; u8_t fcs;
buf = rfcomm_make_uih_msg(session, cr, BT_RFCOMM_TEST, len); buf = rfcomm_make_uih_msg(session, cr, BT_RFCOMM_TEST, len);
@ -679,10 +679,10 @@ static int rfcomm_send_test(struct bt_rfcomm_session *session, uint8_t cr,
return bt_l2cap_chan_send(&session->br_chan.chan, buf); return bt_l2cap_chan_send(&session->br_chan.chan, buf);
} }
static int rfcomm_send_nsc(struct bt_rfcomm_session *session, uint8_t cmd_type) static int rfcomm_send_nsc(struct bt_rfcomm_session *session, u8_t cmd_type)
{ {
struct net_buf *buf; struct net_buf *buf;
uint8_t fcs; u8_t fcs;
buf = rfcomm_make_uih_msg(session, BT_RFCOMM_MSG_RESP_CR, buf = rfcomm_make_uih_msg(session, BT_RFCOMM_MSG_RESP_CR,
BT_RFCOMM_NSC, sizeof(cmd_type)); BT_RFCOMM_NSC, sizeof(cmd_type));
@ -695,10 +695,10 @@ static int rfcomm_send_nsc(struct bt_rfcomm_session *session, uint8_t cmd_type)
return bt_l2cap_chan_send(&session->br_chan.chan, buf); return bt_l2cap_chan_send(&session->br_chan.chan, buf);
} }
static int rfcomm_send_fcon(struct bt_rfcomm_session *session, uint8_t cr) static int rfcomm_send_fcon(struct bt_rfcomm_session *session, u8_t cr)
{ {
struct net_buf *buf; struct net_buf *buf;
uint8_t fcs; u8_t fcs;
buf = rfcomm_make_uih_msg(session, cr, BT_RFCOMM_FCON, 0); buf = rfcomm_make_uih_msg(session, cr, BT_RFCOMM_FCON, 0);
@ -708,10 +708,10 @@ static int rfcomm_send_fcon(struct bt_rfcomm_session *session, uint8_t cr)
return bt_l2cap_chan_send(&session->br_chan.chan, buf); return bt_l2cap_chan_send(&session->br_chan.chan, buf);
} }
static int rfcomm_send_fcoff(struct bt_rfcomm_session *session, uint8_t cr) static int rfcomm_send_fcoff(struct bt_rfcomm_session *session, u8_t cr)
{ {
struct net_buf *buf; struct net_buf *buf;
uint8_t fcs; u8_t fcs;
buf = rfcomm_make_uih_msg(session, cr, BT_RFCOMM_FCOFF, 0); buf = rfcomm_make_uih_msg(session, cr, BT_RFCOMM_FCOFF, 0);
@ -835,7 +835,7 @@ static int rfcomm_dlc_close(struct bt_rfcomm_dlc *dlc)
return 0; return 0;
} }
static void rfcomm_handle_sabm(struct bt_rfcomm_session *session, uint8_t dlci) static void rfcomm_handle_sabm(struct bt_rfcomm_session *session, u8_t dlci)
{ {
if (!dlci) { if (!dlci) {
if (rfcomm_send_ua(session, dlci) < 0) { if (rfcomm_send_ua(session, dlci) < 0) {
@ -881,11 +881,11 @@ static void rfcomm_handle_sabm(struct bt_rfcomm_session *session, uint8_t dlci)
} }
} }
static int rfcomm_send_pn(struct bt_rfcomm_dlc *dlc, uint8_t cr) static int rfcomm_send_pn(struct bt_rfcomm_dlc *dlc, u8_t cr)
{ {
struct bt_rfcomm_pn *pn; struct bt_rfcomm_pn *pn;
struct net_buf *buf; struct net_buf *buf;
uint8_t fcs; u8_t fcs;
buf = rfcomm_make_uih_msg(dlc->session, cr, BT_RFCOMM_PN, sizeof(*pn)); buf = rfcomm_make_uih_msg(dlc->session, cr, BT_RFCOMM_PN, sizeof(*pn));
@ -920,11 +920,11 @@ static int rfcomm_send_pn(struct bt_rfcomm_dlc *dlc, uint8_t cr)
return bt_l2cap_chan_send(&dlc->session->br_chan.chan, buf); return bt_l2cap_chan_send(&dlc->session->br_chan.chan, buf);
} }
static int rfcomm_send_credit(struct bt_rfcomm_dlc *dlc, uint8_t credits) static int rfcomm_send_credit(struct bt_rfcomm_dlc *dlc, u8_t credits)
{ {
struct bt_rfcomm_hdr *hdr; struct bt_rfcomm_hdr *hdr;
struct net_buf *buf; struct net_buf *buf;
uint8_t fcs, cr; u8_t fcs, cr;
BT_DBG("Dlc %p credits %d", dlc, credits); BT_DBG("Dlc %p credits %d", dlc, credits);
@ -967,7 +967,7 @@ static int rfcomm_dlc_start(struct bt_rfcomm_dlc *dlc)
return 0; return 0;
} }
static void rfcomm_handle_ua(struct bt_rfcomm_session *session, uint8_t dlci) static void rfcomm_handle_ua(struct bt_rfcomm_session *session, u8_t dlci)
{ {
struct bt_rfcomm_dlc *dlc, *next; struct bt_rfcomm_dlc *dlc, *next;
int err; int err;
@ -1020,7 +1020,7 @@ static void rfcomm_handle_ua(struct bt_rfcomm_session *session, uint8_t dlci)
} }
} }
static void rfcomm_handle_dm(struct bt_rfcomm_session *session, uint8_t dlci) static void rfcomm_handle_dm(struct bt_rfcomm_session *session, u8_t dlci)
{ {
struct bt_rfcomm_dlc *dlc; struct bt_rfcomm_dlc *dlc;
@ -1036,11 +1036,11 @@ static void rfcomm_handle_dm(struct bt_rfcomm_session *session, uint8_t dlci)
} }
static void rfcomm_handle_msc(struct bt_rfcomm_session *session, static void rfcomm_handle_msc(struct bt_rfcomm_session *session,
struct net_buf *buf, uint8_t cr) struct net_buf *buf, u8_t cr)
{ {
struct bt_rfcomm_msc *msc = (void *)buf->data; struct bt_rfcomm_msc *msc = (void *)buf->data;
struct bt_rfcomm_dlc *dlc; struct bt_rfcomm_dlc *dlc;
uint8_t dlci = BT_RFCOMM_GET_DLCI(msc->dlci); u8_t dlci = BT_RFCOMM_GET_DLCI(msc->dlci);
BT_DBG("dlci %d", dlci); BT_DBG("dlci %d", dlci);
@ -1076,10 +1076,10 @@ static void rfcomm_handle_msc(struct bt_rfcomm_session *session,
} }
static void rfcomm_handle_rls(struct bt_rfcomm_session *session, static void rfcomm_handle_rls(struct bt_rfcomm_session *session,
struct net_buf *buf, uint8_t cr) struct net_buf *buf, u8_t cr)
{ {
struct bt_rfcomm_rls *rls = (void *)buf->data; struct bt_rfcomm_rls *rls = (void *)buf->data;
uint8_t dlci = BT_RFCOMM_GET_DLCI(rls->dlci); u8_t dlci = BT_RFCOMM_GET_DLCI(rls->dlci);
struct bt_rfcomm_dlc *dlc; struct bt_rfcomm_dlc *dlc;
BT_DBG("dlci %d", dlci); BT_DBG("dlci %d", dlci);
@ -1099,13 +1099,13 @@ static void rfcomm_handle_rls(struct bt_rfcomm_session *session,
} }
static void rfcomm_handle_rpn(struct bt_rfcomm_session *session, static void rfcomm_handle_rpn(struct bt_rfcomm_session *session,
struct net_buf *buf, uint8_t cr) struct net_buf *buf, u8_t cr)
{ {
struct bt_rfcomm_rpn default_rpn, *rpn = (void *)buf->data; struct bt_rfcomm_rpn default_rpn, *rpn = (void *)buf->data;
uint8_t dlci = BT_RFCOMM_GET_DLCI(rpn->dlci); u8_t dlci = BT_RFCOMM_GET_DLCI(rpn->dlci);
uint8_t data_bits, stop_bits, parity_bits; u8_t data_bits, stop_bits, parity_bits;
/* Exclude fcs to get number of value bytes */ /* Exclude fcs to get number of value bytes */
uint8_t value_len = buf->len - 1; u8_t value_len = buf->len - 1;
BT_DBG("dlci %d", dlci); BT_DBG("dlci %d", dlci);
@ -1145,7 +1145,7 @@ static void rfcomm_handle_rpn(struct bt_rfcomm_session *session,
} }
static void rfcomm_handle_pn(struct bt_rfcomm_session *session, static void rfcomm_handle_pn(struct bt_rfcomm_session *session,
struct net_buf *buf, uint8_t cr) struct net_buf *buf, u8_t cr)
{ {
struct bt_rfcomm_pn *pn = (void *)buf->data; struct bt_rfcomm_pn *pn = (void *)buf->data;
struct bt_rfcomm_dlc *dlc; struct bt_rfcomm_dlc *dlc;
@ -1219,7 +1219,7 @@ static void rfcomm_handle_pn(struct bt_rfcomm_session *session,
} }
} }
static void rfcomm_handle_disc(struct bt_rfcomm_session *session, uint8_t dlci) static void rfcomm_handle_disc(struct bt_rfcomm_session *session, u8_t dlci)
{ {
struct bt_rfcomm_dlc *dlc; struct bt_rfcomm_dlc *dlc;
@ -1252,7 +1252,7 @@ static void rfcomm_handle_msg(struct bt_rfcomm_session *session,
struct net_buf *buf) struct net_buf *buf)
{ {
struct bt_rfcomm_msg_hdr *hdr = (void *)buf->data; struct bt_rfcomm_msg_hdr *hdr = (void *)buf->data;
uint8_t msg_type, len, cr; u8_t msg_type, len, cr;
msg_type = BT_RFCOMM_GET_MSG_TYPE(hdr->type); msg_type = BT_RFCOMM_GET_MSG_TYPE(hdr->type);
cr = BT_RFCOMM_GET_MSG_CR(hdr->type); cr = BT_RFCOMM_GET_MSG_CR(hdr->type);
@ -1326,7 +1326,7 @@ static void rfcomm_handle_msg(struct bt_rfcomm_session *session,
static void rfcomm_dlc_update_credits(struct bt_rfcomm_dlc *dlc) static void rfcomm_dlc_update_credits(struct bt_rfcomm_dlc *dlc)
{ {
uint8_t credits; u8_t credits;
if (dlc->session->cfc == BT_RFCOMM_CFC_NOT_SUPPORTED) { if (dlc->session->cfc == BT_RFCOMM_CFC_NOT_SUPPORTED) {
return; return;
@ -1347,7 +1347,7 @@ static void rfcomm_dlc_update_credits(struct bt_rfcomm_dlc *dlc)
} }
static void rfcomm_handle_data(struct bt_rfcomm_session *session, static void rfcomm_handle_data(struct bt_rfcomm_session *session,
struct net_buf *buf, uint8_t dlci, uint8_t pf) struct net_buf *buf, u8_t dlci, u8_t pf)
{ {
struct bt_rfcomm_dlc *dlc; struct bt_rfcomm_dlc *dlc;
@ -1393,7 +1393,7 @@ static void rfcomm_handle_data(struct bt_rfcomm_session *session,
int bt_rfcomm_dlc_send(struct bt_rfcomm_dlc *dlc, struct net_buf *buf) int bt_rfcomm_dlc_send(struct bt_rfcomm_dlc *dlc, struct net_buf *buf)
{ {
struct bt_rfcomm_hdr *hdr; struct bt_rfcomm_hdr *hdr;
uint8_t fcs, cr; u8_t fcs, cr;
if (!buf) { if (!buf) {
return -EINVAL; return -EINVAL;
@ -1410,11 +1410,11 @@ int bt_rfcomm_dlc_send(struct bt_rfcomm_dlc *dlc, struct net_buf *buf)
} }
if (buf->len > BT_RFCOMM_MAX_LEN_8) { if (buf->len > BT_RFCOMM_MAX_LEN_8) {
uint16_t *len; u16_t *len;
/* Length is 2 byte */ /* Length is 2 byte */
hdr = net_buf_push(buf, sizeof(*hdr) + 1); hdr = net_buf_push(buf, sizeof(*hdr) + 1);
len = (uint16_t *)&hdr->length; len = (u16_t *)&hdr->length;
*len = BT_RFCOMM_SET_LEN_16(sys_cpu_to_le16(buf->len - *len = BT_RFCOMM_SET_LEN_16(sys_cpu_to_le16(buf->len -
sizeof(*hdr) + 1)); sizeof(*hdr) + 1));
} else { } else {
@ -1439,7 +1439,7 @@ static void rfcomm_recv(struct bt_l2cap_chan *chan, struct net_buf *buf)
{ {
struct bt_rfcomm_session *session = RFCOMM_SESSION(chan); struct bt_rfcomm_session *session = RFCOMM_SESSION(chan);
struct bt_rfcomm_hdr *hdr = (void *)buf->data; struct bt_rfcomm_hdr *hdr = (void *)buf->data;
uint8_t dlci, frame_type, fcs, fcs_len; u8_t dlci, frame_type, fcs, fcs_len;
/* Need to consider FCS also*/ /* Need to consider FCS also*/
if (buf->len < (sizeof(*hdr) + 1)) { if (buf->len < (sizeof(*hdr) + 1)) {
@ -1495,7 +1495,7 @@ static void rfcomm_recv(struct bt_l2cap_chan *chan, struct net_buf *buf)
} }
static void rfcomm_encrypt_change(struct bt_l2cap_chan *chan, static void rfcomm_encrypt_change(struct bt_l2cap_chan *chan,
uint8_t hci_status) u8_t hci_status)
{ {
struct bt_rfcomm_session *session = RFCOMM_SESSION(chan); struct bt_rfcomm_session *session = RFCOMM_SESSION(chan);
struct bt_conn *conn = chan->conn; struct bt_conn *conn = chan->conn;
@ -1582,11 +1582,11 @@ static struct bt_rfcomm_session *rfcomm_session_new(bt_rfcomm_role_t role)
} }
int bt_rfcomm_dlc_connect(struct bt_conn *conn, struct bt_rfcomm_dlc *dlc, int bt_rfcomm_dlc_connect(struct bt_conn *conn, struct bt_rfcomm_dlc *dlc,
uint8_t channel) u8_t channel)
{ {
struct bt_rfcomm_session *session; struct bt_rfcomm_session *session;
struct bt_l2cap_chan *chan; struct bt_l2cap_chan *chan;
uint8_t dlci; u8_t dlci;
int ret; int ret;
BT_DBG("conn %p dlc %p channel %d", conn, dlc, channel); BT_DBG("conn %p dlc %p channel %d", conn, dlc, channel);

View file

@ -25,8 +25,8 @@ struct bt_rfcomm_session {
/* Binary sem for aggregate fc */ /* Binary sem for aggregate fc */
struct k_sem fc; struct k_sem fc;
struct bt_rfcomm_dlc *dlcs; struct bt_rfcomm_dlc *dlcs;
uint16_t mtu; u16_t mtu;
uint8_t state; u8_t state;
bt_rfcomm_role_t role; bt_rfcomm_role_t role;
bt_rfcomm_cfc_t cfc; bt_rfcomm_cfc_t cfc;
}; };
@ -44,9 +44,9 @@ enum {
}; };
struct bt_rfcomm_hdr { struct bt_rfcomm_hdr {
uint8_t address; u8_t address;
uint8_t control; u8_t control;
uint8_t length; u8_t length;
} __packed; } __packed;
#define BT_RFCOMM_SABM 0x2f #define BT_RFCOMM_SABM 0x2f
@ -54,25 +54,25 @@ struct bt_rfcomm_hdr {
#define BT_RFCOMM_UIH 0xef #define BT_RFCOMM_UIH 0xef
struct bt_rfcomm_msg_hdr { struct bt_rfcomm_msg_hdr {
uint8_t type; u8_t type;
uint8_t len; u8_t len;
} __packed; } __packed;
#define BT_RFCOMM_PN 0x20 #define BT_RFCOMM_PN 0x20
struct bt_rfcomm_pn { struct bt_rfcomm_pn {
uint8_t dlci; u8_t dlci;
uint8_t flow_ctrl; u8_t flow_ctrl;
uint8_t priority; u8_t priority;
uint8_t ack_timer; u8_t ack_timer;
uint16_t mtu; u16_t mtu;
uint8_t max_retrans; u8_t max_retrans;
uint8_t credits; u8_t credits;
} __packed; } __packed;
#define BT_RFCOMM_MSC 0x38 #define BT_RFCOMM_MSC 0x38
struct bt_rfcomm_msc { struct bt_rfcomm_msc {
uint8_t dlci; u8_t dlci;
uint8_t v24_signal; u8_t v24_signal;
} __packed; } __packed;
#define BT_RFCOMM_DISC 0x43 #define BT_RFCOMM_DISC 0x43
@ -80,19 +80,19 @@ struct bt_rfcomm_msc {
#define BT_RFCOMM_RLS 0x14 #define BT_RFCOMM_RLS 0x14
struct bt_rfcomm_rls { struct bt_rfcomm_rls {
uint8_t dlci; u8_t dlci;
uint8_t line_status; u8_t line_status;
} __packed; } __packed;
#define BT_RFCOMM_RPN 0x24 #define BT_RFCOMM_RPN 0x24
struct bt_rfcomm_rpn { struct bt_rfcomm_rpn {
uint8_t dlci; u8_t dlci;
uint8_t baud_rate; u8_t baud_rate;
uint8_t line_settings; u8_t line_settings;
uint8_t flow_control; u8_t flow_control;
uint8_t xon_char; u8_t xon_char;
uint8_t xoff_char; u8_t xoff_char;
uint16_t param_mask; u16_t param_mask;
} __packed; } __packed;
#define BT_RFCOMM_TEST 0x08 #define BT_RFCOMM_TEST 0x08

View file

@ -58,7 +58,7 @@ struct bt_sdp {
}; };
static struct bt_sdp_record *db; static struct bt_sdp_record *db;
static uint8_t num_services; static u8_t num_services;
static struct bt_sdp bt_sdp_pool[CONFIG_BLUETOOTH_MAX_CONN]; static struct bt_sdp bt_sdp_pool[CONFIG_BLUETOOTH_MAX_CONN];
@ -75,7 +75,7 @@ struct bt_sdp_client {
/* list of waiting to be resolved UUID params */ /* list of waiting to be resolved UUID params */
sys_slist_t reqs; sys_slist_t reqs;
/* required SDP transaction ID */ /* required SDP transaction ID */
uint16_t tid; u16_t tid;
/* UUID params holder being now resolved */ /* UUID params holder being now resolved */
const struct bt_sdp_discover_params *param; const struct bt_sdp_discover_params *param;
/* PDU continuation state object */ /* PDU continuation state object */
@ -92,9 +92,9 @@ enum {
}; };
struct search_state { struct search_state {
uint16_t att_list_size; u16_t att_list_size;
uint8_t current_svc; u8_t current_svc;
uint8_t last_att; u8_t last_att;
bool pkt_full; bool pkt_full;
}; };
@ -104,11 +104,11 @@ struct select_attrs_data {
struct bt_sdp *sdp; struct bt_sdp *sdp;
struct bt_sdp_data_elem_seq *seq; struct bt_sdp_data_elem_seq *seq;
struct search_state *state; struct search_state *state;
uint32_t *filter; u32_t *filter;
uint16_t max_att_len; u16_t max_att_len;
uint16_t att_list_len; u16_t att_list_len;
uint8_t cont_state_size; u8_t cont_state_size;
uint8_t num_filters; u8_t num_filters;
bool new_service; bool new_service;
}; };
@ -122,8 +122,8 @@ struct select_attrs_data {
* @return BT_SDP_ITER_CONTINUE if should continue to the next attribute * @return BT_SDP_ITER_CONTINUE if should continue to the next attribute
* or BT_SDP_ITER_STOP to stop. * or BT_SDP_ITER_STOP to stop.
*/ */
typedef uint8_t (*bt_sdp_attr_func_t)(struct bt_sdp_attribute *attr, typedef u8_t (*bt_sdp_attr_func_t)(struct bt_sdp_attribute *attr,
uint8_t att_idx, void *user_data); u8_t att_idx, void *user_data);
/* @typedef bt_sdp_svc_func_t /* @typedef bt_sdp_svc_func_t
* @brief SDP service record iterator callback. * @brief SDP service record iterator callback.
@ -134,7 +134,7 @@ typedef uint8_t (*bt_sdp_attr_func_t)(struct bt_sdp_attribute *attr,
* @return BT_SDP_ITER_CONTINUE if should continue to the next service record * @return BT_SDP_ITER_CONTINUE if should continue to the next service record
* or BT_SDP_ITER_STOP to stop. * or BT_SDP_ITER_STOP to stop.
*/ */
typedef uint8_t (*bt_sdp_svc_func_t)(struct bt_sdp_record *rec, typedef u8_t (*bt_sdp_svc_func_t)(struct bt_sdp_record *rec,
void *user_data); void *user_data);
/* @brief Callback for SDP connection /* @brief Callback for SDP connection
@ -204,10 +204,10 @@ static struct net_buf *bt_sdp_create_pdu(void)
* @return None * @return None
*/ */
static void bt_sdp_send(struct bt_l2cap_chan *chan, struct net_buf *buf, static void bt_sdp_send(struct bt_l2cap_chan *chan, struct net_buf *buf,
uint8_t op, uint16_t tid) u8_t op, u16_t tid)
{ {
struct bt_sdp_hdr *hdr; struct bt_sdp_hdr *hdr;
uint16_t param_len = buf->len; u16_t param_len = buf->len;
hdr = net_buf_push(buf, sizeof(struct bt_sdp_hdr)); hdr = net_buf_push(buf, sizeof(struct bt_sdp_hdr));
hdr->op_code = op; hdr->op_code = op;
@ -227,8 +227,8 @@ static void bt_sdp_send(struct bt_l2cap_chan *chan, struct net_buf *buf,
* *
* @return None * @return None
*/ */
static void send_err_rsp(struct bt_l2cap_chan *chan, uint16_t err, static void send_err_rsp(struct bt_l2cap_chan *chan, u16_t err,
uint16_t tid) u16_t tid)
{ {
struct net_buf *buf; struct net_buf *buf;
@ -252,10 +252,10 @@ static void send_err_rsp(struct bt_l2cap_chan *chan, uint16_t err,
* *
* @return 0 for success, or relevant error code * @return 0 for success, or relevant error code
*/ */
static uint16_t parse_data_elem(struct net_buf *buf, static u16_t parse_data_elem(struct net_buf *buf,
struct bt_sdp_data_elem *data_elem) struct bt_sdp_data_elem *data_elem)
{ {
uint8_t size_field_len = 0; /* Space used to accommodate the size */ u8_t size_field_len = 0; /* Space used to accommodate the size */
if (buf->len < 1) { if (buf->len < 1) {
BT_WARN("Malformed packet"); BT_WARN("Malformed packet");
@ -328,11 +328,11 @@ static uint16_t parse_data_elem(struct net_buf *buf,
* @return Size of the last data element that has been searched * @return Size of the last data element that has been searched
* (used in recursion) * (used in recursion)
*/ */
static uint32_t search_uuid(struct bt_sdp_data_elem *elem, struct bt_uuid *uuid, static u32_t search_uuid(struct bt_sdp_data_elem *elem, struct bt_uuid *uuid,
bool *found, uint8_t nest_level) bool *found, u8_t nest_level)
{ {
const uint8_t *cur_elem; const u8_t *cur_elem;
uint32_t seq_size, size; u32_t seq_size, size;
union { union {
struct bt_uuid uuid; struct bt_uuid uuid;
struct bt_uuid_16 u16; struct bt_uuid_16 u16;
@ -355,13 +355,13 @@ static uint32_t search_uuid(struct bt_sdp_data_elem *elem, struct bt_uuid *uuid,
if ((elem->type & BT_SDP_TYPE_DESC_MASK) == BT_SDP_UUID_UNSPEC) { if ((elem->type & BT_SDP_TYPE_DESC_MASK) == BT_SDP_UUID_UNSPEC) {
if (seq_size == 2) { if (seq_size == 2) {
u.uuid.type = BT_UUID_TYPE_16; u.uuid.type = BT_UUID_TYPE_16;
u.u16.val = *((uint16_t *)cur_elem); u.u16.val = *((u16_t *)cur_elem);
if (!bt_uuid_cmp(&u.uuid, uuid)) { if (!bt_uuid_cmp(&u.uuid, uuid)) {
*found = true; *found = true;
} }
} else if (seq_size == 4) { } else if (seq_size == 4) {
u.uuid.type = BT_UUID_TYPE_32; u.uuid.type = BT_UUID_TYPE_32;
u.u32.val = *((uint32_t *)cur_elem); u.u32.val = *((u32_t *)cur_elem);
if (!bt_uuid_cmp(&u.uuid, uuid)) { if (!bt_uuid_cmp(&u.uuid, uuid)) {
*found = true; *found = true;
} }
@ -428,7 +428,7 @@ static struct bt_sdp_record *bt_sdp_foreach_svc(bt_sdp_svc_func_t func,
* *
* @return BT_SDP_ITER_CONTINUE to move on to the next record. * @return BT_SDP_ITER_CONTINUE to move on to the next record.
*/ */
static uint8_t insert_record(struct bt_sdp_record *rec, void *user_data) static u8_t insert_record(struct bt_sdp_record *rec, void *user_data)
{ {
struct bt_sdp_record **rec_list = user_data; struct bt_sdp_record **rec_list = user_data;
@ -450,14 +450,14 @@ static uint8_t insert_record(struct bt_sdp_record *rec, void *user_data)
* *
* @return 0 for success, or relevant error code * @return 0 for success, or relevant error code
*/ */
static uint16_t find_services(struct net_buf *buf, static u16_t find_services(struct net_buf *buf,
struct bt_sdp_record **matching_recs) struct bt_sdp_record **matching_recs)
{ {
struct bt_sdp_data_elem data_elem; struct bt_sdp_data_elem data_elem;
struct bt_sdp_record *record; struct bt_sdp_record *record;
uint32_t uuid_list_size; u32_t uuid_list_size;
uint16_t res; u16_t res;
uint8_t att_idx, rec_idx = 0; u8_t att_idx, rec_idx = 0;
bool found; bool found;
union { union {
struct bt_uuid uuid; struct bt_uuid uuid;
@ -564,15 +564,15 @@ static uint16_t find_services(struct net_buf *buf,
* *
* @return 0 for success, or relevant error code * @return 0 for success, or relevant error code
*/ */
static uint16_t sdp_svc_search_req(struct bt_sdp *sdp, struct net_buf *buf, static u16_t sdp_svc_search_req(struct bt_sdp *sdp, struct net_buf *buf,
uint16_t tid) u16_t tid)
{ {
struct bt_sdp_svc_rsp *rsp; struct bt_sdp_svc_rsp *rsp;
struct net_buf *resp_buf; struct net_buf *resp_buf;
struct bt_sdp_record *record; struct bt_sdp_record *record;
struct bt_sdp_record *matching_recs[BT_SDP_MAX_SERVICES]; struct bt_sdp_record *matching_recs[BT_SDP_MAX_SERVICES];
uint16_t max_rec_count, total_recs = 0, current_recs = 0, res; u16_t max_rec_count, total_recs = 0, current_recs = 0, res;
uint8_t cont_state_size, cont_state = 0, idx = 0, count = 0; u8_t cont_state_size, cont_state = 0, idx = 0, count = 0;
bool pkt_full = false; bool pkt_full = false;
res = find_services(buf, matching_recs); res = find_services(buf, matching_recs);
@ -700,11 +700,11 @@ static uint16_t sdp_svc_search_req(struct bt_sdp *sdp, struct net_buf *buf,
* @return Size of the last data element that has been searched * @return Size of the last data element that has been searched
* (used in recursion) * (used in recursion)
*/ */
static uint32_t copy_attribute(struct bt_sdp_data_elem *elem, static u32_t copy_attribute(struct bt_sdp_data_elem *elem,
struct net_buf *buf, uint8_t nest_level) struct net_buf *buf, u8_t nest_level)
{ {
const uint8_t *cur_elem; const u8_t *cur_elem;
uint32_t size, seq_size, total_size; u32_t size, seq_size, total_size;
/* Limit recursion depth to avoid stack overflows */ /* Limit recursion depth to avoid stack overflows */
if (nest_level == SDP_DATA_ELEM_NEST_LEVEL_MAX) { if (nest_level == SDP_DATA_ELEM_NEST_LEVEL_MAX) {
@ -745,11 +745,11 @@ static uint32_t copy_attribute(struct bt_sdp_data_elem *elem,
(elem->type & BT_SDP_TYPE_DESC_MASK) == BT_SDP_INT8 || (elem->type & BT_SDP_TYPE_DESC_MASK) == BT_SDP_INT8 ||
(elem->type & BT_SDP_TYPE_DESC_MASK) == BT_SDP_UUID_UNSPEC) { (elem->type & BT_SDP_TYPE_DESC_MASK) == BT_SDP_UUID_UNSPEC) {
if (seq_size == 1) { if (seq_size == 1) {
net_buf_add_u8(buf, *((uint8_t *)elem->data)); net_buf_add_u8(buf, *((u8_t *)elem->data));
} else if (seq_size == 2) { } else if (seq_size == 2) {
net_buf_add_be16(buf, *((uint16_t *)elem->data)); net_buf_add_be16(buf, *((u16_t *)elem->data));
} else if (seq_size == 4) { } else if (seq_size == 4) {
net_buf_add_be32(buf, *((uint32_t *)elem->data)); net_buf_add_be32(buf, *((u32_t *)elem->data));
} else { } else {
/* TODO: Convert 32bit and 128bit values to big-endian*/ /* TODO: Convert 32bit and 128bit values to big-endian*/
net_buf_add_mem(buf, elem->data, seq_size); net_buf_add_mem(buf, elem->data, seq_size);
@ -772,7 +772,7 @@ static uint32_t copy_attribute(struct bt_sdp_data_elem *elem,
* *
* @return Index of the attribute where the iterator stopped * @return Index of the attribute where the iterator stopped
*/ */
static uint8_t bt_sdp_foreach_attr(struct bt_sdp_record *record, uint8_t idx, static u8_t bt_sdp_foreach_attr(struct bt_sdp_record *record, u8_t idx,
bt_sdp_attr_func_t func, void *user_data) bt_sdp_attr_func_t func, void *user_data)
{ {
for (; idx < record->attr_count; idx++) { for (; idx < record->attr_count; idx++) {
@ -798,13 +798,13 @@ static uint8_t bt_sdp_foreach_attr(struct bt_sdp_record *record, uint8_t idx,
* @return BT_SDP_ITER_CONTINUE if should continue to the next attribute * @return BT_SDP_ITER_CONTINUE if should continue to the next attribute
* or BT_SDP_ITER_STOP to stop. * or BT_SDP_ITER_STOP to stop.
*/ */
static uint8_t select_attrs(struct bt_sdp_attribute *attr, uint8_t att_idx, static u8_t select_attrs(struct bt_sdp_attribute *attr, u8_t att_idx,
void *user_data) void *user_data)
{ {
struct select_attrs_data *sad = user_data; struct select_attrs_data *sad = user_data;
uint16_t att_id_lower, att_id_upper, att_id_cur, space; u16_t att_id_lower, att_id_upper, att_id_cur, space;
uint32_t attr_size, seq_size; u32_t attr_size, seq_size;
uint8_t idx_filter; u8_t idx_filter;
for (idx_filter = 0; idx_filter < sad->num_filters; idx_filter++) { for (idx_filter = 0; idx_filter < sad->num_filters; idx_filter++) {
@ -928,15 +928,15 @@ static uint8_t select_attrs(struct bt_sdp_attribute *attr, uint8_t att_idx,
* *
* @return len Length of the attribute list created * @return len Length of the attribute list created
*/ */
static uint16_t create_attr_list(struct bt_sdp *sdp, static u16_t create_attr_list(struct bt_sdp *sdp,
struct bt_sdp_record *record, struct bt_sdp_record *record,
uint32_t *filter, uint8_t num_filters, u32_t *filter, u8_t num_filters,
uint16_t max_att_len, uint8_t cont_state_size, u16_t max_att_len, u8_t cont_state_size,
uint8_t next_att, struct search_state *state, u8_t next_att, struct search_state *state,
struct net_buf *rsp_buf) struct net_buf *rsp_buf)
{ {
struct select_attrs_data sad; struct select_attrs_data sad;
uint8_t idx_att; u8_t idx_att;
sad.num_filters = num_filters; sad.num_filters = num_filters;
sad.rec = record; sad.rec = record;
@ -973,12 +973,12 @@ static uint16_t create_attr_list(struct bt_sdp *sdp,
* *
* @return 0 for success, or relevant error code * @return 0 for success, or relevant error code
*/ */
static uint16_t get_att_search_list(struct net_buf *buf, uint32_t *filter, static u16_t get_att_search_list(struct net_buf *buf, u32_t *filter,
uint8_t *num_filters) u8_t *num_filters)
{ {
struct bt_sdp_data_elem data_elem; struct bt_sdp_data_elem data_elem;
uint16_t res; u16_t res;
uint32_t size; u32_t size;
*num_filters = 0; *num_filters = 0;
res = parse_data_elem(buf, &data_elem); res = parse_data_elem(buf, &data_elem);
@ -1032,9 +1032,9 @@ static uint16_t get_att_search_list(struct net_buf *buf, uint32_t *filter,
* @return BT_SDP_ITER_CONTINUE if should continue to the next record * @return BT_SDP_ITER_CONTINUE if should continue to the next record
* or BT_SDP_ITER_STOP to stop. * or BT_SDP_ITER_STOP to stop.
*/ */
static uint8_t find_handle(struct bt_sdp_record *rec, void *user_data) static u8_t find_handle(struct bt_sdp_record *rec, void *user_data)
{ {
uint32_t *svc_rec_hdl = user_data; u32_t *svc_rec_hdl = user_data;
if (rec->handle == *svc_rec_hdl) { if (rec->handle == *svc_rec_hdl) {
return BT_SDP_ITER_STOP; return BT_SDP_ITER_STOP;
@ -1053,10 +1053,10 @@ static uint8_t find_handle(struct bt_sdp_record *rec, void *user_data)
* *
* @return 0 for success, or relevant error code * @return 0 for success, or relevant error code
*/ */
static uint16_t sdp_svc_att_req(struct bt_sdp *sdp, struct net_buf *buf, static u16_t sdp_svc_att_req(struct bt_sdp *sdp, struct net_buf *buf,
uint16_t tid) u16_t tid)
{ {
uint32_t filter[MAX_NUM_ATT_ID_FILTER]; u32_t filter[MAX_NUM_ATT_ID_FILTER];
struct search_state state = { struct search_state state = {
.current_svc = SDP_INVALID, .current_svc = SDP_INVALID,
.last_att = SDP_INVALID, .last_att = SDP_INVALID,
@ -1065,9 +1065,9 @@ static uint16_t sdp_svc_att_req(struct bt_sdp *sdp, struct net_buf *buf,
struct bt_sdp_record *record; struct bt_sdp_record *record;
struct bt_sdp_att_rsp *rsp; struct bt_sdp_att_rsp *rsp;
struct net_buf *rsp_buf; struct net_buf *rsp_buf;
uint32_t svc_rec_hdl; u32_t svc_rec_hdl;
uint16_t max_att_len, res, att_list_len; u16_t max_att_len, res, att_list_len;
uint8_t num_filters, cont_state_size, next_att = 0; u8_t num_filters, cont_state_size, next_att = 0;
if (buf->len < 6) { if (buf->len < 6) {
BT_WARN("Malformed packet"); BT_WARN("Malformed packet");
@ -1167,10 +1167,10 @@ static uint16_t sdp_svc_att_req(struct bt_sdp *sdp, struct net_buf *buf,
* *
* @return 0 for success, or relevant error code * @return 0 for success, or relevant error code
*/ */
static uint16_t sdp_svc_search_att_req(struct bt_sdp *sdp, struct net_buf *buf, static u16_t sdp_svc_search_att_req(struct bt_sdp *sdp, struct net_buf *buf,
uint16_t tid) u16_t tid)
{ {
uint32_t filter[MAX_NUM_ATT_ID_FILTER]; u32_t filter[MAX_NUM_ATT_ID_FILTER];
struct bt_sdp_record *matching_recs[BT_SDP_MAX_SERVICES]; struct bt_sdp_record *matching_recs[BT_SDP_MAX_SERVICES];
struct search_state state = { struct search_state state = {
.att_list_size = 0, .att_list_size = 0,
@ -1182,8 +1182,8 @@ static uint16_t sdp_svc_search_att_req(struct bt_sdp *sdp, struct net_buf *buf,
struct bt_sdp_record *record; struct bt_sdp_record *record;
struct bt_sdp_att_rsp *rsp; struct bt_sdp_att_rsp *rsp;
struct bt_sdp_data_elem_seq *seq = NULL; struct bt_sdp_data_elem_seq *seq = NULL;
uint16_t max_att_len, res, att_list_len = 0; u16_t max_att_len, res, att_list_len = 0;
uint8_t num_filters, cont_state_size, next_svc = 0, next_att = 0; u8_t num_filters, cont_state_size, next_svc = 0, next_att = 0;
bool dry_run = false; bool dry_run = false;
res = find_services(buf, matching_recs); res = find_services(buf, matching_recs);
@ -1312,9 +1312,9 @@ static uint16_t sdp_svc_search_att_req(struct bt_sdp *sdp, struct net_buf *buf,
} }
static const struct { static const struct {
uint8_t op_code; u8_t op_code;
uint16_t (*func)(struct bt_sdp *sdp, struct net_buf *buf, u16_t (*func)(struct bt_sdp *sdp, struct net_buf *buf,
uint16_t tid); u16_t tid);
} handlers[] = { } handlers[] = {
{ BT_SDP_SVC_SEARCH_REQ, sdp_svc_search_req }, { BT_SDP_SVC_SEARCH_REQ, sdp_svc_search_req },
{ BT_SDP_SVC_ATTR_REQ, sdp_svc_att_req }, { BT_SDP_SVC_ATTR_REQ, sdp_svc_att_req },
@ -1337,7 +1337,7 @@ static void bt_sdp_recv(struct bt_l2cap_chan *chan, struct net_buf *buf)
struct bt_l2cap_br_chan, chan); struct bt_l2cap_br_chan, chan);
struct bt_sdp *sdp = CONTAINER_OF(ch, struct bt_sdp, chan); struct bt_sdp *sdp = CONTAINER_OF(ch, struct bt_sdp, chan);
struct bt_sdp_hdr *hdr = (struct bt_sdp_hdr *)buf->data; struct bt_sdp_hdr *hdr = (struct bt_sdp_hdr *)buf->data;
uint16_t err = BT_SDP_INVALID_SYNTAX; u16_t err = BT_SDP_INVALID_SYNTAX;
size_t i; size_t i;
BT_DBG("chan %p, ch %p, cid 0x%04x", chan, ch, ch->tx.cid); BT_DBG("chan %p, ch %p, cid 0x%04x", chan, ch, ch->tx.cid);
@ -1430,7 +1430,7 @@ void bt_sdp_init(void)
int bt_sdp_register_service(struct bt_sdp_record *service) int bt_sdp_register_service(struct bt_sdp_record *service)
{ {
uint32_t handle = SDP_SERVICE_HANDLE_BASE; u32_t handle = SDP_SERVICE_HANDLE_BASE;
if (!service) { if (!service) {
BT_ERR("No service record specified"); BT_ERR("No service record specified");
@ -1449,7 +1449,7 @@ int bt_sdp_register_service(struct bt_sdp_record *service)
service->next = db; service->next = db;
service->index = num_services++; service->index = num_services++;
service->handle = handle; service->handle = handle;
*((uint32_t *)(service->attrs[0].val.data)) = handle; *((u32_t *)(service->attrs[0].val.data)) = handle;
db = service; db = service;
BT_DBG("Service registered at %u", handle); BT_DBG("Service registered at %u", handle);
@ -1587,11 +1587,11 @@ static void sdp_client_params_iterator(struct bt_sdp_client *session)
} }
} }
static uint16_t sdp_client_get_total(struct bt_sdp_client *session, static u16_t sdp_client_get_total(struct bt_sdp_client *session,
struct net_buf *buf, uint16_t *total) struct net_buf *buf, u16_t *total)
{ {
uint16_t pulled; u16_t pulled;
uint8_t seq; u8_t seq;
/* /*
* Pull value of total octets of all attributes available to be * Pull value of total octets of all attributes available to be
@ -1627,10 +1627,10 @@ static uint16_t sdp_client_get_total(struct bt_sdp_client *session,
return pulled; return pulled;
} }
static uint16_t get_record_len(struct net_buf *buf) static u16_t get_record_len(struct net_buf *buf)
{ {
uint16_t len; u16_t len;
uint8_t seq; u8_t seq;
seq = net_buf_pull_u8(buf); seq = net_buf_pull_u8(buf);
@ -1662,8 +1662,8 @@ static void sdp_client_notify_result(struct bt_sdp_client *session,
{ {
struct bt_conn *conn = session->chan.chan.conn; struct bt_conn *conn = session->chan.chan.conn;
struct bt_sdp_client_result result; struct bt_sdp_client_result result;
uint16_t rec_len; u16_t rec_len;
uint8_t user_ret; u8_t user_ret;
result.uuid = session->param->uuid; result.uuid = session->param->uuid;
@ -1716,8 +1716,8 @@ static void sdp_client_receive(struct bt_l2cap_chan *chan, struct net_buf *buf)
struct bt_sdp_client *session = SDP_CLIENT_CHAN(chan); struct bt_sdp_client *session = SDP_CLIENT_CHAN(chan);
struct bt_sdp_hdr *hdr = (void *)buf->data; struct bt_sdp_hdr *hdr = (void *)buf->data;
struct bt_sdp_pdu_cstate *cstate; struct bt_sdp_pdu_cstate *cstate;
uint16_t len, tid, frame_len; u16_t len, tid, frame_len;
uint16_t total; u16_t total;
BT_DBG("session %p buf %p", session, buf); BT_DBG("session %p buf %p", session, buf);
@ -1953,7 +1953,7 @@ int bt_sdp_discover(struct bt_conn *conn,
} }
/* Helper getting length of data determined by DTD for integers */ /* Helper getting length of data determined by DTD for integers */
static inline ssize_t sdp_get_int_len(const uint8_t *data, size_t len) static inline ssize_t sdp_get_int_len(const u8_t *data, size_t len)
{ {
BT_ASSERT(data); BT_ASSERT(data);
@ -2001,7 +2001,7 @@ static inline ssize_t sdp_get_int_len(const uint8_t *data, size_t len)
} }
/* Helper getting length of data determined by DTD for UUID */ /* Helper getting length of data determined by DTD for UUID */
static inline ssize_t sdp_get_uuid_len(const uint8_t *data, size_t len) static inline ssize_t sdp_get_uuid_len(const u8_t *data, size_t len)
{ {
BT_ASSERT(data); BT_ASSERT(data);
@ -2029,9 +2029,9 @@ static inline ssize_t sdp_get_uuid_len(const uint8_t *data, size_t len)
} }
/* Helper getting length of data determined by DTD for strings */ /* Helper getting length of data determined by DTD for strings */
static inline ssize_t sdp_get_str_len(const uint8_t *data, size_t len) static inline ssize_t sdp_get_str_len(const u8_t *data, size_t len)
{ {
const uint8_t *pnext; const u8_t *pnext;
BT_ASSERT(data); BT_ASSERT(data);
@ -2040,7 +2040,7 @@ static inline ssize_t sdp_get_str_len(const uint8_t *data, size_t len)
goto err; goto err;
} }
pnext = data + sizeof(uint8_t); pnext = data + sizeof(u8_t);
switch (data[0]) { switch (data[0]) {
case BT_SDP_TEXT_STR8: case BT_SDP_TEXT_STR8:
@ -2074,9 +2074,9 @@ err:
} }
/* Helper getting length of data determined by DTD for sequences */ /* Helper getting length of data determined by DTD for sequences */
static inline ssize_t sdp_get_seq_len(const uint8_t *data, size_t len) static inline ssize_t sdp_get_seq_len(const u8_t *data, size_t len)
{ {
const uint8_t *pnext; const u8_t *pnext;
BT_ASSERT(data); BT_ASSERT(data);
@ -2085,7 +2085,7 @@ static inline ssize_t sdp_get_seq_len(const uint8_t *data, size_t len)
goto err; goto err;
} }
pnext = data + sizeof(uint8_t); pnext = data + sizeof(u8_t);
switch (data[0]) { switch (data[0]) {
case BT_SDP_SEQ8: case BT_SDP_SEQ8:
@ -2119,7 +2119,7 @@ err:
} }
/* Helper getting length of attribute value data */ /* Helper getting length of attribute value data */
static ssize_t sdp_get_attr_value_len(const uint8_t *data, size_t len) static ssize_t sdp_get_attr_value_len(const u8_t *data, size_t len)
{ {
BT_ASSERT(data); BT_ASSERT(data);
@ -2170,28 +2170,28 @@ struct bt_sdp_uuid_desc {
struct bt_uuid_16 uuid16; struct bt_uuid_16 uuid16;
struct bt_uuid_32 uuid32; struct bt_uuid_32 uuid32;
}; };
uint16_t attr_id; u16_t attr_id;
uint8_t *params; u8_t *params;
uint16_t params_len; u16_t params_len;
}; };
/* Generic attribute item collector. */ /* Generic attribute item collector. */
struct bt_sdp_attr_item { struct bt_sdp_attr_item {
/* Attribute identifier. */ /* Attribute identifier. */
uint16_t attr_id; u16_t attr_id;
/* Address of beginning attribute value taken from original buffer /* Address of beginning attribute value taken from original buffer
* holding response from server. * holding response from server.
*/ */
uint8_t *val; u8_t *val;
/* Says about the length of attribute value. */ /* Says about the length of attribute value. */
uint16_t len; u16_t len;
}; };
static int bt_sdp_get_attr(const struct net_buf *buf, static int bt_sdp_get_attr(const struct net_buf *buf,
struct bt_sdp_attr_item *attr, uint16_t attr_id) struct bt_sdp_attr_item *attr, u16_t attr_id)
{ {
uint8_t *data; u8_t *data;
uint16_t id; u16_t id;
data = buf->data; data = buf->data;
while (data - buf->data < buf->len) { while (data - buf->data < buf->len) {
@ -2203,10 +2203,10 @@ static int bt_sdp_get_attr(const struct net_buf *buf,
return -EINVAL; return -EINVAL;
} }
data += sizeof(uint8_t); data += sizeof(u8_t);
id = sys_get_be16(data); id = sys_get_be16(data);
BT_DBG("Attribute ID 0x%04x", id); BT_DBG("Attribute ID 0x%04x", id);
data += sizeof(uint16_t); data += sizeof(u16_t);
dlen = sdp_get_attr_value_len(data, dlen = sdp_get_attr_value_len(data,
buf->len - (data - buf->data)); buf->len - (data - buf->data));
@ -2234,9 +2234,9 @@ static int bt_sdp_get_attr(const struct net_buf *buf,
} }
/* reads SEQ item length, moves input buffer data reader forward */ /* reads SEQ item length, moves input buffer data reader forward */
static ssize_t sdp_get_seq_len_item(uint8_t **data, size_t len) static ssize_t sdp_get_seq_len_item(u8_t **data, size_t len)
{ {
const uint8_t *pnext; const u8_t *pnext;
BT_ASSERT(data); BT_ASSERT(data);
BT_ASSERT(*data); BT_ASSERT(*data);
@ -2246,7 +2246,7 @@ static ssize_t sdp_get_seq_len_item(uint8_t **data, size_t len)
goto err; goto err;
} }
pnext = *data + sizeof(uint8_t); pnext = *data + sizeof(u8_t);
switch (*data[0]) { switch (*data[0]) {
case BT_SDP_SEQ8: case BT_SDP_SEQ8:
@ -2291,10 +2291,10 @@ err:
static int sdp_get_uuid_data(const struct bt_sdp_attr_item *attr, static int sdp_get_uuid_data(const struct bt_sdp_attr_item *attr,
struct bt_sdp_uuid_desc *pd, struct bt_sdp_uuid_desc *pd,
uint16_t proto_profile) u16_t proto_profile)
{ {
/* get start address of attribute value */ /* get start address of attribute value */
uint8_t *p = attr->val; u8_t *p = attr->val;
ssize_t slen; ssize_t slen;
BT_ASSERT(p); BT_ASSERT(p);
@ -2331,8 +2331,8 @@ static int sdp_get_uuid_data(const struct bt_sdp_attr_item *attr,
memcpy(&pd->uuid16, memcpy(&pd->uuid16,
BT_UUID_DECLARE_16(sys_get_be16(++p)), BT_UUID_DECLARE_16(sys_get_be16(++p)),
sizeof(struct bt_uuid_16)); sizeof(struct bt_uuid_16));
p += sizeof(uint16_t); p += sizeof(u16_t);
left -= sizeof(uint16_t); left -= sizeof(u16_t);
break; break;
case BT_SDP_UUID32: case BT_SDP_UUID32:
/* check if valid UUID32 can be read safely */ /* check if valid UUID32 can be read safely */
@ -2343,8 +2343,8 @@ static int sdp_get_uuid_data(const struct bt_sdp_attr_item *attr,
memcpy(&pd->uuid32, memcpy(&pd->uuid32,
BT_UUID_DECLARE_32(sys_get_be32(++p)), BT_UUID_DECLARE_32(sys_get_be32(++p)),
sizeof(struct bt_uuid_32)); sizeof(struct bt_uuid_32));
p += sizeof(uint32_t); p += sizeof(u32_t);
left -= sizeof(uint32_t); left -= sizeof(u32_t);
break; break;
default: default:
BT_ERR("Invalid/unhandled DTD 0x%02x\n", p[0]); BT_ERR("Invalid/unhandled DTD 0x%02x\n", p[0]);
@ -2379,9 +2379,9 @@ static int sdp_get_uuid_data(const struct bt_sdp_attr_item *attr,
* Helper extracting specific parameters associated with UUID node given in * Helper extracting specific parameters associated with UUID node given in
* protocol descriptor list or profile descriptor list. * protocol descriptor list or profile descriptor list.
*/ */
static int sdp_get_param_item(struct bt_sdp_uuid_desc *pd_item, uint16_t *param) static int sdp_get_param_item(struct bt_sdp_uuid_desc *pd_item, u16_t *param)
{ {
const uint8_t *p = pd_item->params; const u8_t *p = pd_item->params;
bool len_err = false; bool len_err = false;
BT_ASSERT(p); BT_ASSERT(p);
@ -2396,7 +2396,7 @@ static int sdp_get_param_item(struct bt_sdp_uuid_desc *pd_item, uint16_t *param)
break; break;
} }
*param = (++p)[0]; *param = (++p)[0];
p += sizeof(uint8_t); p += sizeof(u8_t);
break; break;
case BT_SDP_UINT16: case BT_SDP_UINT16:
/* check if 16bits value can be read safely */ /* check if 16bits value can be read safely */
@ -2405,7 +2405,7 @@ static int sdp_get_param_item(struct bt_sdp_uuid_desc *pd_item, uint16_t *param)
break; break;
} }
*param = sys_get_be16(++p); *param = sys_get_be16(++p);
p += sizeof(uint16_t); p += sizeof(u16_t);
break; break;
case BT_SDP_UINT32: case BT_SDP_UINT32:
/* check if 32bits value can be read safely */ /* check if 32bits value can be read safely */
@ -2414,7 +2414,7 @@ static int sdp_get_param_item(struct bt_sdp_uuid_desc *pd_item, uint16_t *param)
break; break;
} }
*param = sys_get_be32(++p); *param = sys_get_be32(++p);
p += sizeof(uint32_t); p += sizeof(u32_t);
break; break;
default: default:
BT_ERR("Invalid/unhandled DTD 0x%02x\n", p[0]); BT_ERR("Invalid/unhandled DTD 0x%02x\n", p[0]);
@ -2433,7 +2433,7 @@ static int sdp_get_param_item(struct bt_sdp_uuid_desc *pd_item, uint16_t *param)
} }
int bt_sdp_get_proto_param(const struct net_buf *buf, enum bt_sdp_proto proto, int bt_sdp_get_proto_param(const struct net_buf *buf, enum bt_sdp_proto proto,
uint16_t *param) u16_t *param)
{ {
struct bt_sdp_attr_item attr; struct bt_sdp_attr_item attr;
struct bt_sdp_uuid_desc pd; struct bt_sdp_uuid_desc pd;
@ -2461,8 +2461,8 @@ int bt_sdp_get_proto_param(const struct net_buf *buf, enum bt_sdp_proto proto,
return sdp_get_param_item(&pd, param); return sdp_get_param_item(&pd, param);
} }
int bt_sdp_get_profile_version(const struct net_buf *buf, uint16_t profile, int bt_sdp_get_profile_version(const struct net_buf *buf, u16_t profile,
uint16_t *version) u16_t *version)
{ {
struct bt_sdp_attr_item attr; struct bt_sdp_attr_item attr;
struct bt_sdp_uuid_desc pd; struct bt_sdp_uuid_desc pd;
@ -2484,10 +2484,10 @@ int bt_sdp_get_profile_version(const struct net_buf *buf, uint16_t profile,
return sdp_get_param_item(&pd, version); return sdp_get_param_item(&pd, version);
} }
int bt_sdp_get_features(const struct net_buf *buf, uint16_t *features) int bt_sdp_get_features(const struct net_buf *buf, u16_t *features)
{ {
struct bt_sdp_attr_item attr; struct bt_sdp_attr_item attr;
const uint8_t *p; const u8_t *p;
int res; int res;
res = bt_sdp_get_attr(buf, &attr, BT_SDP_ATTR_SUPPORTED_FEATURES); res = bt_sdp_get_attr(buf, &attr, BT_SDP_ATTR_SUPPORTED_FEATURES);
@ -2512,7 +2512,7 @@ int bt_sdp_get_features(const struct net_buf *buf, uint16_t *features)
} }
*features = sys_get_be16(++p); *features = sys_get_be16(++p);
p += sizeof(uint16_t); p += sizeof(u16_t);
if (p - attr.val != attr.len) { if (p - attr.val != attr.len) {
BT_ERR("Invalid data length %u", attr.len); BT_ERR("Invalid data length %u", attr.len);

View file

@ -40,23 +40,23 @@
#define BT_SDP_MAX_SERVICES 10 #define BT_SDP_MAX_SERVICES 10
struct bt_sdp_data_elem_seq { struct bt_sdp_data_elem_seq {
uint8_t type; /* Type: Will be data element sequence */ u8_t type; /* Type: Will be data element sequence */
uint16_t size; /* We only support 2 byte sizes for now */ u16_t size; /* We only support 2 byte sizes for now */
} __packed; } __packed;
struct bt_sdp_hdr { struct bt_sdp_hdr {
uint8_t op_code; u8_t op_code;
uint16_t tid; u16_t tid;
uint16_t param_len; u16_t param_len;
} __packed; } __packed;
struct bt_sdp_svc_rsp { struct bt_sdp_svc_rsp {
uint16_t total_recs; u16_t total_recs;
uint16_t current_recs; u16_t current_recs;
} __packed; } __packed;
struct bt_sdp_att_rsp { struct bt_sdp_att_rsp {
uint16_t att_list_len; u16_t att_list_len;
} __packed; } __packed;
/* Allowed attributes length in SSA Request PDU to be taken from server */ /* Allowed attributes length in SSA Request PDU to be taken from server */
@ -67,8 +67,8 @@ struct bt_sdp_att_rsp {
/* Type mapping SDP PDU Continuation State */ /* Type mapping SDP PDU Continuation State */
struct bt_sdp_pdu_cstate { struct bt_sdp_pdu_cstate {
uint8_t length; u8_t length;
uint8_t data[BT_SDP_MAX_PDU_CSTATE_LEN]; u8_t data[BT_SDP_MAX_PDU_CSTATE_LEN];
} __packed; } __packed;
void bt_sdp_init(void); void bt_sdp_init(void);

File diff suppressed because it is too large Load diff

View file

@ -10,7 +10,7 @@
*/ */
struct bt_smp_hdr { struct bt_smp_hdr {
uint8_t code; u8_t code;
} __packed; } __packed;
#define BT_SMP_ERR_PASSKEY_ENTRY_FAILED 0x01 #define BT_SMP_ERR_PASSKEY_ENTRY_FAILED 0x01
@ -57,43 +57,43 @@ struct bt_smp_hdr {
#define BT_SMP_CMD_PAIRING_REQ 0x01 #define BT_SMP_CMD_PAIRING_REQ 0x01
#define BT_SMP_CMD_PAIRING_RSP 0x02 #define BT_SMP_CMD_PAIRING_RSP 0x02
struct bt_smp_pairing { struct bt_smp_pairing {
uint8_t io_capability; u8_t io_capability;
uint8_t oob_flag; u8_t oob_flag;
uint8_t auth_req; u8_t auth_req;
uint8_t max_key_size; u8_t max_key_size;
uint8_t init_key_dist; u8_t init_key_dist;
uint8_t resp_key_dist; u8_t resp_key_dist;
} __packed; } __packed;
#define BT_SMP_CMD_PAIRING_CONFIRM 0x03 #define BT_SMP_CMD_PAIRING_CONFIRM 0x03
struct bt_smp_pairing_confirm { struct bt_smp_pairing_confirm {
uint8_t val[16]; u8_t val[16];
} __packed; } __packed;
#define BT_SMP_CMD_PAIRING_RANDOM 0x04 #define BT_SMP_CMD_PAIRING_RANDOM 0x04
struct bt_smp_pairing_random { struct bt_smp_pairing_random {
uint8_t val[16]; u8_t val[16];
} __packed; } __packed;
#define BT_SMP_CMD_PAIRING_FAIL 0x05 #define BT_SMP_CMD_PAIRING_FAIL 0x05
struct bt_smp_pairing_fail { struct bt_smp_pairing_fail {
uint8_t reason; u8_t reason;
} __packed; } __packed;
#define BT_SMP_CMD_ENCRYPT_INFO 0x06 #define BT_SMP_CMD_ENCRYPT_INFO 0x06
struct bt_smp_encrypt_info { struct bt_smp_encrypt_info {
uint8_t ltk[16]; u8_t ltk[16];
} __packed; } __packed;
#define BT_SMP_CMD_MASTER_IDENT 0x07 #define BT_SMP_CMD_MASTER_IDENT 0x07
struct bt_smp_master_ident { struct bt_smp_master_ident {
uint16_t ediv; u16_t ediv;
uint64_t rand; u64_t rand;
} __packed; } __packed;
#define BT_SMP_CMD_IDENT_INFO 0x08 #define BT_SMP_CMD_IDENT_INFO 0x08
struct bt_smp_ident_info { struct bt_smp_ident_info {
uint8_t irk[16]; u8_t irk[16];
} __packed; } __packed;
#define BT_SMP_CMD_IDENT_ADDR_INFO 0x09 #define BT_SMP_CMD_IDENT_ADDR_INFO 0x09
@ -103,31 +103,31 @@ struct bt_smp_ident_addr_info {
#define BT_SMP_CMD_SIGNING_INFO 0x0a #define BT_SMP_CMD_SIGNING_INFO 0x0a
struct bt_smp_signing_info { struct bt_smp_signing_info {
uint8_t csrk[16]; u8_t csrk[16];
} __packed; } __packed;
#define BT_SMP_CMD_SECURITY_REQUEST 0x0b #define BT_SMP_CMD_SECURITY_REQUEST 0x0b
struct bt_smp_security_request { struct bt_smp_security_request {
uint8_t auth_req; u8_t auth_req;
} __packed; } __packed;
#define BT_SMP_CMD_PUBLIC_KEY 0x0c #define BT_SMP_CMD_PUBLIC_KEY 0x0c
struct bt_smp_public_key { struct bt_smp_public_key {
uint8_t x[32]; u8_t x[32];
uint8_t y[32]; u8_t y[32];
} __packed; } __packed;
#define BT_SMP_DHKEY_CHECK 0x0d #define BT_SMP_DHKEY_CHECK 0x0d
struct bt_smp_dhkey_check { struct bt_smp_dhkey_check {
uint8_t e[16]; u8_t e[16];
} __packed; } __packed;
bool bt_smp_irk_matches(const uint8_t irk[16], const bt_addr_t *addr); bool bt_smp_irk_matches(const u8_t irk[16], const bt_addr_t *addr);
int bt_smp_create_rpa(const uint8_t irk[16], bt_addr_t *rpa); int bt_smp_create_rpa(const u8_t irk[16], bt_addr_t *rpa);
int bt_smp_send_pairing_req(struct bt_conn *conn); int bt_smp_send_pairing_req(struct bt_conn *conn);
int bt_smp_send_security_req(struct bt_conn *conn); int bt_smp_send_security_req(struct bt_conn *conn);
void bt_smp_update_keys(struct bt_conn *conn); void bt_smp_update_keys(struct bt_conn *conn);
bool bt_smp_get_tk(struct bt_conn *conn, uint8_t *tk); bool bt_smp_get_tk(struct bt_conn *conn, u8_t *tk);
int bt_smp_br_send_pairing_req(struct bt_conn *conn); int bt_smp_br_send_pairing_req(struct bt_conn *conn);

View file

@ -38,7 +38,7 @@ enum storage_access {
STORAGE_WRITE STORAGE_WRITE
}; };
static int storage_open(const bt_addr_le_t *addr, uint16_t key, static int storage_open(const bt_addr_le_t *addr, u16_t key,
enum storage_access access, fs_file_t *file) enum storage_access access, fs_file_t *file)
{ {
char path[STORAGE_PATH_MAX]; char path[STORAGE_PATH_MAX];
@ -78,7 +78,7 @@ static int storage_open(const bt_addr_le_t *addr, uint16_t key,
return fs_open(file, path); return fs_open(file, path);
} }
static ssize_t storage_read(const bt_addr_le_t *addr, uint16_t key, void *data, static ssize_t storage_read(const bt_addr_le_t *addr, u16_t key, void *data,
size_t length) size_t length)
{ {
fs_file_t file; fs_file_t file;
@ -95,7 +95,7 @@ static ssize_t storage_read(const bt_addr_le_t *addr, uint16_t key, void *data,
return ret; return ret;
} }
static ssize_t storage_write(const bt_addr_le_t *addr, uint16_t key, static ssize_t storage_write(const bt_addr_le_t *addr, u16_t key,
const void *data, size_t length) const void *data, size_t length)
{ {
fs_file_t file; fs_file_t file;

View file

@ -82,8 +82,8 @@ int bt_uuid_cmp(const struct bt_uuid *u1, const struct bt_uuid *u2)
#if defined(CONFIG_BLUETOOTH_DEBUG) #if defined(CONFIG_BLUETOOTH_DEBUG)
void bt_uuid_to_str(const struct bt_uuid *uuid, char *str, size_t len) void bt_uuid_to_str(const struct bt_uuid *uuid, char *str, size_t len)
{ {
uint32_t tmp1, tmp5; u32_t tmp1, tmp5;
uint16_t tmp0, tmp2, tmp3, tmp4; u16_t tmp0, tmp2, tmp3, tmp4;
switch (uuid->type) { switch (uuid->type) {
case BT_UUID_TYPE_16: case BT_UUID_TYPE_16: