// Initialize library and handle sketch functions like we want to #include #include #include #include "MySensorsCore.h" /* * handler for SIGINT signal */ void handle_sigint(int sig) { if (sig == SIGINT) { std::cout << "Received SIGINT\n" << std::endl; } else if (sig == SIGTERM) { std::cout << "Received SIGTERM\n" << std::endl; } #ifdef MY_RF24_IRQ_PIN detachInterrupt(MY_RF24_IRQ_PIN); #endif #if defined(MY_GATEWAY_SERIAL) MY_SERIALDEVICE.end(); #endif exit(0); } int main(void) { /* register the signal handler */ signal(SIGINT, handle_sigint); signal(SIGTERM, handle_sigint); _begin(); // Startup MySensors library for (;;) { _process(); // Process incoming data if (loop) loop(); // Call sketch loop } return 0; }