Skip to content

Commit

Permalink
First step to add possibility to set BLE power level
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxdevel committed Oct 29, 2015
1 parent 7957b2d commit 9b416f5
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 14 deletions.
11 changes: 9 additions & 2 deletions BLEDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@

class BLEDevice;

typedef enum {
BLE_OUTPUT_POWER_MINUS_18DBM = 0x00, /**< Output power set to -18dBm */
BLE_OUTPUT_POWER_MINUS_12DBM = 0x01, /**< Output power set to -12dBm */
BLE_OUTPUT_POWER_MINUS_6DBM = 0x02, /**< Output power set to -6dBm */
BLE_OUTPUT_POWER_0DBM = 0x03 /**< Output power set to 0dBm - DEFAULT*/
} BLE_Tx_Power_Level;

class BLEDeviceEventListener
{
public:
Expand All @@ -32,8 +39,8 @@ class BLEDeviceEventListener

class BLEDevice
{
friend class BLEPeripheral;

friend class BLEPeripheral;
protected:
BLEDevice();

Expand Down
4 changes: 2 additions & 2 deletions BLEHIDPeripheral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ static const PROGMEM unsigned char hidInformationCharacteriticValue[] = { 0x11

BLEHIDPeripheral* BLEHIDPeripheral::_instance = NULL;

BLEHIDPeripheral::BLEHIDPeripheral(unsigned char req, unsigned char rdy, unsigned char rst) :
BLEPeripheral(req, rdy, rst),
BLEHIDPeripheral::BLEHIDPeripheral(BLE_Tx_Power_Level tx_power_level, unsigned char req, unsigned char rdy, unsigned char rst) :
BLEPeripheral(tx_power_level, req, rdy, rst),
_bleBondStore(),

_hidService("1812"),
Expand Down
2 changes: 1 addition & 1 deletion BLEHIDPeripheral.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class BLEHIDPeripheral : public BLEPeripheral
friend class BLEHID;

public:
BLEHIDPeripheral(unsigned char req, unsigned char rdy, unsigned char rst);
BLEHIDPeripheral(BLE_Tx_Power_Level tx_power_level, unsigned char req, unsigned char rdy, unsigned char rst);
~BLEHIDPeripheral();

void begin();
Expand Down
4 changes: 2 additions & 2 deletions BLEPeripheral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
#define DEFAULT_DEVICE_NAME "Arduino"
#define DEFAULT_APPEARANCE 0x0000

BLEPeripheral::BLEPeripheral(unsigned char req, unsigned char rdy, unsigned char rst) :
BLEPeripheral::BLEPeripheral(BLE_Tx_Power_Level tx_power_level, unsigned char req, unsigned char rdy, unsigned char rst) :
#if defined(NRF51) || defined(__RFduino__)
_nRF51822(),
#else
_nRF8001(req, rdy, rst),
_nRF8001(tx_power_level, req, rdy, rst),
#endif

_localName(NULL),
Expand Down
2 changes: 1 addition & 1 deletion BLEPeripheral.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class BLEPeripheral : public BLEDeviceEventListener,
public BLERemoteCharacteristicValueChangeListener
{
public:
BLEPeripheral(unsigned char req, unsigned char rdy, unsigned char rst);
BLEPeripheral(BLE_Tx_Power_Level tx_power_level, unsigned char req, unsigned char rdy, unsigned char rst);
virtual ~BLEPeripheral();

void begin();
Expand Down
1 change: 1 addition & 0 deletions BLEPeripheral.pnproj
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<Project name="BLEPeripheral"><Folder name="New Folder"></Folder><Folder name="New Folder"></Folder><MagicFolder excludeFiles="*.pnproj;*.pnps;*.bak;*.tmp" excludeFolders="CVS;.svn;.hg;.git" filter="*" name="examples" path="examples\"><MagicFolder excludeFiles="*.pnproj;*.pnps;*.bak;*.tmp" excludeFolders="CVS;.svn;.hg;.git" filter="*" name="ancs" path="ancs\"><File path="ancs.ino"></File></MagicFolder><MagicFolder excludeFiles="*.pnproj;*.pnps;*.bak;*.tmp" excludeFolders="CVS;.svn;.hg;.git" filter="*" name="Eddystone" path="Eddystone\"><MagicFolder excludeFiles="*.pnproj;*.pnps;*.bak;*.tmp" excludeFolders="CVS;.svn;.hg;.git" filter="*" name="EddystoneUID" path="EddystoneUID\"><File path="EddystoneUID.ino"></File></MagicFolder><MagicFolder excludeFiles="*.pnproj;*.pnps;*.bak;*.tmp" excludeFolders="CVS;.svn;.hg;.git" filter="*" name="EddystoneURL" path="EddystoneURL\"><File path="EddystoneURL.ino"></File></MagicFolder></MagicFolder><MagicFolder excludeFiles="*.pnproj;*.pnps;*.bak;*.tmp" excludeFolders="CVS;.svn;.hg;.git" filter="*" name="HID" path="HID\"><MagicFolder excludeFiles="*.pnproj;*.pnps;*.bak;*.tmp" excludeFolders="CVS;.svn;.hg;.git" filter="*" name="HID_joystick_mouse" path="HID_joystick_mouse\"><File path="HID_joystick_mouse.ino"></File></MagicFolder><MagicFolder excludeFiles="*.pnproj;*.pnps;*.bak;*.tmp" excludeFolders="CVS;.svn;.hg;.git" filter="*" name="HID_keyboard" path="HID_keyboard\"><File path="HID_keyboard.ino"></File></MagicFolder><MagicFolder excludeFiles="*.pnproj;*.pnps;*.bak;*.tmp" excludeFolders="CVS;.svn;.hg;.git" filter="*" name="HID_keypad" path="HID_keypad\"><File path="HID_keypad.ino"></File></MagicFolder><MagicFolder excludeFiles="*.pnproj;*.pnps;*.bak;*.tmp" excludeFolders="CVS;.svn;.hg;.git" filter="*" name="HID_test" path="HID_test\"><File path="HID_test.ino"></File></MagicFolder><MagicFolder excludeFiles="*.pnproj;*.pnps;*.bak;*.tmp" excludeFolders="CVS;.svn;.hg;.git" filter="*" name="HID_volume" path="HID_volume\"><File path="HID_volume.ino"></File></MagicFolder></MagicFolder><MagicFolder excludeFiles="*.pnproj;*.pnps;*.bak;*.tmp" excludeFolders="CVS;.svn;.hg;.git" filter="*" name="iBeacon" path="iBeacon\"><File path="iBeacon.ino"></File></MagicFolder><MagicFolder excludeFiles="*.pnproj;*.pnps;*.bak;*.tmp" excludeFolders="CVS;.svn;.hg;.git" filter="*" name="ir_bridge" path="ir_bridge\"><File path="ir_bridge.ino"></File></MagicFolder><MagicFolder excludeFiles="*.pnproj;*.pnps;*.bak;*.tmp" excludeFolders="CVS;.svn;.hg;.git" filter="*" name="led" path="led\"><File path="led.ino"></File></MagicFolder><MagicFolder excludeFiles="*.pnproj;*.pnps;*.bak;*.tmp" excludeFolders="CVS;.svn;.hg;.git" filter="*" name="led_callback" path="led_callback\"><File path="led_callback.ino"></File></MagicFolder><MagicFolder excludeFiles="*.pnproj;*.pnps;*.bak;*.tmp" excludeFolders="CVS;.svn;.hg;.git" filter="*" name="led_switch" path="led_switch\"><File path="led_switch.ino"></File></MagicFolder><MagicFolder excludeFiles="*.pnproj;*.pnps;*.bak;*.tmp" excludeFolders="CVS;.svn;.hg;.git" filter="*" name="RedBearLab" path="RedBearLab\"><MagicFolder excludeFiles="*.pnproj;*.pnps;*.bak;*.tmp" excludeFolders="CVS;.svn;.hg;.git" filter="*" name="BLEControllerSketch" path="BLEControllerSketch\"><File path="BLEControllerSketch.ino"></File><File path="Boards.h"></File></MagicFolder><MagicFolder excludeFiles="*.pnproj;*.pnps;*.bak;*.tmp" excludeFolders="CVS;.svn;.hg;.git" filter="*" name="SimpleChat" path="SimpleChat\"><File path="SimpleChat.ino"></File></MagicFolder><MagicFolder excludeFiles="*.pnproj;*.pnps;*.bak;*.tmp" excludeFolders="CVS;.svn;.hg;.git" filter="*" name="SimpleControls" path="SimpleControls\"><File path="SimpleControls.ino"></File></MagicFolder></MagicFolder><MagicFolder excludeFiles="*.pnproj;*.pnps;*.bak;*.tmp" excludeFolders="CVS;.svn;.hg;.git" filter="*" name="remote_service" path="remote_service\"><File path="remote_service.ino"></File></MagicFolder><MagicFolder excludeFiles="*.pnproj;*.pnps;*.bak;*.tmp" excludeFolders="CVS;.svn;.hg;.git" filter="*" name="remote_test" path="remote_test\"><File path="remote_test.ino"></File></MagicFolder><MagicFolder excludeFiles="*.pnproj;*.pnps;*.bak;*.tmp" excludeFolders="CVS;.svn;.hg;.git" filter="*" name="starter" path="starter\"><File path="starter.ino"></File></MagicFolder><MagicFolder excludeFiles="*.pnproj;*.pnps;*.bak;*.tmp" excludeFolders="CVS;.svn;.hg;.git" filter="*" name="temp_sensor" path="temp_sensor\"><File path="temp_sensor.ino"></File></MagicFolder><MagicFolder excludeFiles="*.pnproj;*.pnps;*.bak;*.tmp" excludeFolders="CVS;.svn;.hg;.git" filter="*" name="test" path="test\"><File path="test.ino"></File></MagicFolder><File path="README.md"></File></MagicFolder><MagicFolder excludeFiles="*.pnproj;*.pnps;*.bak;*.tmp" excludeFolders="CVS;.svn;.hg;.git" filter="*" name="utility" path="utility\"><MagicFolder excludeFiles="*.pnproj;*.pnps;*.bak;*.tmp" excludeFolders="CVS;.svn;.hg;.git" filter="*" name="RFduino" path="RFduino\"><File path="ble.h"></File><File path="ble_err.h"></File><File path="ble_gap.h"></File><File path="ble_gatt.h"></File><File path="ble_gattc.h"></File><File path="ble_gatts.h"></File><File path="ble_hci.h"></File><File path="ble_l2cap.h"></File><File path="ble_ranges.h"></File><File path="ble_types.h"></File><File path="nrf_error.h"></File><File path="nrf_error_sdm.h"></File><File path="nrf_error_soc.h"></File><File path="nrf_sdm.h"></File><File path="nrf_soc.h"></File><File path="nrf_svc.h"></File><File path="softdevice_assert.h"></File></MagicFolder><File path="aci.h"></File><File path="acilib.cpp"></File><File path="acilib.h"></File><File path="acilib_defs.h"></File><File path="acilib_if.h"></File><File path="acilib_types.h"></File><File path="aci_cmds.h"></File><File path="aci_evts.h"></File><File path="aci_protocol_defines.h"></File><File path="aci_queue.cpp"></File><File path="aci_queue.h"></File><File path="ble_assert.h"></File><File path="boards.h"></File><File path="dtm.h"></File><File path="hal_aci_tl.cpp"></File><File path="hal_aci_tl.h"></File><File path="hal_platform.h"></File><File path="lib_aci.cpp"></File><File path="lib_aci.h"></File><File path="README.md"></File></MagicFolder><File path="API.md"></File><File path="BLEAttribute.cpp"></File><File path="BLEAttribute.h"></File><File path="BLEBondStore.cpp"></File><File path="BLEBondStore.h"></File><File path="BLECentral.cpp"></File><File path="BLECentral.h"></File><File path="BLECharacteristic.cpp"></File><File path="BLECharacteristic.h"></File><File path="BLEConstantCharacteristic.cpp"></File><File path="BLEConstantCharacteristic.h"></File><File path="BLEDescriptor.cpp"></File><File path="BLEDescriptor.h"></File><File path="BLEDevice.cpp"></File><File path="BLEDevice.h"></File><File path="BLEDeviceLimits.h"></File><File path="BLEFixedLengthCharacteristic.cpp"></File><File path="BLEFixedLengthCharacteristic.h"></File><File path="BLEHID.cpp"></File><File path="BLEHID.h"></File><File path="BLEHIDPeripheral.cpp"></File><File path="BLEHIDPeripheral.h"></File><File path="BLEHIDReportMapCharacteristic.cpp"></File><File path="BLEHIDReportMapCharacteristic.h"></File><File path="BLEHIDReportReferenceDescriptor.cpp"></File><File path="BLEHIDReportReferenceDescriptor.h"></File><File path="BLEKeyboard.cpp"></File><File path="BLEKeyboard.h"></File><File path="BLELocalAttribute.cpp"></File><File path="BLELocalAttribute.h"></File><File path="BLEMouse.cpp"></File><File path="BLEMouse.h"></File><File path="BLEMultimedia.cpp"></File><File path="BLEMultimedia.h"></File><File path="BLEPeripheral.cpp"></File><File path="BLEPeripheral.h"></File><File path="BLEPeripheral.pnproj"></File><File path="BLEProgmemConstantCharacteristic.cpp"></File><File path="BLEProgmemConstantCharacteristic.h"></File><File path="BLERemoteAttribute.cpp"></File><File path="BLERemoteAttribute.h"></File><File path="BLERemoteCharacteristic.cpp"></File><File path="BLERemoteCharacteristic.h"></File><File path="BLERemoteService.cpp"></File><File path="BLERemoteService.h"></File><File path="BLEService.cpp"></File><File path="BLEService.h"></File><File path="BLESystemControl.cpp"></File><File path="BLESystemControl.h"></File><File path="BLETypedCharacteristic.h"></File><File path="BLETypedCharacteristics.cpp"></File><File path="BLETypedCharacteristics.h"></File><File path="BLEUtil.cpp"></File><File path="BLEUtil.h"></File><File path="BLEUuid.cpp"></File><File path="BLEUuid.h"></File><File path="EddystoneBeacon.cpp"></File><File path="EddystoneBeacon.h"></File><File path="iBeacon.cpp"></File><File path="iBeacon.h"></File><File path="keywords.txt"></File><File path="library.properties"></File><File path="LICENSE"></File><File path="nRF8001.cpp"></File><File path="nRF8001.h"></File><File path="nRF51822.cpp"></File><File path="nRF51822.h"></File><File path="README.md"></File></Project>
1 change: 1 addition & 0 deletions BLEPeripheral.pnps
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<pd><ViewState><e p="BLEPeripheral" x="true"></e><e p="BLEPeripheral\examples" x="false"></e><e p="BLEPeripheral\utility" x="false"></e></ViewState></pd>
4 changes: 2 additions & 2 deletions EddystoneBeacon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ static const char* EDDYSTONE_URL_BEACON_SUFFIX_SUBSTITUTIONS[] = {
".gov"
};

EddystoneBeacon::EddystoneBeacon(unsigned char req, unsigned char rdy, unsigned char rst) :
BLEPeripheral(req, rdy, rst),
EddystoneBeacon::EddystoneBeacon(BLE_Tx_Power_Level tx_power_level, unsigned char req, unsigned char rdy, unsigned char rst) :
BLEPeripheral(tx_power_level, req, rdy, rst),
_bleService("feaa"),
_bleCharacteristic("feab", BLERead | BLEBroadcast, MAX_SERVICE_DATA_SIZE)
{
Expand Down
2 changes: 1 addition & 1 deletion EddystoneBeacon.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class EddystoneBeacon : public BLEPeripheral
{
public:
EddystoneBeacon(unsigned char req, unsigned char rdy, unsigned char rst);
EddystoneBeacon(BLE_Tx_Power_Level tx_power_level, unsigned char req, unsigned char rdy, unsigned char rst);

void begin(char power, const BLEUuid& uid);
void begin(char power, const char* uri);
Expand Down
6 changes: 4 additions & 2 deletions nRF8001.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ uint16_t crc_16_ccitt(uint16_t crc, uint8_t * data_in, uint16_t data_len) {
return crc;
}

nRF8001::nRF8001(unsigned char req, unsigned char rdy, unsigned char rst) :
nRF8001::nRF8001(BLE_Tx_Power_Level power_level, unsigned char req, unsigned char rdy, unsigned char rst) :
BLEDevice(),

_localPipeInfo(NULL),
Expand All @@ -117,7 +117,9 @@ nRF8001::nRF8001(unsigned char req, unsigned char rdy, unsigned char rst) :
_dynamicDataSequenceNo(0),
_storeDynamicData(false),

_crcSeed(0xFFFF)
_crcSeed(0xFFFF),
_tx_power_level(power_level)

{
this->_aciState.aci_pins.reqn_pin = req;
this->_aciState.aci_pins.rdyn_pin = rdy;
Expand Down
4 changes: 3 additions & 1 deletion nRF8001.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class nRF8001 : protected BLEDevice
unsigned char rxReqPipe;
};

nRF8001(unsigned char req, unsigned char rdy, unsigned char rst);
nRF8001(BLE_Tx_Power_Level power_level, unsigned char req, unsigned char rdy, unsigned char rst);

virtual ~nRF8001();

Expand Down Expand Up @@ -103,6 +103,8 @@ class nRF8001 : protected BLEDevice
bool _storeDynamicData;

unsigned short _crcSeed;

BLE_Tx_Power_Level _tx_power_level;
};

#endif

0 comments on commit 9b416f5

Please sign in to comment.