@@ -88,7 +88,7 @@ void ScanForSlave() {
88
88
Serial.print (i + 1 ); Serial.print (" : " ); Serial.print (SSID); Serial.print (" [" ); Serial.print (BSSIDstr); Serial.print (" ]" ); Serial.print (" (" ); Serial.print (RSSI); Serial.print (" )" ); Serial.println (" " );
89
89
// Get BSSID => Mac Address of the Slave
90
90
int mac[6 ];
91
- if ( 6 == sscanf (BSSIDstr.c_str (), " %x:%x:%x:%x:%x:%x%c " , &mac[0 ], &mac[1 ], &mac[2 ], &mac[3 ], &mac[4 ], &mac[5 ] ) ) {
91
+ if ( 6 == sscanf (BSSIDstr.c_str (), " %x:%x:%x:%x:%x:%x" , &mac[0 ], &mac[1 ], &mac[2 ], &mac[3 ], &mac[4 ], &mac[5 ] ) ) {
92
92
for (int ii = 0 ; ii < 6 ; ++ii ) {
93
93
slave.peer_addr [ii] = (uint8_t ) mac[ii];
94
94
}
@@ -124,17 +124,15 @@ bool manageSlave() {
124
124
}
125
125
126
126
Serial.print (" Slave Status: " );
127
- const esp_now_peer_info_t *peer = &slave;
128
- const uint8_t *peer_addr = slave.peer_addr ;
129
127
// check if the peer exists
130
- bool exists = esp_now_is_peer_exist (peer_addr);
128
+ bool exists = esp_now_is_peer_exist (slave. peer_addr );
131
129
if ( exists) {
132
130
// Slave already paired.
133
131
Serial.println (" Already Paired" );
134
132
return true ;
135
133
} else {
136
134
// Slave not paired, attempt pair
137
- esp_err_t addStatus = esp_now_add_peer (peer );
135
+ esp_err_t addStatus = esp_now_add_peer (&slave );
138
136
if (addStatus == ESP_OK) {
139
137
// Pair success
140
138
Serial.println (" Pair success" );
@@ -168,9 +166,7 @@ bool manageSlave() {
168
166
}
169
167
170
168
void deletePeer () {
171
- const esp_now_peer_info_t *peer = &slave;
172
- const uint8_t *peer_addr = slave.peer_addr ;
173
- esp_err_t delStatus = esp_now_del_peer (peer_addr);
169
+ esp_err_t delStatus = esp_now_del_peer (slave.peer_addr );
174
170
Serial.print (" Slave Delete Status: " );
175
171
if (delStatus == ESP_OK) {
176
172
// Delete success
0 commit comments