Compare commits

...

15 Commits

Author SHA1 Message Date
Johan Hedberg
8746c3fd01 Bluetooth: Mesh: Fix matching for "All Proxies" group address
The bt_mesh_fixed_group_match() function is intended to match the
various well-known group addresses, however it was never updated when
Proxy support was added.

Fixes #19015

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-12-19 13:09:38 -05:00
Mariusz Skamra
a4aaf8bbf4 Bluetooth: ATT: Fix responding to unknown ATT command
Host shall ignore the unknown ATT PDU that has Command Flag set.
Fixes regression introduced in 3b271b8455.

Fixes: GATT/SR/UNS/BI-02-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2019-12-19 12:37:04 -05:00
Luiz Augusto von Dentz
f8ba0cccb7 Bluetooth: GATT: Fix not storing SC changes
CCC storaged is no longer declared separetly so check if ccc->cfg
matches with sc_ccc_cfg no longer works so instead use the cfg_changed
callback and match against sc_ccc_cfg_changed.

Fixes #19267

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-12-19 11:01:57 -05:00
Vinayak Kariappa Chettimada
1b31b7eb79 Bluetooth: controller: split: Fix to reject invalid enable command
Fix to reject invalid advertise and scan enable commands.

Fixes BT HCI.TS.5.1.1 tests:
HCI/DDI/BI-06-C
HCI/DDI/BI-07-C

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2019-12-19 11:01:37 -05:00
Mariusz Skamra
0bab5dcec1 Bluetooth: tester: Adapt to BTP Get Attribute Value API change
Adapt the gatt_get_attribute_value_cmd to recent changes in API.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2019-12-19 11:01:20 -05:00
Johan Hedberg
feef3a64ca Bluetooth: Mesh: Fix Clear Procedure start timestamp initialization
The start timestamp was supposed to signify the starting point of the
clear procedure. The code was incorrectly initializing it to the *end*
point of the procedure.

Fixes #19263

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-12-19 11:01:05 -05:00
Yannis Damigos
3bfd36efd1 i2c_ll_stm32_v2: Send STOP manually after NACK
In master trasmitter mode AutoEndMode is
always disabled, so we need to send STOP
manually if NACK is received.

Fixes #19059

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2019-12-19 11:00:44 -05:00
Joakim Andersson
2f507cd9ff Bluetooth: ATT: Fix disconnected ATT not releasing buffers
Fix bug in ATT reset handling, not releasing queued notification
buffers when the connection is terminated.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-12-19 11:00:16 -05:00
Joakim Andersson
5ccd5c753d Bluetooth: host: Fix whitelist for non-central bluetooth applications
Fix compilation issue when wanting to use whitelist in bluetooth
applications that does not have CONFIG_BT_CENTRAL defined.
These functions are useful even for broadcaster and observer roles.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-12-19 10:59:54 -05:00
Joakim Andersson
d515cf298a Bluetooth: GATT: Fix bug in bt_gatt_attr_next unable for static handles
Fix bug in bt_gatt_attr_next when given an attribute that has static
allocation. The handle is then 0 and the function would always return
the attribute with handle 1.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-12-19 10:59:37 -05:00
Lingao Meng
1ebe758115 Bluetooth: Mesh: Fixed Provision Random buffer size
Fixed some minor issues, missing a byte for opcode.

Fixes: #19767

Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
2019-12-19 10:58:59 -05:00
Joakim Andersson
7304c52ecc Bluetooth: GATT: Fix gatt buffer leak for write commands and notify
Fix GATT buffer leak when bt_att_send returns error the allocated
buffer is never freed. Discovered case where the link was disconnected
during the function call, so when GATT checkd the link was still
connected, but ATT checkd the link was disconnected.

Fixes: #19889

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-12-19 10:58:40 -05:00
Erwan Gouriou
d4a1812e9e dt: stm32f0: Fix clock bus for SPI1 and few timers
There is no APB2 bus on stm32f0 series.
What could be found as APB2 in CMSIS files is actually
second group of APB (A.K.A APB1_2).
Fix nodes that are using this wrong reference accorss the series.

Fixes #20310

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2019-12-19 10:58:20 -05:00
Pavlo Hamov
cc004036f6 drivers: i2c: stm32_Slave: Fix addr flag handling
In the main Addr handler code the F1 workaround was used.
Add compile time swith depending on SOC family.
So workaround is not afffecting F2/F4 families.

Signed-off-by: Pavlo Hamov <pavlo_hamov@jabil.com>
2019-12-19 10:57:43 -05:00
Anas Nashif
ca3eb0eb31 doc: link-roles: convert bytes to string
Get the correct branch name as a string instead of bytes.

Fixes #19165

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-09-17 04:37:48 +08:00
14 changed files with 139 additions and 95 deletions

View File

@@ -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'

View File

@@ -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)

View File

@@ -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 */

View File

@@ -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";

View File

@@ -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) {

View File

@@ -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);

View File

@@ -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);

View File

@@ -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;

View File

@@ -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,

View File

@@ -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;

View File

@@ -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:

View File

@@ -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);

View File

@@ -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));

View File

@@ -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 {