move setTxPower() and getTxPowerLevels() into Gap.h

This commit is contained in:
Rohit Grover 2015-06-12 17:50:05 +01:00
parent 4d24dc24c9
commit efcb88a147
4 changed files with 30 additions and 30 deletions

View file

@ -71,33 +71,6 @@ const char *nRF51822n::getVersion(void)
return versionString;
}
/* (Valid values are -40, -20, -16, -12, -8, -4, 0, 4) */
ble_error_t nRF51822n::setTxPower(int8_t txPower)
{
unsigned rc;
if ((rc = sd_ble_gap_tx_power_set(txPower)) != NRF_SUCCESS) {
switch (rc) {
case NRF_ERROR_BUSY:
return BLE_STACK_BUSY;
case NRF_ERROR_INVALID_PARAM:
default:
return BLE_ERROR_PARAM_OUT_OF_RANGE;
}
}
return BLE_ERROR_NONE;
}
void nRF51822n::getPermittedTxPowerValues(const int8_t **valueArrayPP, size_t *countP)
{
static const int8_t permittedTxValues[] = {
-40, -30, -20, -16, -12, -8, -4, 0, 4
};
*valueArrayPP = permittedTxValues;
*countP = sizeof(permittedTxValues) / sizeof(int8_t);
}
ble_error_t nRF51822n::init(void)
{
/* ToDo: Clear memory contents, reset the SD, etc. */

View file

@ -40,9 +40,6 @@ public:
return nRF51GattServer::getInstance();
};
virtual ble_error_t setTxPower(int8_t txPower);
virtual void getPermittedTxPowerValues(const int8_t **valueArrayPP, size_t *countP);
virtual ble_error_t init(void);
virtual ble_error_t shutdown(void);
virtual ble_error_t reset(void);

View file

@ -378,3 +378,30 @@ ble_error_t nRF51Gap::getAppearance(uint16_t *appearanceP)
return BLE_ERROR_PARAM_OUT_OF_RANGE;
}
}
/* (Valid values are -40, -20, -16, -12, -8, -4, 0, 4) */
ble_error_t nRF51Gap::setTxPower(int8_t txPower)
{
unsigned rc;
if ((rc = sd_ble_gap_tx_power_set(txPower)) != NRF_SUCCESS) {
switch (rc) {
case NRF_ERROR_BUSY:
return BLE_STACK_BUSY;
case NRF_ERROR_INVALID_PARAM:
default:
return BLE_ERROR_PARAM_OUT_OF_RANGE;
}
}
return BLE_ERROR_NONE;
}
void nRF51Gap::getPermittedTxPowerValues(const int8_t **valueArrayPP, size_t *countP)
{
static const int8_t permittedTxValues[] = {
-40, -30, -20, -16, -12, -8, -4, 0, 4
};
*valueArrayPP = permittedTxValues;
*countP = sizeof(permittedTxValues) / sizeof(int8_t);
}

View file

@ -63,6 +63,9 @@ public:
virtual ble_error_t setAppearance(uint16_t appearance);
virtual ble_error_t getAppearance(uint16_t *appearanceP);
virtual ble_error_t setTxPower(int8_t txPower);
virtual void getPermittedTxPowerValues(const int8_t **valueArrayPP, size_t *countP);
void setConnectionHandle(uint16_t con_handle);
uint16_t getConnectionHandle(void);