Skip to content

Commit 5f06fd2

Browse files
committed
move getPeerName to BLEConnection
1 parent a5bc1f7 commit 5f06fd2

File tree

15 files changed

+42
-21
lines changed

15 files changed

+42
-21
lines changed

changelog.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@
2121
- Bluefruit.setConnectCallback()/setDisconnectCallback() are replaced by BLEPeriph's setConnectCallback()/setDisconnectCallback()
2222
- Introduce BLEConnection class (Bluefruit.Connection(conn)) to mange both peripheral and central connections
2323
- Added setRssiCallback(), monitorRssi(), getRssi(), stopRssi() for tracking rssi of a connection. `rssi_poll` and `rssi_callback` are added as example sketches
24-
- Remove BLEGap, API functions are taken by Bluefruit, BLEPeriph, BLECentral
24+
- Remove BLEGap, API functions are taken by Bluefruit, BLEPeriph, BLECentral, BLEConnection
2525
- Gap.setAddr()/getAddr() are replaced by Bluefruit.setAddr()/getAddr()
26-
- Gap.getPeerName() is replaced by Bluefruit.getPeerName()
2726
- Gap.requestPairing() is replaced by Bluefruit.requestPairing(), conn_handle parameter is also added
2827
- Most of other functions of BLEGap are replaced by BLEConnection's one
2928
- BLECharacteristic

libraries/Bluefruit52Lib/examples/Central/central_bleuart_multi/central_bleuart_multi.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ void connect_callback(uint16_t conn_handle)
156156
prph_info_t* peer = &prphs[id];
157157
peer->conn_handle = conn_handle;
158158

159-
Bluefruit.getPeerName(conn_handle, peer->name, sizeof(peer->name)-1);
159+
Bluefruit.Connection(conn_handle)->getPeerName(peer->name, sizeof(peer->name)-1);
160160

161161
Serial.print("Connected to ");
162162
Serial.println(peer->name);

