From 79f5b1719bc0d6f3f9b5fa2b28d38c2575aee092 Mon Sep 17 00:00:00 2001 From: Andrzej Kaczmarek Date: Mon, 20 Nov 2017 14:11:08 +0100 Subject: [PATCH 1/4] nimble/host: Use static buffer for GAP mempool It is only allocated on startup and host initialization will fail in case it cannot be allocated, so let's just make it static. X-Original-Commit: 881eae1633d347a9a30019e90ffe17585f467abf --- nimble/host/src/ble_gap.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/nimble/host/src/ble_gap.c b/nimble/host/src/ble_gap.c index ed8fb0c13..ba58f79e7 100644 --- a/nimble/host/src/ble_gap.c +++ b/nimble/host/src/ble_gap.c @@ -22,7 +22,6 @@ #include #include "bsp/bsp.h" #include "os/os.h" -#include "mem/mem.h" #include "nimble/nimble_opt.h" #include "host/ble_hs_adv.h" #include "host/ble_hs_hci.h" @@ -172,7 +171,9 @@ struct ble_gap_snapshot { void *cb_arg; }; -static void *ble_gap_update_entry_mem; +static os_membuf_t ble_gap_update_entry_mem[ + OS_MEMPOOL_SIZE(BLE_GAP_MAX_UPDATE_ENTRIES, + sizeof (struct ble_gap_update_entry))]; static struct os_mempool ble_gap_update_entry_pool; static struct ble_gap_update_entry_list ble_gap_update_entries; @@ -4413,18 +4414,16 @@ ble_gap_init(void) { int rc; - free(ble_gap_update_entry_mem); - memset(&ble_gap_master, 0, sizeof ble_gap_master); memset(ble_gap_slave, 0, sizeof ble_gap_slave); SLIST_INIT(&ble_gap_update_entries); - rc = mem_malloc_mempool(&ble_gap_update_entry_pool, - BLE_GAP_MAX_UPDATE_ENTRIES, - sizeof (struct ble_gap_update_entry), - "ble_gap_update", - &ble_gap_update_entry_mem); + rc = os_mempool_init(&ble_gap_update_entry_pool, + BLE_GAP_MAX_UPDATE_ENTRIES, + sizeof (struct ble_gap_update_entry), + ble_gap_update_entry_mem, + "ble_gap_update"); switch (rc) { case 0: break; @@ -4446,8 +4445,5 @@ ble_gap_init(void) return 0; err: - free(ble_gap_update_entry_mem); - ble_gap_update_entry_mem = NULL; - return rc; } From ad860f9ea175dbe2f38ecce28c27c320be293a7a Mon Sep 17 00:00:00 2001 From: Andrzej Kaczmarek Date: Wed, 22 Nov 2017 13:51:26 +0100 Subject: [PATCH 2/4] nimble/host: Change services pkg init priorities Let's define following init priorities for service packages: - 301 for GAP - 302 for GATT - 303 for other services This will make services register in this order to upon discovery we'll always have GAP first, then GATT and other services. Note that this particular order is not required by is probably used by virtually any device as it makes sense to have mandatory services first. X-Original-Commit: a0c805462cc54167a339a9d62a265dbc7cb8dcf0 --- nimble/host/services/ans/pkg.yml | 2 +- nimble/host/services/gap/pkg.yml | 2 +- nimble/host/services/gatt/pkg.yml | 2 +- nimble/host/services/ias/pkg.yml | 2 +- nimble/host/services/lls/pkg.yml | 2 +- nimble/host/services/tps/pkg.yml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/nimble/host/services/ans/pkg.yml b/nimble/host/services/ans/pkg.yml index 8a14adfe7..345c93b68 100644 --- a/nimble/host/services/ans/pkg.yml +++ b/nimble/host/services/ans/pkg.yml @@ -31,4 +31,4 @@ pkg.deps: - net/nimble/host pkg.init: - ble_svc_ans_init: 300 + ble_svc_ans_init: 303 diff --git a/nimble/host/services/gap/pkg.yml b/nimble/host/services/gap/pkg.yml index 1b1900bd4..c68acea25 100644 --- a/nimble/host/services/gap/pkg.yml +++ b/nimble/host/services/gap/pkg.yml @@ -31,4 +31,4 @@ pkg.deps: - net/nimble/host pkg.init: - ble_svc_gap_init: 300 + ble_svc_gap_init: 301 diff --git a/nimble/host/services/gatt/pkg.yml b/nimble/host/services/gatt/pkg.yml index 278d67b09..8af1c9eee 100644 --- a/nimble/host/services/gatt/pkg.yml +++ b/nimble/host/services/gatt/pkg.yml @@ -31,4 +31,4 @@ pkg.deps: - net/nimble/host pkg.init: - ble_svc_gatt_init: 300 + ble_svc_gatt_init: 302 diff --git a/nimble/host/services/ias/pkg.yml b/nimble/host/services/ias/pkg.yml index a2c674875..0af4d5c07 100644 --- a/nimble/host/services/ias/pkg.yml +++ b/nimble/host/services/ias/pkg.yml @@ -31,4 +31,4 @@ pkg.deps: - net/nimble/host pkg.init: - ble_svc_ias_init: 300 + ble_svc_ias_init: 303 diff --git a/nimble/host/services/lls/pkg.yml b/nimble/host/services/lls/pkg.yml index 0a228847c..bab70ff0c 100644 --- a/nimble/host/services/lls/pkg.yml +++ b/nimble/host/services/lls/pkg.yml @@ -31,4 +31,4 @@ pkg.deps: - net/nimble/host pkg.init: - ble_svc_lls_init: 300 + ble_svc_lls_init: 303 diff --git a/nimble/host/services/tps/pkg.yml b/nimble/host/services/tps/pkg.yml index 59e536f0a..821d389dd 100644 --- a/nimble/host/services/tps/pkg.yml +++ b/nimble/host/services/tps/pkg.yml @@ -31,4 +31,4 @@ pkg.deps: - net/nimble/host pkg.init: - ble_svc_tps_init: 300 + ble_svc_tps_init: 303 From 4b9f966b66eefcb3c6d03b19e4ad64bc01ff6256 Mon Sep 17 00:00:00 2001 From: Andrzej Kaczmarek Date: Tue, 21 Nov 2017 14:39:36 +0100 Subject: [PATCH 3/4] nimble/mesh: Fix #include X-Original-Commit: 2885fec6cdb974c0b65ce0cba26560edce44f11f --- nimble/host/mesh/src/beacon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nimble/host/mesh/src/beacon.c b/nimble/host/mesh/src/beacon.c index 9558ae58f..ad7464a93 100644 --- a/nimble/host/mesh/src/beacon.c +++ b/nimble/host/mesh/src/beacon.c @@ -16,7 +16,7 @@ #include "host/ble_hs_log.h" #include "adv.h" -#include +#include "mesh_priv.h" #include "net.h" #include "prov.h" #include "crypto.h" From 9e48713b9aa6a63479a40323367b9a9e09b96c8f Mon Sep 17 00:00:00 2001 From: Andrzej Kaczmarek Date: Wed, 22 Nov 2017 14:04:25 +0100 Subject: [PATCH 4/4] nimble/mesh: Remove invalid typedef We should not redefine size_t. X-Original-Commit: f959b1cb2673fcc580caf211eb88f2fbe6b72c36 --- nimble/host/mesh/include/mesh/glue.h | 1 - 1 file changed, 1 deletion(-) diff --git a/nimble/host/mesh/include/mesh/glue.h b/nimble/host/mesh/include/mesh/glue.h index 18ed6b227..ec7febcb1 100644 --- a/nimble/host/mesh/include/mesh/glue.h +++ b/nimble/host/mesh/include/mesh/glue.h @@ -49,7 +49,6 @@ #define u64_t uint64_t #define s64_t int64_t #define s32_t int32_t -typedef size_t ssize_t; /** @brief Helper to declare elements of bt_data arrays *