mesh: after sync fixes continuation

This commit is contained in:
Krzysztof Kopyściński
2021-01-12 14:05:19 +01:00
committed by Łukasz Rymanowski
parent 5b090c9f5e
commit 13a7c75cba
8 changed files with 40 additions and 33 deletions
+1
View File
@@ -130,6 +130,7 @@ syscfg.vals:
BLE_MESH_FRIEND_QUEUE_SIZE: 32
BLE_MESH_RX_SEG_MAX: 13
BLE_MESH_TX_SEG_MSG_COUNT: 2
BLE_MAX_CONNECTIONS: 8
BLE_MESH_ADV_BUF_COUNT: 20
BLE_MESH_TX_SEG_MAX: 6
+4 -5
View File
@@ -4,8 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
#if BLE_MESH_CDB
#define BT_DBG_ENABLED MYNEWT_VAL(BLE_MESH_DEBUG_CDB)
#define LOG_MODULE_NAME bt_mesh_cdb
#include "log/log.h"
@@ -17,6 +15,8 @@
#include "mesh_priv.h"
#include "mesh/glue.h"
#if MYNEWT_VAL(BLE_MESH_CDB)
struct bt_mesh_cdb bt_mesh_cdb = {
.nodes = {
[0 ... (CONFIG_BT_MESH_NODE_COUNT - 1)] = {
@@ -85,7 +85,7 @@ static int addr_is_free(uint16_t addr_start, uint8_t num_elem, uint16_t *next)
*/
static uint16_t find_lowest_free_addr(uint8_t num_elem)
{
uint16_t addr = 1, next;
uint16_t addr = 1, next = 0;
int err, i;
/*
@@ -386,5 +386,4 @@ void bt_mesh_cdb_app_key_store(const struct bt_mesh_cdb_app_key *key)
bt_mesh_store_cdb_app_key(key);
}
}
#endif
#endif
+7 -6
View File
@@ -881,7 +881,7 @@ static void enqueue_offer(struct bt_mesh_friend *frnd, int8_t rssi)
}
if (encrypt_friend_pdu(frnd, buf, true)) {
return;
goto done;
}
frnd->counter++;
@@ -922,11 +922,7 @@ static int32_t offer_delay(struct bt_mesh_friend *frnd, int8_t rssi, uint8_t cri
BT_DBG("Local Delay calculated as %d ms", (int) delay);
if (delay < 100) {
return K_MSEC(100);
}
return K_MSEC(delay);
return MAX(delay, 100);
}
int bt_mesh_friend_req(struct bt_mesh_net_rx *rx, struct os_mbuf *buf)
@@ -1650,6 +1646,11 @@ void bt_mesh_friend_enqueue_rx(struct bt_mesh_net_rx *rx,
continue;
}
if (friend_lpn_matches(frnd, rx->sub->net_idx,
rx->ctx.addr)) {
continue;
}
if (!friend_queue_prepare_space(frnd, rx->ctx.addr, seq_auth,
seg_count)) {
continue;
+1 -1
View File
@@ -467,7 +467,7 @@ k_delayed_work_remaining_get (struct k_delayed_work *w)
int64_t k_uptime_get(void)
{
/* We should return ms */
return os_cputime_get32();
return ble_npl_time_ticks_to_ms32(ble_npl_time_get());
}
uint32_t k_uptime_get_32(void)
+2
View File
@@ -1072,6 +1072,8 @@ int bt_mesh_lpn_init(void)
BT_DBG("");
lpn->groups_changed = 0;
k_delayed_work_init(&lpn->timer, lpn_timeout);
if (lpn->state == BT_MESH_LPN_ENABLED) {
+21 -17
View File
@@ -989,29 +989,33 @@ static void notify_complete(void)
static int proxy_send(uint16_t conn_handle, const void *data, uint16_t len)
{
struct os_mbuf *om;
int err;
int err = 0;
BT_DBG("%u bytes: %s", len, bt_hex(data, len));
/* Different from Zephyr implementation: no parameter structure is required,
* so for PB and GATT procedure is the same
*/
#if (MYNEWT_VAL(BLE_MESH_GATT_PROXY) || MYNEWT_VAL(BLE_MESH_PB_GATT))
if (gatt_svc == MESH_GATT_PROXY || gatt_svc == MESH_GATT_PROV) {
#if (MYNEWT_VAL(BLE_MESH_GATT_PROXY))
if (gatt_svc == MESH_GATT_PROXY) {
om = ble_hs_mbuf_from_flat(data, len);
assert(om);
err = ble_gattc_notify_custom(conn_handle, svc_handles.prov_data_out_h, om);
if (!err) {
atomic_inc(&pending_notifications);
return err;
}
err = ble_gattc_notify_custom(conn_handle, svc_handles.proxy_data_out_h, om);
notify_complete();
}
#endif
notify_complete();
#if (MYNEWT_VAL(BLE_MESH_PB_GATT))
if (gatt_svc == MESH_GATT_PROV) {
om = ble_hs_mbuf_from_flat(data, len);
assert(om);
err = ble_gattc_notify_custom(conn_handle, svc_handles.prov_data_out_h, om);
notify_complete();
}
#endif
return 0;
if (!err) {
atomic_inc(&pending_notifications);
}
return err;
}
static int proxy_segment_and_send(uint16_t conn_handle, uint8_t type,
@@ -1234,14 +1238,14 @@ static int32_t gatt_proxy_advertise(struct bt_mesh_subnet *sub)
BT_DBG("");
if (conn_count == CONFIG_BT_MAX_CONN) {
BT_DBG("Connectable advertising deferred (max connections)");
return remaining;
BT_DBG("Connectable advertising deferred (max connections %d)", conn_count);
return -ENOMEM;
}
sub = beacon_sub ? beacon_sub : bt_mesh_subnet_next(beacon_sub);
if (!sub) {
BT_WARN("No subnets to advertise on");
return remaining;
return -ENOENT;
}
if (sub->node_id == BT_MESH_NODE_IDENTITY_RUNNING) {
+1 -1
View File
@@ -2719,7 +2719,7 @@ struct shell_cmd_help cmd_del_fault_help = {
NULL, "[Fault ID]", NULL
};
#if defined(CONFIG_BT_MESH_CDB)
#if BLE_MESH_CDB
struct shell_cmd_help cmd_cdb_create_help = {
NULL, "[NetKey]", NULL
};
+3 -3
View File
@@ -546,6 +546,7 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, struct os_mbuf *sdu,
k_mem_slab_free(&segs, &buf);
tx->seg[seg_o] = NULL;
}
os_mbuf_free_chain(seg);
}
}
@@ -1025,6 +1026,7 @@ int bt_mesh_ctl_send(struct bt_mesh_net_tx *tx, uint8_t ctl_op, void *data,
} else {
return send_unseg(tx, buf, cb, cb_data, &ctl_op);
}
os_mbuf_free_chain(buf);
}
static int send_ack(struct bt_mesh_subnet *sub, uint16_t src, uint16_t dst,
@@ -1425,9 +1427,6 @@ found_rx:
os_mbuf_copydata(buf, 0, buf->om_len, rx->seg[seg_o]);
BT_DBG("copied %s", bt_hex(rx->seg[seg_o], rx->len));
if (segs.free_list) {
BT_DBG("segs free list not null: %c", segs.free_list)
}
BT_DBG("Received %u/%u", seg_o, seg_n);
@@ -1473,6 +1472,7 @@ found_rx:
sdu, seg_buf->om_data, rx->len - APP_MIC_LEN(ASZMIC(hdr)));
err = sdu_recv(net_rx, *hdr, ASZMIC(hdr), seg_buf, sdu, rx);
os_mbuf_free_chain(seg_buf);
}
seg_rx_reset(rx, false);