|
4 | 4 |
|
5 | 5 | Created by Henrik Ekblad <[email protected]>
|
6 | 6 | 12/10/14 - Ported to Raspberry Pi by OUJABER Mohamed <[email protected]>
|
7 |
| - |
| 7 | +
|
8 | 8 | This program is free software; you can redistribute it and/or
|
9 | 9 | modify it under the terms of the GNU General Public License
|
10 | 10 | version 2 as published by the Free Software Foundation.
|
@@ -89,7 +89,12 @@ void MyGateway::begin(rf24_pa_dbm_e paLevel, uint8_t channel, rf24_datarate_e da
|
89 | 89 | #endif
|
90 | 90 |
|
91 | 91 | // Start up the radio library
|
92 |
| - setupRadio(paLevel, channel, dataRate); |
| 92 | + try { |
| 93 | + setupRadio(paLevel, channel, dataRate); |
| 94 | + } catch (const char* msg) { |
| 95 | + printf("Unable to start up the radio library. (Error: %s)\n", msg); |
| 96 | + exit(EXIT_FAILURE); |
| 97 | + } |
93 | 98 | RF24::openReadingPipe(WRITE_PIPE, BASE_RADIO_ID);
|
94 | 99 | RF24::openReadingPipe(CURRENT_NODE_PIPE, BASE_RADIO_ID);
|
95 | 100 | RF24::startListening();
|
@@ -237,20 +242,25 @@ void MyGateway::setInclusionMode(boolean newMode) {
|
237 | 242 | }
|
238 | 243 |
|
239 | 244 | void MyGateway::processRadioMessage() {
|
240 |
| - if (process()) { |
241 |
| - // A new message was received from one of the sensors |
242 |
| - MyMessage message = getLastMessage(); |
243 |
| - if (mGetCommand(message) == C_PRESENTATION && inclusionMode) { |
244 |
| - rxBlink(3); |
245 |
| - } else { |
246 |
| - rxBlink(1); |
247 |
| - } |
248 |
| - // Pass along the message from sensors to serial line |
249 |
| - serial(message); |
250 |
| - } |
| 245 | + try { |
| 246 | + if (process()) { |
| 247 | + // A new message was received from one of the sensors |
| 248 | + MyMessage message = getLastMessage(); |
| 249 | + if (mGetCommand(message) == C_PRESENTATION && inclusionMode) { |
| 250 | + rxBlink(3); |
| 251 | + } else { |
| 252 | + rxBlink(1); |
| 253 | + } |
| 254 | + // Pass along the message from sensors to serial line |
| 255 | + serial(message); |
| 256 | + } |
| 257 | + } catch (const char* msg) { |
| 258 | + printf("Unable to process radio messages. (Error: %s)\n", msg); |
| 259 | + exit(EXIT_FAILURE); |
| 260 | + } |
251 | 261 |
|
252 |
| - checkButtonTriggeredInclusion(); |
253 |
| - checkInclusionFinished(); |
| 262 | + checkButtonTriggeredInclusion(); |
| 263 | + checkInclusionFinished(); |
254 | 264 | }
|
255 | 265 |
|
256 | 266 | void MyGateway::serial(const char *fmt, ... ) {
|
@@ -319,4 +329,3 @@ void MyGateway::errBlink(uint8_t cnt) {
|
319 | 329 | if(countErr == 255) { countErr = cnt; }
|
320 | 330 | #endif
|
321 | 331 | }
|
322 |
| - |
|
0 commit comments