-
Notifications
You must be signed in to change notification settings - Fork 1
Emulation Mode
Local module program is pretty feature-rich and complex. It would be convenient to be able to develop and debug it without bringing up the actual transmitter all the time. For this reason, local module program includes a simple emulator of received messages. The main logic is in the Receiver.cpp file. The emulator is activated with the help of DS_DEVBOARD
macro in MySystem.h. In emulation mode, button double click will trigger "reception" of a message. Double click is used, because single click is already taken for regular program functions. The emulator is stateful and keeps record of the previous message sent. A new message is formed as follows:
- mailbox ID is set to 1;
- through message number is incremented by one (starting from 1);
- door is flipped every time (starting with opening);
- time is set fixed to 200 ms on odd messages and 5000 ms on even messages (emulating a 5 sec door opening event);
- first two messages are marked as boot messages, similar to what's happening in a real transmitter;
- "online" mode is set according to the real behavior ("on" for odd messages, "off" for even messages).
This is a default sequence suitable for testing much of the higher level logic. One can temporarily tweak the code to test various specific scenarios.
To avoid confusion with a production receiver which might be around at the same time, the emulator adds (DEV)
to its program title on the web site, and its mDNS name changes to mailbox-dev.local
. One needs to be careful with sending commands to Telegram in such scenario, as they will be answered by both modules. To avoid this race, and also testing noise in the Telegram channel, it is recommended to specify a different Telegram channel when in emulator mode. This would be typically a private chat opened by developer to the bot.
Finally, the production receiver hardware is not very convenient for development, as it does not have programming circuits. To facilitate quick testing turnaround, the emulation mode also takes advantage of using a true development board (ESP-12F Witty Cloud in my case) with a high speed upload support (like 460800 bod). A few configuration settings need to be changed in this case; consult Getting Started. If your development board is different, you might need to adapt the code a bit.