Skip to content

Commit 29004ba

Browse files
committed
Update address types to align with the latest Mbed OS API changes
In ARMmbed/mbed-os#12730 we have removed legacy address-related types (BLEProtocol:: namespace) in favour of new once in ble:: namespace. This commit updates examples so they continue to work the latest Mbed OS.
1 parent 21bfa30 commit 29004ba

File tree

17 files changed

+74
-75
lines changed

17 files changed

+74
-75
lines changed

BLE_BatteryLevel/source/pretty_printer.h

Lines changed: 4 additions & 4 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,9 +74,9 @@ 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
}

BLE_Beacon/source/pretty_printer.h

Lines changed: 4 additions & 4 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,9 +74,9 @@ 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
}

BLE_Button/source/pretty_printer.h

Lines changed: 4 additions & 4 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,9 +74,9 @@ 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
}

BLE_GAP/source/main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,9 @@ int main()
771771

772772
while (1) {
773773
demo.run();
774+
printf("sleeping\n");
774775
thread_sleep_for(TIME_BETWEEN_MODES_MS);
776+
printf("done\n");
775777
printf("\r\nStarting next GAP demo mode\r\n");
776778
};
777779

BLE_GAP/source/pretty_printer.h

Lines changed: 4 additions & 4 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,9 +74,9 @@ 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
}

BLE_GAPButton/source/pretty_printer.h

Lines changed: 4 additions & 4 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,9 +74,9 @@ 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
}

BLE_GattClient/source/pretty_printer.h

Lines changed: 5 additions & 5 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,16 +80,16 @@ 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
}

BLE_GattServer/source/pretty_printer.h

Lines changed: 5 additions & 5 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,16 +80,16 @@ 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
}

BLE_HeartRate/source/pretty_printer.h

Lines changed: 4 additions & 4 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,9 +74,9 @@ 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
}

BLE_LED/source/pretty_printer.h

Lines changed: 4 additions & 4 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,9 +74,9 @@ 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
}

0 commit comments

Comments
 (0)