Introduces new config flag PRST_BLE_EXPERIMENTAL_LONG_RANGE

This flags makes use of the Coded PHY from Bluetooth 5. It should be
treated as an experimental feature and it's disabled by default.
Note that clients (such as ESPHomme) would also have to scan on the
Coded PHY to be able to find b-parasites operating in this mode.
Currently, no client does that. Thus the feature is disabled and marked
as experimental.
This commit is contained in:
rbaron 2022-08-03 23:11:42 +02:00
parent 0e9b9feb97
commit a7732f106b
2 changed files with 16 additions and 2 deletions

View file

@ -2,7 +2,6 @@
#define _PRST_CONFIG_H_
#include "nrf_gpio.h"
// Some configurations are version-specific. Uncomment the line corresponding
// the the version you're programming. The version can be found on the
// b-parasite board.
@ -51,6 +50,11 @@
#define PRST_BLE_ADV_INTERVAL_IN_MS 30
// Possible values are ..., -8, -4, 0, 4, 8.
#define PRST_BLE_ADV_TX_POWER 8
// Experimental support for "long range" BLE, introduced in Bluetooth 5. It uses
// a different type of physical layer - the Coded PHY. Receivers should also
// scan using Coded PHY in order to find this device when operating in this
// mode.
#define PRST_BLE_EXPERIMENTAL_LONG_RANGE 0
// PWM.
#define PRST_PWM_PIN NRF_GPIO_PIN_MAP(0, 5)

View file

@ -72,7 +72,11 @@ static ble_advdata_service_data_t advdata_service_data_ = {
// Warning: do not update this while advertising.
static ble_advdata_t adv_data_ = {
.name_type = BLE_ADVDATA_FULL_NAME,
#if PRST_BLE_EXPERIMENTAL_LONG_RANGE
.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE,
#else
.flags = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED,
#endif
.p_service_data_array = &advdata_service_data_,
.service_data_count = 1,
};
@ -91,10 +95,16 @@ static ble_gap_addr_t gap_addr_ = {.addr_type =
static void init_advertisement_data() {
// We'll just broadcast our data, so we disallow connections and scan
// requests.
#if PRST_BLE_EXPERIMENTAL_LONG_RANGE
adv_params_.properties.type =
BLE_GAP_ADV_TYPE_EXTENDED_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED;
adv_params_.primary_phy = BLE_GAP_PHY_CODED;
adv_params_.secondary_phy = BLE_GAP_PHY_CODED;
#else
adv_params_.properties.type =
BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED;
#endif
// No particular peer - undirected advertisement.
adv_params_.p_peer_addr = NULL;
adv_params_.filter_policy = BLE_GAP_ADV_FP_ANY;
adv_params_.interval = NON_CONNECTABLE_ADV_INTERVAL;