Compare commits
15 Commits
collab-sdk
...
v2.0-branc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8746c3fd01 | ||
|
|
a4aaf8bbf4 | ||
|
|
f8ba0cccb7 | ||
|
|
1b31b7eb79 | ||
|
|
0bab5dcec1 | ||
|
|
feef3a64ca | ||
|
|
3bfd36efd1 | ||
|
|
2f507cd9ff | ||
|
|
5ccd5c753d | ||
|
|
d515cf298a | ||
|
|
1ebe758115 | ||
|
|
7304c52ecc | ||
|
|
d4a1812e9e | ||
|
|
cc004036f6 | ||
|
|
ca3eb0eb31 |
@@ -14,7 +14,7 @@ from local_util import run_cmd_get_output
|
||||
def get_github_rev():
|
||||
tag = run_cmd_get_output('git describe --exact-match')
|
||||
if tag:
|
||||
return tag
|
||||
return tag.decode("utf-8")
|
||||
else:
|
||||
return 'master'
|
||||
|
||||
|
||||
@@ -210,24 +210,32 @@ static inline void handle_addr(struct device *dev)
|
||||
}
|
||||
}
|
||||
|
||||
if (data->current.is_write || data->current.len > 2) {
|
||||
if (data->current.is_write) {
|
||||
LL_I2C_ClearFlag_ADDR(i2c);
|
||||
return;
|
||||
}
|
||||
if (data->current.len == 0U) {
|
||||
/* according to STM32F1 errata we need to handle these corner cases in
|
||||
* specific way.
|
||||
* Please ref to STM32F10xxC/D/E I2C peripheral Errata sheet 2.14.1
|
||||
*/
|
||||
if (data->current.len == 0U && IS_ENABLED(CONFIG_SOC_SERIES_STM32F1X)) {
|
||||
LL_I2C_GenerateStopCondition(i2c);
|
||||
LL_I2C_ClearFlag_ADDR(i2c);
|
||||
} else if (data->current.len == 1U) {
|
||||
/* Single byte reception: enable NACK and clear POS */
|
||||
LL_I2C_AcknowledgeNextData(i2c, LL_I2C_NACK);
|
||||
#ifdef CONFIG_SOC_SERIES_STM32F1X
|
||||
LL_I2C_ClearFlag_ADDR(i2c);
|
||||
LL_I2C_GenerateStopCondition(i2c);
|
||||
#endif
|
||||
} else if (data->current.len == 2U) {
|
||||
/* 2-byte reception: enable NACK and set POS */
|
||||
#ifdef CONFIG_SOC_SERIES_STM32F1X
|
||||
LL_I2C_ClearFlag_ADDR(i2c);
|
||||
#endif
|
||||
/* 2-byte reception: enable NACK and set POS */
|
||||
LL_I2C_AcknowledgeNextData(i2c, LL_I2C_NACK);
|
||||
LL_I2C_EnableBitPOS(i2c);
|
||||
}
|
||||
LL_I2C_ClearFlag_ADDR(i2c);
|
||||
}
|
||||
|
||||
static inline void handle_txe(struct device *dev)
|
||||
|
||||
@@ -286,7 +286,12 @@ static void stm32_i2c_event(struct device *dev)
|
||||
if (LL_I2C_IsActiveFlag_NACK(i2c)) {
|
||||
LL_I2C_ClearFlag_NACK(i2c);
|
||||
data->current.is_nack = 1U;
|
||||
goto end;
|
||||
/*
|
||||
* AutoEndMode is always disabled in master mode,
|
||||
* so send a stop condition manually
|
||||
*/
|
||||
LL_I2C_GenerateStopCondition(i2c);
|
||||
return;
|
||||
}
|
||||
|
||||
/* STOP received */
|
||||
|
||||
@@ -152,7 +152,7 @@
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
reg = <0x40013000 0x400>;
|
||||
clocks = <&rcc STM32_CLOCK_BUS_APB2 0x00001000>;
|
||||
clocks = <&rcc STM32_CLOCK_BUS_APB1_2 0x00001000>;
|
||||
interrupts = <25 3>;
|
||||
status = "disabled";
|
||||
label = "SPI_1";
|
||||
@@ -167,7 +167,7 @@
|
||||
timers1: timers@40012c00 {
|
||||
compatible = "st,stm32-timers";
|
||||
reg = <0x40012c00 0x400>;
|
||||
clocks = <&rcc STM32_CLOCK_BUS_APB2 0x00000800>;
|
||||
clocks = <&rcc STM32_CLOCK_BUS_APB1_2 0x00000800>;
|
||||
status = "disabled";
|
||||
label = "TIMERS_1";
|
||||
|
||||
@@ -247,7 +247,7 @@
|
||||
timers15: timers@40014000 {
|
||||
compatible = "st,stm32-timers";
|
||||
reg = <0x40014000 0x400>;
|
||||
clocks = <&rcc STM32_CLOCK_BUS_APB2 0x00010000>;
|
||||
clocks = <&rcc STM32_CLOCK_BUS_APB1_2 0x00010000>;
|
||||
status = "disabled";
|
||||
label = "TIMERS_15";
|
||||
|
||||
@@ -263,7 +263,7 @@
|
||||
timers16: timers@40014400 {
|
||||
compatible = "st,stm32-timers";
|
||||
reg = <0x40014400 0x400>;
|
||||
clocks = <&rcc STM32_CLOCK_BUS_APB2 0x00020000>;
|
||||
clocks = <&rcc STM32_CLOCK_BUS_APB1_2 0x00020000>;
|
||||
status = "disabled";
|
||||
label = "TIMERS_16";
|
||||
|
||||
@@ -279,7 +279,7 @@
|
||||
timers17: timers@40014800 {
|
||||
compatible = "st,stm32-timers";
|
||||
reg = <0x40014800 0x400>;
|
||||
clocks = <&rcc STM32_CLOCK_BUS_APB2 0x00040000>;
|
||||
clocks = <&rcc STM32_CLOCK_BUS_APB1_2 0x00040000>;
|
||||
status = "disabled";
|
||||
label = "TIMERS_17";
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "hal/ticker.h"
|
||||
|
||||
#include "util/util.h"
|
||||
#include "util/mem.h"
|
||||
#include "util/memq.h"
|
||||
#include "util/mayfly.h"
|
||||
|
||||
@@ -443,11 +444,15 @@ u8_t ll_adv_enable(u8_t enable)
|
||||
return BT_HCI_ERR_CMD_DISALLOWED;
|
||||
}
|
||||
|
||||
/* remember addr to use and also update the addr in
|
||||
* both adv and scan response PDUs.
|
||||
*/
|
||||
lll = &adv->lll;
|
||||
|
||||
pdu_adv = lll_adv_data_peek(lll);
|
||||
if (pdu_adv->tx_addr) {
|
||||
if (!mem_nz(ll_addr_get(1, NULL), BDADDR_SIZE)) {
|
||||
return BT_HCI_ERR_INVALID_PARAM;
|
||||
}
|
||||
}
|
||||
|
||||
pdu_scan = lll_adv_scan_rsp_peek(lll);
|
||||
|
||||
if (0) {
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "hal/ticker.h"
|
||||
|
||||
#include "util/util.h"
|
||||
#include "util/mem.h"
|
||||
#include "util/memq.h"
|
||||
#include "util/mayfly.h"
|
||||
|
||||
@@ -79,6 +80,12 @@ u8_t ll_scan_enable(u8_t enable)
|
||||
return BT_HCI_ERR_CMD_DISALLOWED;
|
||||
}
|
||||
|
||||
if (scan->own_addr_type & 0x1) {
|
||||
if (!mem_nz(ll_addr_get(1, NULL), BDADDR_SIZE)) {
|
||||
return BT_HCI_ERR_INVALID_PARAM;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_PRIVACY)
|
||||
struct lll_scan *lll = &scan->lll;
|
||||
ull_filter_scan_update(lll->filter_policy);
|
||||
|
||||
@@ -1965,6 +1965,10 @@ static att_type_t att_op_get_type(u8_t op)
|
||||
return ATT_INDICATION;
|
||||
}
|
||||
|
||||
if (op & ATT_CMD_MASK) {
|
||||
return ATT_COMMAND;
|
||||
}
|
||||
|
||||
return ATT_UNKNOWN;
|
||||
}
|
||||
|
||||
@@ -2095,18 +2099,18 @@ static void att_reset(struct bt_att *att)
|
||||
{
|
||||
struct bt_att_req *req, *tmp;
|
||||
int i;
|
||||
#if CONFIG_BT_ATT_PREPARE_COUNT > 0
|
||||
struct net_buf *buf;
|
||||
|
||||
#if CONFIG_BT_ATT_PREPARE_COUNT > 0
|
||||
/* Discard queued buffers */
|
||||
while ((buf = k_fifo_get(&att->prep_queue, K_NO_WAIT))) {
|
||||
net_buf_unref(buf);
|
||||
}
|
||||
#endif /* CONFIG_BT_ATT_PREPARE_COUNT > 0 */
|
||||
|
||||
while ((buf = k_fifo_get(&att->tx_queue, K_NO_WAIT))) {
|
||||
net_buf_unref(buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
atomic_set_bit(att->flags, ATT_DISCONNECTED);
|
||||
|
||||
|
||||
@@ -1986,73 +1986,6 @@ static void bt_conn_set_param_le(struct bt_conn *conn,
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BT_WHITELIST)
|
||||
int bt_le_whitelist_add(const bt_addr_le_t *addr)
|
||||
{
|
||||
struct bt_hci_cp_le_add_dev_to_wl *cp;
|
||||
struct net_buf *buf;
|
||||
int err;
|
||||
|
||||
if (!(bt_dev.le.wl_entries < bt_dev.le.wl_size)) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
buf = bt_hci_cmd_create(BT_HCI_OP_LE_ADD_DEV_TO_WL, sizeof(*cp));
|
||||
if (!buf) {
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
cp = net_buf_add(buf, sizeof(*cp));
|
||||
bt_addr_le_copy(&cp->addr, addr);
|
||||
|
||||
err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_ADD_DEV_TO_WL, buf, NULL);
|
||||
if (err) {
|
||||
BT_ERR("Failed to add device to whitelist");
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
bt_dev.le.wl_entries++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_le_whitelist_rem(const bt_addr_le_t *addr)
|
||||
{
|
||||
struct bt_hci_cp_le_rem_dev_from_wl *cp;
|
||||
struct net_buf *buf;
|
||||
int err;
|
||||
|
||||
buf = bt_hci_cmd_create(BT_HCI_OP_LE_REM_DEV_FROM_WL, sizeof(*cp));
|
||||
if (!buf) {
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
cp = net_buf_add(buf, sizeof(*cp));
|
||||
bt_addr_le_copy(&cp->addr, addr);
|
||||
|
||||
err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_REM_DEV_FROM_WL, buf, NULL);
|
||||
if (err) {
|
||||
BT_ERR("Failed to remove device from whitelist");
|
||||
return err;
|
||||
}
|
||||
|
||||
bt_dev.le.wl_entries--;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_le_whitelist_clear(void)
|
||||
{
|
||||
int err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_CLEAR_WL, NULL, NULL);
|
||||
|
||||
if (err) {
|
||||
BT_ERR("Failed to clear whitelist");
|
||||
return err;
|
||||
}
|
||||
|
||||
bt_dev.le.wl_entries = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_conn_create_auto_le(const struct bt_le_conn_param *param)
|
||||
{
|
||||
struct bt_conn *conn;
|
||||
|
||||
@@ -181,8 +181,6 @@ BT_GATT_SERVICE_DEFINE(_2_gap_svc,
|
||||
);
|
||||
|
||||
#if defined(CONFIG_BT_GATT_DYNAMIC_DB)
|
||||
static struct bt_gatt_ccc_cfg sc_ccc_cfg[BT_GATT_CCC_MAX] = {};
|
||||
|
||||
static void sc_ccc_cfg_changed(const struct bt_gatt_attr *attr,
|
||||
u16_t value)
|
||||
{
|
||||
@@ -1166,9 +1164,9 @@ static u8_t find_next(const struct bt_gatt_attr *attr, void *user_data)
|
||||
struct bt_gatt_attr *bt_gatt_attr_next(const struct bt_gatt_attr *attr)
|
||||
{
|
||||
struct bt_gatt_attr *next = NULL;
|
||||
u16_t handle = attr->handle ? : find_static_attr(attr);
|
||||
|
||||
bt_gatt_foreach_attr(attr->handle + 1, attr->handle + 1, find_next,
|
||||
&next);
|
||||
bt_gatt_foreach_attr(handle + 1, handle + 1, find_next, &next);
|
||||
|
||||
return next;
|
||||
}
|
||||
@@ -1357,6 +1355,20 @@ struct notify_data {
|
||||
};
|
||||
};
|
||||
|
||||
static int gatt_send_cb(struct bt_conn *conn, struct net_buf *buf,
|
||||
bt_conn_tx_cb_t cb, void *user_data)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = bt_att_send(conn, buf, cb, user_data);
|
||||
if (err) {
|
||||
net_buf_unref(buf);
|
||||
return err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gatt_notify(struct bt_conn *conn, u16_t handle,
|
||||
struct bt_gatt_notify_params *params)
|
||||
{
|
||||
@@ -1389,7 +1401,7 @@ static int gatt_notify(struct bt_conn *conn, u16_t handle,
|
||||
net_buf_add(buf, params->len);
|
||||
memcpy(nfy->value, params->data, params->len);
|
||||
|
||||
return bt_att_send(conn, buf, params->func, params->user_data);
|
||||
return gatt_send_cb(conn, buf, params->func, params->user_data);
|
||||
}
|
||||
|
||||
static void gatt_indicate_rsp(struct bt_conn *conn, u8_t err,
|
||||
@@ -1530,7 +1542,7 @@ static u8_t notify_cb(const struct bt_gatt_attr *attr, void *user_data)
|
||||
conn = bt_conn_lookup_addr_le(cfg->id, &cfg->peer);
|
||||
if (!conn) {
|
||||
#if defined(CONFIG_BT_GATT_DYNAMIC_DB)
|
||||
if (ccc->cfg == sc_ccc_cfg) {
|
||||
if (ccc->cfg_changed == sc_ccc_cfg_changed) {
|
||||
sc_save(cfg, data->ind_params);
|
||||
}
|
||||
#endif /* CONFIG_BT_GATT_DYNAMIC_DB */
|
||||
@@ -1738,7 +1750,7 @@ static u8_t connected_cb(const struct bt_gatt_attr *attr, void *user_data)
|
||||
if (ccc->cfg[i].value) {
|
||||
gatt_ccc_changed(attr, ccc);
|
||||
#if defined(CONFIG_BT_GATT_DYNAMIC_DB)
|
||||
if (ccc->cfg == sc_ccc_cfg) {
|
||||
if (ccc->cfg_changed == sc_ccc_cfg_changed) {
|
||||
sc_restore(&ccc->cfg[i]);
|
||||
}
|
||||
#endif /* CONFIG_BT_GATT_DYNAMIC_DB */
|
||||
@@ -2926,7 +2938,7 @@ int bt_gatt_write_without_response_cb(struct bt_conn *conn, u16_t handle,
|
||||
|
||||
BT_DBG("handle 0x%04x length %u", handle, length);
|
||||
|
||||
return bt_att_send(conn, buf, func, user_data);
|
||||
return gatt_send_cb(conn, buf, func, user_data);
|
||||
}
|
||||
|
||||
static int gatt_exec_write(struct bt_conn *conn,
|
||||
|
||||
@@ -5937,6 +5937,75 @@ int bt_le_scan_stop(void)
|
||||
}
|
||||
#endif /* CONFIG_BT_OBSERVER */
|
||||
|
||||
#if defined(CONFIG_BT_WHITELIST)
|
||||
int bt_le_whitelist_add(const bt_addr_le_t *addr)
|
||||
{
|
||||
struct bt_hci_cp_le_add_dev_to_wl *cp;
|
||||
struct net_buf *buf;
|
||||
int err;
|
||||
|
||||
if (!(bt_dev.le.wl_entries < bt_dev.le.wl_size)) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
buf = bt_hci_cmd_create(BT_HCI_OP_LE_ADD_DEV_TO_WL, sizeof(*cp));
|
||||
if (!buf) {
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
cp = net_buf_add(buf, sizeof(*cp));
|
||||
bt_addr_le_copy(&cp->addr, addr);
|
||||
|
||||
err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_ADD_DEV_TO_WL, buf, NULL);
|
||||
if (err) {
|
||||
BT_ERR("Failed to add device to whitelist");
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
bt_dev.le.wl_entries++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_le_whitelist_rem(const bt_addr_le_t *addr)
|
||||
{
|
||||
struct bt_hci_cp_le_rem_dev_from_wl *cp;
|
||||
struct net_buf *buf;
|
||||
int err;
|
||||
|
||||
buf = bt_hci_cmd_create(BT_HCI_OP_LE_REM_DEV_FROM_WL, sizeof(*cp));
|
||||
if (!buf) {
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
cp = net_buf_add(buf, sizeof(*cp));
|
||||
bt_addr_le_copy(&cp->addr, addr);
|
||||
|
||||
err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_REM_DEV_FROM_WL, buf, NULL);
|
||||
if (err) {
|
||||
BT_ERR("Failed to remove device from whitelist");
|
||||
return err;
|
||||
}
|
||||
|
||||
bt_dev.le.wl_entries--;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_le_whitelist_clear(void)
|
||||
{
|
||||
int err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_CLEAR_WL, NULL, NULL);
|
||||
|
||||
if (err) {
|
||||
BT_ERR("Failed to clear whitelist");
|
||||
return err;
|
||||
}
|
||||
|
||||
bt_dev.le.wl_entries = 0;
|
||||
return 0;
|
||||
}
|
||||
#endif /* defined(CONFIG_BT_WHITELIST) */
|
||||
|
||||
int bt_le_set_chan_map(u8_t chan_map[5])
|
||||
{
|
||||
struct bt_hci_cp_le_set_host_chan_classif *cp;
|
||||
|
||||
@@ -513,8 +513,7 @@ bool bt_mesh_fixed_group_match(u16_t addr)
|
||||
case BT_MESH_ADDR_ALL_NODES:
|
||||
return true;
|
||||
case BT_MESH_ADDR_PROXIES:
|
||||
/* TODO: Proxy not yet supported */
|
||||
return false;
|
||||
return (bt_mesh_gatt_proxy_get() == BT_MESH_GATT_PROXY_ENABLED);
|
||||
case BT_MESH_ADDR_FRIENDS:
|
||||
return (bt_mesh_friend_get() == BT_MESH_FRIEND_ENABLED);
|
||||
case BT_MESH_ADDR_RELAYS:
|
||||
|
||||
@@ -663,7 +663,7 @@ static void clear_procedure_start(struct bt_mesh_friend *frnd)
|
||||
{
|
||||
BT_DBG("LPN 0x%04x (old) Friend 0x%04x", frnd->lpn, frnd->clear.frnd);
|
||||
|
||||
frnd->clear.start = k_uptime_get_32() + (2 * frnd->poll_to);
|
||||
frnd->clear.start = k_uptime_get_32();
|
||||
frnd->clear.repeat_sec = 1U;
|
||||
|
||||
send_friend_clear(frnd);
|
||||
|
||||
@@ -970,7 +970,7 @@ static void prov_confirm(const u8_t *data)
|
||||
|
||||
static void prov_random(const u8_t *data)
|
||||
{
|
||||
PROV_BUF(rnd, 16);
|
||||
PROV_BUF(rnd, 17);
|
||||
u8_t conf_verify[16];
|
||||
|
||||
BT_DBG("Remote Random: %s", bt_hex(data, 16));
|
||||
|
||||
@@ -577,6 +577,8 @@ struct gatt_attr {
|
||||
|
||||
#define GATT_GET_ATTRIBUTE_VALUE 0x1d
|
||||
struct gatt_get_attribute_value_cmd {
|
||||
u8_t address_type;
|
||||
u8_t address[6];
|
||||
u16_t handle;
|
||||
} __packed;
|
||||
struct gatt_get_attribute_value_rp {
|
||||
|
||||
Reference in New Issue
Block a user