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
|
||||
initRegion(); // create regions[] and load myRegion
|
||||
applyModemConfig(); // apply lora settings
|
||||
radio.standby();
|
||||
radio.setPacketReceivedAction(ISR_setReceived); // Interrupt Handler -> set "PacketReceived" flag at RX
|
||||
MSG("[INFO][SX1262] Starting to listen ... ");
|
||||
state = radio.startReceive();
|
||||
startReceive();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
MSG("success!\n\n");
|
||||
} else {
|
||||
MSG("\n[ERROR][SX1262] startReceive() failed, code: %i\n\n ** Full Stop **", state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void clearInterrupts(void) {
|
||||
radio.clearDio1Action();
|
||||
radio.finishTransmit();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
@ -43,7 +35,7 @@ void loop() {
|
|||
MSG("\n[WARN]Not a Meshtastic packet, too short!\n");
|
||||
return; // will not repeat
|
||||
}
|
||||
//const uint8_t *payload = radiobuf + sizeof(PacketHeader);
|
||||
|
||||
PacketHeader *h = (PacketHeader *)radiobuf;
|
||||
|
||||
const uint8_t hop_limit = h->flags & PACKET_FLAGS_HOP_MASK;
|
||||
|
@ -69,9 +61,7 @@ void loop() {
|
|||
}
|
||||
else {
|
||||
MSG("failed, ERR = %i - resume RX", state);
|
||||
clearInterrupts();
|
||||
radio.setPacketReceivedAction(ISR_setReceived);
|
||||
radio.startReceive();
|
||||
PacketSent=true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,14 +74,11 @@ void loop() {
|
|||
|
||||
if (PacketSent) {
|
||||
PacketSent = false;
|
||||
clearInterrupts();
|
||||
radio.setPacketReceivedAction(ISR_setReceived);
|
||||
radio.startReceive();
|
||||
startReceive();
|
||||
}
|
||||
|
||||
delay(100); // wait for Serial
|
||||
MCU_deepsleep();
|
||||
|
||||
}
|
||||
|
||||
void MCU_deepsleep(void) {
|
||||
|
@ -108,5 +95,15 @@ void MCU_deepsleep(void) {
|
|||
UART_1_Wakeup;
|
||||
#endif
|
||||
#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];
|
||||
uint32_t lastPacketID = 0;
|
||||
int state = RADIOLIB_ERR_NONE;
|
||||
|
||||
void MCU_deepsleep(void);
|
||||
void clearInterrupts(void);
|
||||
void startReceive(void);
|
||||
|
||||
// Flag and ISR for "Received packet" - events
|
||||
volatile bool PacketReceived = false;
|
||||
|
@ -41,8 +44,6 @@ void ISR_setPacketSent(void) {
|
|||
PacketSent = true;
|
||||
}
|
||||
|
||||
int state = RADIOLIB_ERR_NONE;
|
||||
|
||||
#ifndef SILENT
|
||||
#define MSG(...) Serial.printf(__VA_ARGS__)
|
||||
#define MSGFLOAT(a,b) Serial.print(a); Serial.print(b)
|
||||
|
|
Loading…
Reference in New Issue