Skip to content

Commit 3b23dc5

Browse files
authored
Merge pull request #290 from LDong-Arm/gap_api_update
Use new types for BLE address and Gap
2 parents cde2cb3 + 57dabf8 commit 3b23dc5

File tree

19 files changed

+143
-146
lines changed

19 files changed

+143
-146
lines changed

BLE_BatteryLevel/source/pretty_printer.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ inline void print_error(ble_error_t error, const char* msg)
6565
}
6666

6767
/** print device address to the terminal */
68-
inline void print_address(const BLEProtocol::AddressBytes_t &addr)
68+
inline void print_address(const ble::address_t &addr)
6969
{
7070
printf("%02x:%02x:%02x:%02x:%02x:%02x\r\n",
7171
addr[5], addr[4], addr[3], addr[2], addr[1], addr[0]);
@@ -74,20 +74,20 @@ inline void print_address(const BLEProtocol::AddressBytes_t &addr)
7474
inline void print_mac_address()
7575
{
7676
/* Print out device MAC address to the console*/
77-
BLEProtocol::AddressType_t addr_type;
78-
BLEProtocol::AddressBytes_t address;
79-
BLE::Instance().gap().getAddress(&addr_type, address);
77+
ble::own_address_type_t addr_type;
78+
ble::address_t address;
79+
BLE::Instance().gap().getAddress(addr_type, address);
8080
printf("DEVICE MAC ADDRESS: ");
8181
print_address(address);
8282
}
8383

84-
inline const char* phy_to_string(Gap::Phy_t phy) {
84+
inline const char* phy_to_string(ble::phy_t phy) {
8585
switch(phy.value()) {
86-
case Gap::Phy_t::LE_1M:
86+
case ble::phy_t::LE_1M:
8787
return "LE 1M";
88-
case Gap::Phy_t::LE_2M:
88+
case ble::phy_t::LE_2M:
8989
return "LE 2M";
90-
case Gap::Phy_t::LE_CODED:
90+
case ble::phy_t::LE_CODED:
9191
return "LE coded";
9292
default:
9393
return "invalid PHY";

BLE_Beacon/source/pretty_printer.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ inline void print_error(ble_error_t error, const char* msg)
6565
}
6666

6767
/** print device address to the terminal */
68-
inline void print_address(const BLEProtocol::AddressBytes_t &addr)
68+
inline void print_address(const ble::address_t &addr)
6969
{
7070
printf("%02x:%02x:%02x:%02x:%02x:%02x\r\n",
7171
addr[5], addr[4], addr[3], addr[2], addr[1], addr[0]);
@@ -74,20 +74,20 @@ inline void print_address(const BLEProtocol::AddressBytes_t &addr)
7474
inline void print_mac_address()
7575
{
7676
/* Print out device MAC address to the console*/
77-
BLEProtocol::AddressType_t addr_type;
78-
BLEProtocol::AddressBytes_t address;
79-
BLE::Instance().gap().getAddress(&addr_type, address);
77+
ble::own_address_type_t addr_type;
78+
ble::address_t address;
79+
BLE::Instance().gap().getAddress(addr_type, address);
8080
printf("DEVICE MAC ADDRESS: ");
8181
print_address(address);
8282
}
8383

84-
inline const char* phy_to_string(Gap::Phy_t phy) {
84+
inline const char* phy_to_string(ble::phy_t phy) {
8585
switch(phy.value()) {
86-
case Gap::Phy_t::LE_1M:
86+
case ble::phy_t::LE_1M:
8787
return "LE 1M";
88-
case Gap::Phy_t::LE_2M:
88+
case ble::phy_t::LE_2M:
8989
return "LE 2M";
90-
case Gap::Phy_t::LE_CODED:
90+
case ble::phy_t::LE_CODED:
9191
return "LE coded";
9292
default:
9393
return "invalid PHY";

BLE_Button/source/pretty_printer.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ inline void print_error(ble_error_t error, const char* msg)
6565
}
6666

6767
/** print device address to the terminal */
68-
inline void print_address(const BLEProtocol::AddressBytes_t &addr)
68+
inline void print_address(const ble::address_t &addr)
6969
{
7070
printf("%02x:%02x:%02x:%02x:%02x:%02x\r\n",
7171
addr[5], addr[4], addr[3], addr[2], addr[1], addr[0]);
@@ -74,20 +74,20 @@ inline void print_address(const BLEProtocol::AddressBytes_t &addr)
7474
inline void print_mac_address()
7575
{
7676
/* Print out device MAC address to the console*/
77-
BLEProtocol::AddressType_t addr_type;
78-
BLEProtocol::AddressBytes_t address;
79-
BLE::Instance().gap().getAddress(&addr_type, address);
77+
ble::own_address_type_t addr_type;
78+
ble::address_t address;
79+
BLE::Instance().gap().getAddress(addr_type, address);
8080
printf("DEVICE MAC ADDRESS: ");
8181
print_address(address);
8282
}
8383

84-
inline const char* phy_to_string(Gap::Phy_t phy) {
84+
inline const char* phy_to_string(ble::phy_t phy) {
8585
switch(phy.value()) {
86-
case Gap::Phy_t::LE_1M:
86+
case ble::phy_t::LE_1M:
8787
return "LE 1M";
88-
case Gap::Phy_t::LE_2M:
88+
case ble::phy_t::LE_2M:
8989
return "LE 2M";
90-
case Gap::Phy_t::LE_CODED:
90+
case ble::phy_t::LE_CODED:
9191
return "LE coded";
9292
default:
9393
return "invalid PHY";

BLE_GAP/source/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ class GapDemo : private mbed::NonCopyable<GapDemo>, public ble::Gap::EventHandle
443443
/* skip non discoverable device */
444444
if (field.type != ble::adv_data_type_t::FLAGS ||
445445
field.value.size() != 1 ||
446-
!(field.value[0] & GapAdvertisingData::LE_GENERAL_DISCOVERABLE)) {
446+
!ble::adv_data_flags_t(field.value[0]).getGeneralDiscoverable()) {
447447
continue;
448448
}
449449

BLE_GAP/source/pretty_printer.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ inline void print_error(ble_error_t error, const char* msg)
6565
}
6666

6767
/** print device address to the terminal */
68-
inline void print_address(const BLEProtocol::AddressBytes_t &addr)
68+
inline void print_address(const ble::address_t &addr)
6969
{
7070
printf("%02x:%02x:%02x:%02x:%02x:%02x\r\n",
7171
addr[5], addr[4], addr[3], addr[2], addr[1], addr[0]);
@@ -74,20 +74,20 @@ inline void print_address(const BLEProtocol::AddressBytes_t &addr)
7474
inline void print_mac_address()
7575
{
7676
/* Print out device MAC address to the console*/
77-
BLEProtocol::AddressType_t addr_type;
78-
BLEProtocol::AddressBytes_t address;
79-
BLE::Instance().gap().getAddress(&addr_type, address);
77+
ble::own_address_type_t addr_type;
78+
ble::address_t address;
79+
BLE::Instance().gap().getAddress(addr_type, address);
8080
printf("DEVICE MAC ADDRESS: ");
8181
print_address(address);
8282
}
8383

84-
inline const char* phy_to_string(Gap::Phy_t phy) {
84+
inline const char* phy_to_string(ble::phy_t phy) {
8585
switch(phy.value()) {
86-
case Gap::Phy_t::LE_1M:
86+
case ble::phy_t::LE_1M:
8787
return "LE 1M";
88-
case Gap::Phy_t::LE_2M:
88+
case ble::phy_t::LE_2M:
8989
return "LE 2M";
90-
case Gap::Phy_t::LE_CODED:
90+
case ble::phy_t::LE_CODED:
9191
return "LE coded";
9292
default:
9393
return "invalid PHY";

BLE_GAPButton/source/pretty_printer.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ inline void print_error(ble_error_t error, const char* msg)
6565
}
6666

6767
/** print device address to the terminal */
68-
inline void print_address(const BLEProtocol::AddressBytes_t &addr)
68+
inline void print_address(const ble::address_t &addr)
6969
{
7070
printf("%02x:%02x:%02x:%02x:%02x:%02x\r\n",
7171
addr[5], addr[4], addr[3], addr[2], addr[1], addr[0]);
@@ -74,20 +74,20 @@ inline void print_address(const BLEProtocol::AddressBytes_t &addr)
7474
inline void print_mac_address()
7575
{
7676
/* Print out device MAC address to the console*/
77-
BLEProtocol::AddressType_t addr_type;
78-
BLEProtocol::AddressBytes_t address;
79-
BLE::Instance().gap().getAddress(&addr_type, address);
77+
ble::own_address_type_t addr_type;
78+
ble::address_t address;
79+
BLE::Instance().gap().getAddress(addr_type, address);
8080
printf("DEVICE MAC ADDRESS: ");
8181
print_address(address);
8282
}
8383

84-
inline const char* phy_to_string(Gap::Phy_t phy) {
84+
inline const char* phy_to_string(ble::phy_t phy) {
8585
switch(phy.value()) {
86-
case Gap::Phy_t::LE_1M:
86+
case ble::phy_t::LE_1M:
8787
return "LE 1M";
88-
case Gap::Phy_t::LE_2M:
88+
case ble::phy_t::LE_2M:
8989
return "LE 2M";
90-
case Gap::Phy_t::LE_CODED:
90+
case ble::phy_t::LE_CODED:
9191
return "LE coded";
9292
default:
9393
return "invalid PHY";

BLE_GattClient/source/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ class GattClientProcess : private mbed::NonCopyable<GattClientProcess>,
250250
*
251251
* @see GattClient::onServiceDiscoveryTermination
252252
*/
253-
void when_service_discovery_ends(Gap::Handle_t connection_handle)
253+
void when_service_discovery_ends(ble::connection_handle_t connection_handle)
254254
{
255255
if (!_characteristics) {
256256
printf("No characteristics discovered, end of the process.\r\n");
@@ -565,7 +565,7 @@ class GattClientProcess : private mbed::NonCopyable<GattClientProcess>,
565565
}
566566

567567
GattClient *_client;
568-
Gap::Handle_t _connection_handle;
568+
ble::connection_handle_t _connection_handle;
569569
DiscoveredCharacteristicNode *_characteristics;
570570
DiscoveredCharacteristicNode *_it;
571571
GattAttribute::Handle_t _descriptor_handle;

BLE_GattClient/source/pretty_printer.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ inline void print_error(ble_error_t error, const char* msg)
7171
}
7272

7373
/** print device address to the terminal */
74-
inline void print_address(const uint8_t *addr)
74+
inline void print_address(const ble::address_t addr)
7575
{
7676
printf("%02x:%02x:%02x:%02x:%02x:%02x\r\n",
7777
addr[5], addr[4], addr[3], addr[2], addr[1], addr[0]);
@@ -80,27 +80,27 @@ inline void print_address(const uint8_t *addr)
8080
inline void print_mac_address()
8181
{
8282
/* Print out device MAC address to the console*/
83-
BLEProtocol::AddressType_t addr_type;
84-
BLEProtocol::AddressBytes_t address;
85-
BLE::Instance().gap().getAddress(&addr_type, address);
83+
ble::own_address_type_t addr_type;
84+
ble::address_t address;
85+
BLE::Instance().gap().getAddress(addr_type, address);
8686
printf("DEVICE MAC ADDRESS: ");
8787
print_address(address);
8888

8989
if (!seeded) {
9090
seeded = true;
9191
/* use the address as a seed */
92-
uint8_t* random_data = address;
92+
uint8_t* random_data = address.data();
9393
srand(*((unsigned int*)random_data));
9494
}
9595
}
9696

97-
inline const char* phy_to_string(Gap::Phy_t phy) {
97+
inline const char* phy_to_string(ble::phy_t phy) {
9898
switch(phy.value()) {
99-
case Gap::Phy_t::LE_1M:
99+
case ble::phy_t::LE_1M:
100100
return "LE 1M";
101-
case Gap::Phy_t::LE_2M:
101+
case ble::phy_t::LE_2M:
102102
return "LE 2M";
103-
case Gap::Phy_t::LE_CODED:
103+
case ble::phy_t::LE_CODED:
104104
return "LE coded";
105105
default:
106106
return "invalid PHY";

BLE_GattServer/source/pretty_printer.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ inline void print_error(ble_error_t error, const char* msg)
7171
}
7272

7373
/** print device address to the terminal */
74-
inline void print_address(const uint8_t *addr)
74+
inline void print_address(const ble::address_t &addr)
7575
{
7676
printf("%02x:%02x:%02x:%02x:%02x:%02x\r\n",
7777
addr[5], addr[4], addr[3], addr[2], addr[1], addr[0]);
@@ -80,27 +80,27 @@ inline void print_address(const uint8_t *addr)
8080
inline void print_mac_address()
8181
{
8282
/* Print out device MAC address to the console*/
83-
BLEProtocol::AddressType_t addr_type;
84-
BLEProtocol::AddressBytes_t address;
85-
BLE::Instance().gap().getAddress(&addr_type, address);
83+
ble::own_address_type_t addr_type;
84+
ble::address_t address;
85+
BLE::Instance().gap().getAddress(addr_type, address);
8686
printf("DEVICE MAC ADDRESS: ");
8787
print_address(address);
8888

8989
if (!seeded) {
9090
seeded = true;
9191
/* use the address as a seed */
92-
uint8_t* random_data = address;
92+
uint8_t* random_data = address.data();
9393
srand(*((unsigned int*)random_data));
9494
}
9595
}
9696

97-
inline const char* phy_to_string(Gap::Phy_t phy) {
97+
inline const char* phy_to_string(ble::phy_t phy) {
9898
switch(phy.value()) {
99-
case Gap::Phy_t::LE_1M:
99+
case ble::phy_t::LE_1M:
100100
return "LE 1M";
101-
case Gap::Phy_t::LE_2M:
101+
case ble::phy_t::LE_2M:
102102
return "LE 2M";
103-
case Gap::Phy_t::LE_CODED:
103+
case ble::phy_t::LE_CODED:
104104
return "LE coded";
105105
default:
106106
return "invalid PHY";

BLE_HeartRate/source/pretty_printer.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ inline void print_error(ble_error_t error, const char* msg)
6565
}
6666

6767
/** print device address to the terminal */
68-
inline void print_address(const BLEProtocol::AddressBytes_t &addr)
68+
inline void print_address(const ble::address_t &addr)
6969
{
7070
printf("%02x:%02x:%02x:%02x:%02x:%02x\r\n",
7171
addr[5], addr[4], addr[3], addr[2], addr[1], addr[0]);
@@ -74,20 +74,20 @@ inline void print_address(const BLEProtocol::AddressBytes_t &addr)
7474
inline void print_mac_address()
7575
{
7676
/* Print out device MAC address to the console*/
77-
BLEProtocol::AddressType_t addr_type;
78-
BLEProtocol::AddressBytes_t address;
79-
BLE::Instance().gap().getAddress(&addr_type, address);
77+
ble::own_address_type_t addr_type;
78+
ble::address_t address;
79+
BLE::Instance().gap().getAddress(addr_type, address);
8080
printf("DEVICE MAC ADDRESS: ");
8181
print_address(address);
8282
}
8383

84-
inline const char* phy_to_string(Gap::Phy_t phy) {
84+
inline const char* phy_to_string(ble::phy_t phy) {
8585
switch(phy.value()) {
86-
case Gap::Phy_t::LE_1M:
86+
case ble::phy_t::LE_1M:
8787
return "LE 1M";
88-
case Gap::Phy_t::LE_2M:
88+
case ble::phy_t::LE_2M:
8989
return "LE 2M";
90-
case Gap::Phy_t::LE_CODED:
90+
case ble::phy_t::LE_CODED:
9191
return "LE coded";
9292
default:
9393
return "invalid PHY";

BLE_LED/source/pretty_printer.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ inline void print_error(ble_error_t error, const char* msg)
6565
}
6666

6767
/** print device address to the terminal */
68-
inline void print_address(const BLEProtocol::AddressBytes_t &addr)
68+
inline void print_address(const ble::address_t &addr)
6969
{
7070
printf("%02x:%02x:%02x:%02x:%02x:%02x\r\n",
7171
addr[5], addr[4], addr[3], addr[2], addr[1], addr[0]);
@@ -74,20 +74,20 @@ inline void print_address(const BLEProtocol::AddressBytes_t &addr)
7474
inline void print_mac_address()
7575
{
7676
/* Print out device MAC address to the console*/
77-
BLEProtocol::AddressType_t addr_type;
78-
BLEProtocol::AddressBytes_t address;
79-
BLE::Instance().gap().getAddress(&addr_type, address);
77+
ble::own_address_type_t addr_type;
78+
ble::address_t address;
79+
BLE::Instance().gap().getAddress(addr_type, address);
8080
printf("DEVICE MAC ADDRESS: ");
8181
print_address(address);
8282
}
8383

84-
inline const char* phy_to_string(Gap::Phy_t phy) {
84+
inline const char* phy_to_string(ble::phy_t phy) {
8585
switch(phy.value()) {
86-
case Gap::Phy_t::LE_1M:
86+
case ble::phy_t::LE_1M:
8787
return "LE 1M";
88-
case Gap::Phy_t::LE_2M:
88+
case ble::phy_t::LE_2M:
8989
return "LE 2M";
90-
case Gap::Phy_t::LE_CODED:
90+
case ble::phy_t::LE_CODED:
9191
return "LE coded";
9292
default:
9393
return "invalid PHY";

BLE_LEDBlinker/source/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void characteristic_discovery(const DiscoveredCharacteristic *characteristicP) {
5757
}
5858
}
5959

60-
void discovery_termination(Gap::Handle_t connectionHandle) {
60+
void discovery_termination(ble::connection_handle_t connectionHandle) {
6161
printf("terminated SD for handle %u\r\n", connectionHandle);
6262
if (trigger_led_characteristic) {
6363
trigger_led_characteristic = false;

0 commit comments

Comments
 (0)