reduce flash usage by 16 bytes
This commit is contained in:
parent
720e0edf8e
commit
84c10253e6
|
@ -0,0 +1,5 @@
|
||||||
|
.pio
|
||||||
|
.vscode/.browse.c_cpp.db*
|
||||||
|
.vscode/c_cpp_properties.json
|
||||||
|
.vscode/launch.json
|
||||||
|
.vscode/ipch
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||||
|
// for the documentation about the extensions.json format
|
||||||
|
"recommendations": [
|
||||||
|
"platformio.platformio-ide"
|
||||||
|
],
|
||||||
|
"unwantedRecommendations": [ ]
|
||||||
|
}
|
33
src/main.cpp
33
src/main.cpp
|
@ -13,22 +13,14 @@ void setup() {
|
||||||
#endif
|
#endif
|
||||||
initRegion(); // create regions[] and load myRegion
|
initRegion(); // create regions[] and load myRegion
|
||||||
applyModemConfig(); // apply lora settings
|
applyModemConfig(); // apply lora settings
|
||||||
radio.standby();
|
|
||||||
radio.setPacketReceivedAction(ISR_setReceived); // Interrupt Handler -> set "PacketReceived" flag at RX
|
|
||||||
MSG("[INFO][SX1262] Starting to listen ... ");
|
MSG("[INFO][SX1262] Starting to listen ... ");
|
||||||
state = radio.startReceive();
|
startReceive();
|
||||||
if (state == RADIOLIB_ERR_NONE) {
|
if (state == RADIOLIB_ERR_NONE) {
|
||||||
MSG("success!\n\n");
|
MSG("success!\n\n");
|
||||||
} else {
|
} else {
|
||||||
MSG("\n[ERROR][SX1262] startReceive() failed, code: %i\n\n ** Full Stop **", state);
|
MSG("\n[ERROR][SX1262] startReceive() failed, code: %i\n\n ** Full Stop **", state);
|
||||||
while (true);
|
while (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void clearInterrupts(void) {
|
|
||||||
radio.clearDio1Action();
|
|
||||||
radio.finishTransmit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
@ -43,7 +35,7 @@ void loop() {
|
||||||
MSG("\n[WARN]Not a Meshtastic packet, too short!\n");
|
MSG("\n[WARN]Not a Meshtastic packet, too short!\n");
|
||||||
return; // will not repeat
|
return; // will not repeat
|
||||||
}
|
}
|
||||||
//const uint8_t *payload = radiobuf + sizeof(PacketHeader);
|
|
||||||
PacketHeader *h = (PacketHeader *)radiobuf;
|
PacketHeader *h = (PacketHeader *)radiobuf;
|
||||||
|
|
||||||
const uint8_t hop_limit = h->flags & PACKET_FLAGS_HOP_MASK;
|
const uint8_t hop_limit = h->flags & PACKET_FLAGS_HOP_MASK;
|
||||||
|
@ -69,9 +61,7 @@ void loop() {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
MSG("failed, ERR = %i - resume RX", state);
|
MSG("failed, ERR = %i - resume RX", state);
|
||||||
clearInterrupts();
|
PacketSent=true;
|
||||||
radio.setPacketReceivedAction(ISR_setReceived);
|
|
||||||
radio.startReceive();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,14 +74,11 @@ void loop() {
|
||||||
|
|
||||||
if (PacketSent) {
|
if (PacketSent) {
|
||||||
PacketSent = false;
|
PacketSent = false;
|
||||||
clearInterrupts();
|
startReceive();
|
||||||
radio.setPacketReceivedAction(ISR_setReceived);
|
|
||||||
radio.startReceive();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delay(100); // wait for Serial
|
delay(100); // wait for Serial
|
||||||
MCU_deepsleep();
|
MCU_deepsleep();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCU_deepsleep(void) {
|
void MCU_deepsleep(void) {
|
||||||
|
@ -108,5 +95,15 @@ void MCU_deepsleep(void) {
|
||||||
UART_1_Wakeup;
|
UART_1_Wakeup;
|
||||||
#endif
|
#endif
|
||||||
#endif //CUBECELL
|
#endif //CUBECELL
|
||||||
|
}
|
||||||
|
|
||||||
|
void clearInterrupts(void) {
|
||||||
|
radio.clearDio1Action();
|
||||||
|
radio.finishTransmit();
|
||||||
|
}
|
||||||
|
|
||||||
|
void startReceive(){
|
||||||
|
clearInterrupts();
|
||||||
|
radio.setPacketReceivedAction(ISR_setReceived);
|
||||||
|
state=radio.startReceive();
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,11 @@
|
||||||
|
|
||||||
uint8_t radiobuf[256];
|
uint8_t radiobuf[256];
|
||||||
uint32_t lastPacketID = 0;
|
uint32_t lastPacketID = 0;
|
||||||
|
int state = RADIOLIB_ERR_NONE;
|
||||||
|
|
||||||
void MCU_deepsleep(void);
|
void MCU_deepsleep(void);
|
||||||
|
void clearInterrupts(void);
|
||||||
|
void startReceive(void);
|
||||||
|
|
||||||
// Flag and ISR for "Received packet" - events
|
// Flag and ISR for "Received packet" - events
|
||||||
volatile bool PacketReceived = false;
|
volatile bool PacketReceived = false;
|
||||||
|
@ -41,8 +44,6 @@ void ISR_setPacketSent(void) {
|
||||||
PacketSent = true;
|
PacketSent = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int state = RADIOLIB_ERR_NONE;
|
|
||||||
|
|
||||||
#ifndef SILENT
|
#ifndef SILENT
|
||||||
#define MSG(...) Serial.printf(__VA_ARGS__)
|
#define MSG(...) Serial.printf(__VA_ARGS__)
|
||||||
#define MSGFLOAT(a,b) Serial.print(a); Serial.print(b)
|
#define MSGFLOAT(a,b) Serial.print(a); Serial.print(b)
|
||||||
|
|
Loading…
Reference in New Issue