@@ -29,16 +29,6 @@ NodeManager::NodeManager(uint8_t sensor_count) {
2929 _message = MyMessage ();
3030 // allocate block for all the sensors if sensor_count is provided
3131 if (sensor_count > 0 ) sensors.allocateBlocks (sensor_count);
32- // setup serial port baud rate
33- #ifndef CHIP_NRF5
34- MY_SERIALDEVICE.begin (MY_BAUD_RATE);
35- #endif
36- // print out the version
37- debug (PSTR (LOG_INIT " VER=" VERSION " \n " ));
38- // print out sketch name
39- debug (PSTR (LOG_INIT " INO=" SKETCH_NAME " v" SKETCH_VERSION " \n " ));
40- // print out MySensors' library capabilities
41- debug (PSTR (LOG_INIT " LIB VER=" MYSENSORS_LIBRARY_VERSION " CP=" MY_CAPABILITIES " \n " ));
4232}
4333
4434#if NODEMANAGER_INTERRUPTS == ON
@@ -152,15 +142,21 @@ void NodeManager::registerSensor(Sensor* sensor) {
152142}
153143
154144// register a timer
155- void NodeManager::registerTimer (Timer * timer) {
145+ void NodeManager::registerTimer (InternalTimer * timer) {
156146 _timers.push (timer);
157147}
158148
159149
160150// setup NodeManager
161151void NodeManager::before () {
152+ // print out the version
153+ debug (PSTR (LOG_INIT " VER=" VERSION " \n " ));
154+ // print out sketch name
155+ debug (PSTR (LOG_INIT " INO=" SKETCH_NAME " v" SKETCH_VERSION " \n " ));
156+ // print out MySensors' library capabilities
157+ debug (PSTR (LOG_INIT " LIB VER=" MYSENSORS_LIBRARY_VERSION " CP=" MY_CAPABILITIES " \n " ));
162158 // setup the reboot pin if needed
163- if (_reboot_pin > - 1 ) {
159+ if (_reboot_pin > 0 ) {
164160 debug (PSTR (LOG_INIT " RBT p=%d\n " ),_reboot_pin);
165161 pinMode (_reboot_pin, OUTPUT);
166162 digitalWrite (_reboot_pin, HIGH);
@@ -251,8 +247,8 @@ void NodeManager::loop() {
251247 powerOn ();
252248#endif
253249 // update all the registered timers
254- for (List<Timer *>::iterator itr = _timers.begin (); itr != _timers.end (); ++itr) {
255- Timer * timer = *itr;
250+ for (List<InternalTimer *>::iterator itr = _timers.begin (); itr != _timers.end (); ++itr) {
251+ InternalTimer * timer = *itr;
256252 timer->update ();
257253 }
258254 // run loop for all the registered sensors
@@ -348,7 +344,7 @@ void NodeManager::loop() {
348344 // reboot the board
349345 void NodeManager::reboot () {
350346 debug (PSTR (LOG_POWER " RBT\n " ));
351- if (_reboot_pin > - 1 ) {
347+ if (_reboot_pin > 0 ) {
352348 // reboot the board through the reboot pin which is connected to RST by setting it to low
353349 digitalWrite (_reboot_pin, LOW);
354350 }
@@ -481,7 +477,7 @@ void NodeManager::loop() {
481477 // setup the interrupt pins
482478 void NodeManager::_setupInterrupts () {
483479 // configure wakeup pin if needed
484- if (_sleep_interrupt_pin > - 1 ) {
480+ if (_sleep_interrupt_pin > 0 ) {
485481 // set the interrupt when the pin is connected to ground
486482 setInterrupt (_sleep_interrupt_pin,FALLING,HIGH);
487483 }
@@ -559,10 +555,10 @@ void NodeManager::loop() {
559555 _message.setType (type);
560556 // send the message, multiple times if requested
561557 for (int i = 0 ; i < _retries; i++) {
562- if (mGetPayloadType (_message) == P_INT16) debug_verbose (PSTR (LOG_MSG " SEND(%d) t=%d p=%d\n " ),_message.sensor ,_message.type ,_message.getInt ());
563- if (mGetPayloadType (_message) == P_LONG32) debug_verbose (PSTR (LOG_MSG " SEND(%d) t=%d p=%ld\n " ),_message.sensor ,_message.type ,_message.getLong ());
564- if (mGetPayloadType (_message) == P_FLOAT32) debug_verbose (PSTR (LOG_MSG " SEND(%d) t=%d p=%d.%02d\n " ),_message.sensor ,_message.type ,(unsigned int )_message.getFloat (), (unsigned int )(_message.getFloat ()*100 )%100 );
565- if (mGetPayloadType (_message) == P_STRING) debug_verbose (PSTR (LOG_MSG " SEND(%d) t=%d p=%s\n " ),_message.sensor ,_message.type ,_message.getString ());
558+ if (mGetPayloadType (_message) == P_INT16) { debug_verbose (PSTR (LOG_MSG " SEND(%d) t=%d p=%d\n " ),_message.sensor ,_message.type ,_message.getInt ()); }
559+ if (mGetPayloadType (_message) == P_LONG32) { debug_verbose (PSTR (LOG_MSG " SEND(%d) t=%d p=%ld\n " ),_message.sensor ,_message.type ,_message.getLong ()); }
560+ if (mGetPayloadType (_message) == P_FLOAT32) { debug_verbose (PSTR (LOG_MSG " SEND(%d) t=%d p=%d.%02d\n " ),_message.sensor ,_message.type ,(unsigned int )_message.getFloat (), (unsigned int )(_message.getFloat ()*100 )%100 ); }
561+ if (mGetPayloadType (_message) == P_STRING) { debug_verbose (PSTR (LOG_MSG " SEND(%d) t=%d p=%s\n " ),_message.sensor ,_message.type ,_message.getString ()); }
566562 send (_message, _ack);
567563 // if configured, sleep between each send
568564 sleepBetweenSend ();
@@ -742,7 +738,7 @@ void NodeManager::setAnalogReference(uint8_t value, uint8_t pin) {
742738 // wait a bit
743739 wait (200 );
744740 // perform some reading before actually reading the value
745- if (pin > - 1 ) {
741+ if (pin > 0 ) {
746742 for (int i = 0 ; i < 5 ; i++) {
747743 analogRead (pin);
748744 wait (50 );
0 commit comments