|
|
@ -16,12 +16,11 @@ void ESPNow2::begin(void) { |
|
|
|
2. Once peering mode done and it will receive the first message from the master node and save the configuration (Mac Address) |
|
|
|
3. Use the MAC address to keep broadcasting to the master node. |
|
|
|
**/ |
|
|
|
WiFi.mode(WIFI_STA); |
|
|
|
EEPROM.begin(EEPROM_SIZE); |
|
|
|
WiFi.mode(WIFI_STA); |
|
|
|
|
|
|
|
uint8_t default_server_address[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; |
|
|
|
uint8_t temp_addr[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; |
|
|
|
uint8_t fpvbridge_addr[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; |
|
|
|
// uint8_t temp_addr[] = { 0x08, 0xB6, 0x1F, 0x34, 0x89, 0x98 };
|
|
|
|
|
|
|
|
fpvbridge_addr[0] = EEPROM.read(0); |
|
|
|
fpvbridge_addr[1] = EEPROM.read(1); |
|
|
@ -40,7 +39,9 @@ void ESPNow2::begin(void) { |
|
|
|
Serial.print("On Channel: "); |
|
|
|
Serial.println(espnow_channel); |
|
|
|
|
|
|
|
memcpy(destination_server_address, default_server_address, sizeof(uint8_t[6])); |
|
|
|
|
|
|
|
// uint8_t temp_addr[] = { 0x08, 0xB6, 0x1F, 0x34, 0x89, 0x98 };
|
|
|
|
memcpy(default_server_address, temp_addr, sizeof(uint8_t[6])); |
|
|
|
pairing_status = PAIR_REQUEST; |
|
|
|
} |
|
|
|
|
|
|
@ -87,10 +88,10 @@ PairingStatus ESPNow2::auto_pairing(void) { |
|
|
|
// addPeer(default_server_address, espnow_channel);
|
|
|
|
// Serial.println("After addPeer...");
|
|
|
|
|
|
|
|
esp_now_send(destination_server_address, (uint8_t *) &pairing_data, sizeof(pairing_data)); |
|
|
|
esp_now_send(default_server_address, (uint8_t *) &pairing_data, sizeof(pairing_data)); |
|
|
|
Serial.print("Sending to: "); |
|
|
|
char m[18]; |
|
|
|
sprintf(m, "%02X:%02X:%02X:%02X:%02X:%02X", destination_server_address[0], destination_server_address[1], destination_server_address[2], destination_server_address[3], destination_server_address[4], destination_server_address[5]); |
|
|
|
sprintf(m, "%02X:%02X:%02X:%02X:%02X:%02X", default_server_address[0], default_server_address[1], default_server_address[2], default_server_address[3], default_server_address[4], default_server_address[5]); |
|
|
|
Serial.println(m); |
|
|
|
|
|
|
|
millis_previous = millis(); |
|
|
@ -161,8 +162,6 @@ void on_data_recv(const uint8_t * mac_addr, const uint8_t *incoming_data, int le |
|
|
|
EEPROM.write(6, espnow2.pairing_data.channel); |
|
|
|
|
|
|
|
EEPROM.commit(); |
|
|
|
|
|
|
|
Serial.println("Saved into EEPROM"); |
|
|
|
espnow2.pairing_status = PAIR_PAIRED; // set the pairing status
|
|
|
|
break; |
|
|
|
} |
|
|
|