Beacon Code:
void beaconLoop() {
DEBUG_SERIAL {
Serial.print(F("[beaconLoop] Sending beacon on channel "));
Serial.print(wifi_get_channel());
Serial.print(" ...\n");
}
DEBUG_LED blink(1, 50);
hdrEspLocRequest_t hdrEspLoc;
hdrEspLoc.type = PKT_TYPE_REQUEST;
hdrEspLoc.nodeId = config.nodeId;
hdrEspLoc.packetId = ++config.lastPacketId;
packet[PKT_LEN-1] = sizeof(hdrEspLoc);
memcpy(packet+PKT_LEN, &hdrEspLoc, sizeof(hdrEspLoc));
wifi_send_pkt_freedom(packet, PKT_LEN+sizeof(hdrEspLoc), 0);
delay(450);
}
void beaconRecv(uint8_t *buf) {
hdrPacketReply_t *packet = (hdrPacketReply_t *) buf;
if (packet->hdrEspLoc.type == PKT_TYPE_REPLY) {
DEBUG_SERIAL Serial.printf("- Recebido pacote de Reply [nodeId: %d, packetId: %d, RSSISend: %d, RSSIRecv: %d]\n", packet->hdrEspLoc.nodeId, packet->hdrEspLoc.packetId, packet->hdrEspLoc.senderRssi, packet->hdrControl.rssi);
delay(50);
}
}
Node code:
void nodeLoop() {
DEBUG_SERIAL Serial.printf("- Loop ...\n");
delay(500);
}
void nodeRecv(uint8_t *buf) {
hdrPacketRequest_t *packet = (hdrPacketRequest_t *) buf;
if (packet->hdrEspLoc.type == PKT_TYPE_REQUEST) {
DEBUG_SERIAL Serial.printf("- Recebido pacote de Request [nodeId: %d, packetId: %d, RSSI: %d]\n", packet->hdrEspLoc.nodeId, packet->hdrEspLoc.packetId, packet->hdrControl.rssi);
nodeSendReply(packet);
delay(50);
}
}
void nodeSendReply(hdrPacketRequest_t *packetRequest) {
DEBUG_SERIAL Serial.print(F("[nodeSendReply] Enviando pacote de Reply ...\n"));
hdrEspLocReply_t hdrEspLoc;
hdrEspLoc.type = PKT_TYPE_REPLY;
hdrEspLoc.nodeId = config.nodeId;
hdrEspLoc.packetId = packetRequest->hdrEspLoc.packetId;
hdrEspLoc.senderId = packetRequest->hdrEspLoc.nodeId;
hdrEspLoc.senderRssi = packetRequest->hdrControl.rssi;
packet[PKT_LEN-1] = sizeof(hdrEspLoc);
memcpy(packet+PKT_LEN, &hdrEspLoc, sizeof(hdrEspLoc));
wifi_send_pkt_freedom(packet, PKT_LEN+sizeof(hdrEspLoc), 0);
}
Error: