introduce GAP::getAddress() to fetch the MAC address.
This commit is contained in:
parent
8d7351c5f3
commit
2220853d1e
2 changed files with 17 additions and 0 deletions
16
nRF51Gap.cpp
16
nRF51Gap.cpp
|
@ -319,6 +319,22 @@ ble_error_t nRF51Gap::setAddress(addr_type_t type, const uint8_t address[BLE_GAP
|
|||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
ble_error_t nRF51Gap::getAddress(addr_type_t *typeP, uint8_t addressP[BLE_GAP_ADDR_LEN])
|
||||
{
|
||||
ble_gap_addr_t dev_addr;
|
||||
if (sd_ble_gap_address_get(&dev_addr) != NRF_SUCCESS) {
|
||||
return BLE_ERROR_PARAM_OUT_OF_RANGE;
|
||||
}
|
||||
|
||||
if (typeP != NULL) {
|
||||
*typeP = static_cast<addr_type_t>(dev_addr.addr_type);
|
||||
}
|
||||
if (addressP != NULL) {
|
||||
memcpy(addressP, dev_addr.addr, BLE_GAP_ADDR_LEN);
|
||||
}
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
ble_error_t nRF51Gap::setDeviceName(const uint8_t *deviceName)
|
||||
{
|
||||
ble_gap_conn_sec_mode_t sec_mode;
|
||||
|
|
|
@ -40,6 +40,7 @@ public:
|
|||
|
||||
/* Functions that must be implemented from Gap */
|
||||
virtual ble_error_t setAddress(addr_type_t type, const uint8_t address[BLE_GAP_ADDR_LEN]);
|
||||
virtual ble_error_t getAddress(addr_type_t *typeP, uint8_t addressP[BLE_GAP_ADDR_LEN]);
|
||||
virtual ble_error_t setAdvertisingData(const GapAdvertisingData &, const GapAdvertisingData &);
|
||||
virtual ble_error_t startAdvertising(const GapAdvertisingParams &);
|
||||
virtual ble_error_t stopAdvertising(void);
|
||||
|
|
Loading…
Reference in a new issue