@@ -59,23 +59,24 @@ void isrRxDataAvailable(void)
59
59
// enter deep sleep until packet is received (for low power digirepeating)
60
60
void enterDeepSleep ()
61
61
{
62
- LOG_INFO (F (" Enter sleep " ));
62
+ LOG_INFO (F (" Sleep " ));
63
63
sleep_enable ();
64
64
set_sleep_mode (SLEEP_MODE_PWR_DOWN);
65
65
digitalWrite (LED_BUILTIN, LOW);
66
66
delay (1000 );
67
67
sleep_cpu ();
68
68
digitalWrite (LED_BUILTIN, HIGH);
69
- LOG_INFO (F (" Exit sleep " ));
69
+ LOG_INFO (F (" Unsleep " ));
70
70
}
71
71
72
72
// configura radio with given parameters
73
+ #if CFG_MOD == CFG_MOD_LORA
73
74
void setupRadio (long loraFreq, long bw, int sf, int cr, int pwr, int sync, int crcBytes, bool isExplicit)
74
75
{
75
76
// setup lora
76
77
int state = radio_.begin ((float )loraFreq / 1e6 , (float )bw / 1e3 , sf, cr, sync , pwr);
77
78
if (state != RADIOLIB_ERR_NONE) {
78
- LOG_ERROR (F (" Radio start failure " ), state);
79
+ LOG_ERROR (F (" Radio failed " ), state);
79
80
while (true );
80
81
}
81
82
if (isExplicit && sf > 6 )
@@ -85,33 +86,23 @@ void setupRadio(long loraFreq, long bw, int sf, int cr, int pwr, int sync, int c
85
86
radio_.setCRC (crcBytes);
86
87
radio_.setPreambleLength (CFG_LORA_PREAMBLE);
87
88
radio_.setDio0Action (isrRxDataAvailable);
88
-
89
- // start lora receive
90
- state = radio_.startReceive ();
91
- if (state != RADIOLIB_ERR_NONE) {
92
- LOG_ERROR (F (" Receive start error:" ), state);
93
- while (true );
94
- }
89
+ radio_.startReceive ();
95
90
}
91
+ #endif
96
92
97
93
// configura radio with given parameters
94
+ #if CFG_MOD == CFG_MOD_FSK
98
95
void setupRadioFsk (long loraFreq, float bitRate, float freqDev, float rxBw, int pwr)
99
96
{
100
97
// setup lora
101
98
int state = radio_.beginFSK ((float )loraFreq / 1e6 , bitRate, freqDev, rxBw, pwr);
102
99
if (state != RADIOLIB_ERR_NONE) {
103
- LOG_ERROR (F (" Radio start failure" ), state);
104
- while (true );
100
+ return ;
105
101
}
106
102
radio_.setDio0Action (isrRxDataAvailable);
107
-
108
- // start lora receive
109
- state = radio_.startReceive ();
110
- if (state != RADIOLIB_ERR_NONE) {
111
- LOG_ERROR (F (" Receive start error:" ), state);
112
- while (true );
113
- }
103
+ radio_.startReceive ();
114
104
}
105
+ #endif
115
106
116
107
// arduino default setup
117
108
void setup ()
@@ -162,25 +153,19 @@ size_t receiveLoraPacket()
162
153
return 0 ;
163
154
}
164
155
if (packetLength > CFG_MAX_PACKET_SIZE) {
165
- LOG_ERROR (F (" Packet size is too large:" ), packetLength);
156
+ // LOG_ERROR(F("Packet size is too large:"), packetLength);
166
157
packetLength = 0 ;
167
158
} else {
168
159
// read packet
169
160
int state = radio_.readData (pktBufRx_, packetLength);
170
161
if (state != RADIOLIB_ERR_NONE) {
171
- LOG_ERROR (F (" Read pkt error:" ), state);
162
+ // LOG_ERROR(F("Read pkt error:"), state);
172
163
packetLength = 0 ;
173
164
}
174
165
}
175
166
176
167
isLoraRxDataAvailable_ = false ;
177
-
178
- // start lora receive
179
- int state = radio_.startReceive ();
180
- if (state != RADIOLIB_ERR_NONE) {
181
- LOG_ERROR (F (" Receive start error:" ), state);
182
- }
183
-
168
+ radio_.startReceive ();
184
169
return packetLength;
185
170
}
186
171
@@ -192,17 +177,12 @@ void sendLoraPacket(size_t packetLength)
192
177
// send out
193
178
int state = radio_.transmit (pktBufTx_, packetLength);
194
179
if (state != RADIOLIB_ERR_NONE) {
195
- LOG_ERROR (F (" Failed to transmit" ), state);
180
+ // LOG_ERROR(F("Failed to transmit"), state);
196
181
}
197
182
radio_.finishTransmit ();
198
183
199
184
isRxIsrEnabled_ = true ;
200
-
201
- // start lora receive
202
- state = radio_.startReceive ();
203
- if (state != RADIOLIB_ERR_NONE) {
204
- LOG_ERROR (F (" Receive start error:" ), state);
205
- }
185
+ radio_.startReceive ();
206
186
}
207
187
208
188
// read lora packet and transfer to modem
@@ -396,21 +376,21 @@ void processLoraPacketAsRpt()
396
376
// parse packet
397
377
AX25::Payload payload (pktBufRx_, packetLength);
398
378
if (!payload.IsValid ()) {
399
- LOG_WARN (F (" Failed to parse rx packet, not ax25" ));
379
+ LOG_WARN (F (" Not ax25" ));
400
380
return ;
401
381
}
402
382
payload.Dump ();
403
383
404
384
// digireat
405
385
if (!payload.Digirepeat (myCallsign_)) {
406
- LOG_INFO (F (" Digirepeating skipped " ));
386
+ LOG_INFO (F (" RPT skip " ));
407
387
return ;
408
388
}
409
389
410
390
// serialize to ax25 packet
411
391
int txPacketLength = payload.ToBinary (pktBufRx_, CFG_MAX_PACKET_SIZE);
412
392
if (txPacketLength <= 0 ) {
413
- LOG_WARN (F (" Failed to convert to AX25 to binary " ));
393
+ LOG_WARN (F (" AX25 to bin fail " ));
414
394
return ;
415
395
}
416
396
0 commit comments