libraries/Bluefruit52Lib/examples/DualRoles/dual_bleuart/dual_bleuart.ino

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,11 @@ void loop()
121121
*------------------------------------------------------------------*/
122122
void prph_connect_callback(uint16_t conn_handle)
123123
{
124+
// Get the reference to current connection
125+
BLEConnection* connection = Bluefruit.Connection(conn_handle);
126+
124127
char peer_name[32] = { 0 };
125-
Bluefruit.getPeerName(conn_handle, peer_name, sizeof(peer_name));
128+
connection->getPeerName(peer_name, sizeof(peer_name));
126129

127130
Serial.print("[Prph] Connected to ");
128131
Serial.println(peer_name);
@@ -170,8 +173,11 @@ void scan_callback(ble_gap_evt_adv_report_t* report)
170173

171174
void cent_connect_callback(uint16_t conn_handle)
172175
{
176+
// Get the reference to current connection
177+
BLEConnection* connection = Bluefruit.Connection(conn_handle);
178+
173179
char peer_name[32] = { 0 };
174-
Bluefruit.getPeerName(conn_handle, peer_name, sizeof(peer_name));
180+
connection->getPeerName(peer_name, sizeof(peer_name));
175181

176182
Serial.print("[Cent] Connected to ");
177183
Serial.println(peer_name);;

libraries/Bluefruit52Lib/examples/Peripheral/bleuart/bleuart.ino

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,11 @@ void loop()
123123
// callback invoked when central connects
124124
void connect_callback(uint16_t conn_handle)
125125
{
126+
// Get the reference to current connection
127+
BLEConnection* connection = Bluefruit.Connection(conn_handle);
128+
126129
char central_name[32] = { 0 };
127-
Bluefruit.getPeerName(conn_handle, central_name, sizeof(central_name));
130+
connection->getPeerName(central_name, sizeof(central_name));
128131

129132
Serial.print("Connected to ");
130133
Serial.println(central_name);

libraries/Bluefruit52Lib/examples/Peripheral/custom_hrm/custom_hrm.ino

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,11 @@ void setupHRM(void)
161161

162162
void connect_callback(uint16_t conn_handle)
163163
{
164+
// Get the reference to current connection
165+
BLEConnection* connection = Bluefruit.Connection(conn_handle);
166+
164167
char central_name[32] = { 0 };
165-
Bluefruit.getPeerName(conn_handle, central_name, sizeof(central_name));
168+
connection->getPeerName(central_name, sizeof(central_name));
166169

167170
Serial.print("Connected to ");
168171
Serial.println(central_name);

libraries/Bluefruit52Lib/examples/Peripheral/custom_htm/custom_htm.ino

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,11 @@ void setupHTM(void)
151151

152152
void connect_callback(uint16_t conn_handle)
153153
{
154+
// Get the reference to current connection
155+
BLEConnection* connection = Bluefruit.Connection(conn_handle);
156+
154157
char central_name[32] = { 0 };
155-
Bluefruit.getPeerName(conn_handle, central_name, sizeof(central_name));
158+
connection->getPeerName(central_name, sizeof(central_name));
156159

157160
Serial.print("Connected to ");
158161
Serial.println(central_name);

libraries/Bluefruit52Lib/examples/Peripheral/neomatrix/neomatrix.ino

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,11 @@ void startAdv(void)
133133

134134
void connect_callback(uint16_t conn_handle)
135135
{
136+
// Get the reference to current connection
137+
BLEConnection* connection = Bluefruit.Connection(conn_handle);
138+
136139
char central_name[32] = { 0 };
137-
Bluefruit.getPeerName(conn_handle, central_name, sizeof(central_name));
140+
connection->getPeerName(central_name, sizeof(central_name));
138141

139142
Serial.print("Connected to ");
140143
Serial.println(central_name);

libraries/Bluefruit52Lib/examples/Peripheral/neopixel/neopixel.ino

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,11 @@ void startAdv(void)
113113

114114
void connect_callback(uint16_t conn_handle)
115115
{
116+
// Get the reference to current connection
117+
BLEConnection* connection = Bluefruit.Connection(conn_handle);
118+
116119
char central_name[32] = { 0 };
117-
Bluefruit.getPeerName(conn_handle, central_name, sizeof(central_name));
120+
connection->getPeerName(central_name, sizeof(central_name));
118121

119122
Serial.print("Connected to ");
120123
Serial.println(central_name);

libraries/Bluefruit52Lib/examples/Peripheral/rssi_callback/rssi_callback.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ void connect_callback(uint16_t conn_handle)
9090
Serial.println("Connected");
9191

9292
// Get the reference to current connection
93-
BLEConnection* conn = Bluefruit.Connection(conn_handle);
93+
BLEConnection* connection = Bluefruit.Connection(conn_handle);
9494

9595
// Start monitoring rssi of this connection
9696
// This function should be called in connect callback
9797
// Input argument is value difference (to current rssi) that triggers callback
98-
conn->monitorRssi(10);
98+
connection->monitorRssi(10);
9999
}
100100

101101
void rssi_changed_callback(uint16_t conn_hdl, int8_t rssi)

libraries/Bluefruit52Lib/examples/Peripheral/rssi_poll/rssi_poll.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ void loop()
8484
uint16_t conn_hdl = Bluefruit.connHandle();
8585

8686
// Get the reference to current connected connection
87-
BLEConnection* conn = Bluefruit.Connection(conn_hdl);
87+
BLEConnection* connection = Bluefruit.Connection(conn_hdl);
8888

8989
// get the RSSI value of this connection
9090
// monitorRssi() must be called previously (in callback)
91-
int8_t rssi = conn->getRssi();
91+
int8_t rssi = connection->getRssi();
9292

9393
Serial.printf("Rssi = %d", rssi);
9494
Serial.println();

0 commit comments

Comments
 (0)