Skip to content

Commit

Permalink
Reduced BLE TX radio power level to lower interference. Closes #22
Browse files Browse the repository at this point in the history
  • Loading branch information
tobbeanton committed Nov 30, 2017
1 parent b04bec1 commit 64d4afa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/ble/ble.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@
#define SEC_PARAM_MIN_KEY_SIZE 7 /**< Minimum encryption key size. */
#define SEC_PARAM_MAX_KEY_SIZE 16 /**< Maximum encryption key size. */

#define TX_POWER_LEVEL (-12) /**< TX Power Level value. This will be set both in the TX Power service, in the advertising data, and also used to set the radio transmit power. */

#define DEAD_BEEF 0xDEADBEEF /**< Value used as error code on stack dump, can be used to identify stack location on stack unwind. */

static ble_gap_sec_params_t m_sec_params; /**< Security requirements for this application. */
Expand Down Expand Up @@ -233,6 +235,9 @@ static void gap_params_init(void)

err_code = sd_ble_gap_ppcp_set(&gap_conn_params);
APP_ERROR_CHECK(err_code);

err_code = sd_ble_gap_tx_power_set(TX_POWER_LEVEL);
APP_ERROR_CHECK(err_code);
}


Expand All @@ -246,6 +251,7 @@ static void advertising_init(void)
uint32_t err_code;
ble_advdata_t advdata;
uint8_t flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
int8_t tx_power_level = TX_POWER_LEVEL;

ble_uuid_t adv_uuids[] =
{
Expand All @@ -261,6 +267,7 @@ static void advertising_init(void)
advdata.include_appearance = true;
advdata.flags.size = sizeof(flags);
advdata.flags.p_data = &flags;
advdata.p_tx_power_level = &tx_power_level;
advdata.uuids_more_available.uuid_cnt = sizeof(adv_uuids) / sizeof(adv_uuids[0]);
advdata.uuids_more_available.p_uuids = adv_uuids;

Expand Down Expand Up @@ -401,6 +408,14 @@ void ble_advertising_stop(void)
APP_ERROR_CHECK(err_code);
}

void ble_sd_stop(void)
{
uint32_t err_code;

err_code = sd_softdevice_disable();
APP_ERROR_CHECK(err_code);
}

/*****************************************************************************
* Static Event Handling Functions
*****************************************************************************/
Expand Down
2 changes: 2 additions & 0 deletions src/esb.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,8 @@ void esbSetDatarate(EsbDatarate dr)

void ble_advertising_stop(void);
void advertising_start(void);
void ble_sd_stop(void);

void esbSetContwave(bool enable)
{
contwave = enable;
Expand Down

0 comments on commit 64d4afa

Please sign in to comment.