File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 2525
2626#include " BLEDevice.h"
2727
28+ #include " ble/AdvertisingParameters.h"
29+ #include " ble/Gap.h"
30+
31+
2832extern " C" int strcasecmp (char const *a, char const *b);
2933
3034BLEDevice::BLEDevice () :
@@ -576,3 +580,25 @@ bool BLEDevice::discovered()
576580 return (_advertisementTypeMask & 0x18 ) != 0 ;
577581}
578582
583+ void BLEDevice::setTxPower (int8_t dbm) {
584+ if (!_ble_interface.hasInitialized ()) return ;
585+ _ble_interface.gap ().setTxPower (dbm);
586+ }
587+
588+ void BLEDevice::enableCodedPHYAdvertising (bool enabled) {
589+ if (!_ble_interface.hasInitialized ()) return ;
590+
591+ ble::AdvertisingParameters advParams (
592+ ble::advertising_type_t ::NON_CONNECTABLE_UNDIRECTED,
593+ ble::adv_interval_t (ble::millisecond_t (200 ))
594+ );
595+ if (enabled) {
596+ advParams.setPhy (ble::phy_t ::LE_1M, ble::phy_t ::LE_CODED);
597+ }
598+ auto & gap = _ble_interface.gap ();
599+ gap.setAdvertisingParameters (_adv_handle, advParams);
600+
601+ // Set TX power here if not using setTxPower separately
602+ gap.setTxPower (4 );
603+ }
604+
You can’t perform that action at this time.
0 commit comments