Code: Select all
char *pin = "123";//"R069D"; //<- standard pin would be provided by default
SerialBT.begin("abc");//, false);
SerialBT.setPin(pin);
esp_err_t err;
WiFi.mode(WIFI_STA);
err = esp_now_init();
if (err != ESP_OK)
{
Serial.println("Problem during ESP-NOW init");
ESP.restart();
return;
}
else
{
espNowStarted = true;
Serial.println("ESP-NOW init OK");
}
Serial.print("[OLD] ESP32 Board MAC Address: ");
Serial.println(WiFi.macAddress());
esp_now_register_recv_cb(OnDataRecv);
esp_now_register_send_cb(OnDataSent);
// register peer
esp_now_peer_info_t peerInfo;
peerInfo.channel = 0;
peerInfo.encrypt = false;
// register first peer
memcpy(peerInfo.peer_addr, peerAdmin, 6);
if (esp_now_add_peer(&peerInfo) != ESP_OK){
Serial.println("Failed to add peer");
ESP.restart();
return;
}
memcpy(peerInfo.peer_addr, espAll, 6); //can also broadcast with zero (0) which does each individual
if (esp_now_add_peer(&peerInfo) != ESP_OK){ //delivery success always with 0xFF broadcast, so no ack in that mode
Serial.println("Failed to add peer");
ESP.restart();
return;
}