The Intrusion Avoidance Algorithm - a deleted feature of my published Voice Controlled Arduino Home Automation project, but this showcase publication presents how it works.
The hardware I built was ready and I came up with this idea, so I started a useful and interesting experiment...
The protagonist is the Central Unit now.The published version
The conception: if a new Android user connects the system, the first message has to be 'hi' - as the second line of defense after the Bluetooth PIN code. Otherwise the user will not receive any information and unable to send commands.If the user sends anything else instead of 'hi', will be disconnected immediately by the system.The unpublished version
It was a funny adventure to create a function, which brings some warmth to the automated home.
So I created LoA (Level of Aggression), an attribution of the system, which is 0 at peaceful times. But if the user's first message is not 'hi', the "user" is "intruder" hereinafter.
LoA becomes 1, will grow forcefully by self-generating. First of all, the system writes the fact of 'self defense is in progress' to the proper address of EEPROM memory.
Since LoA is not 0 anymore, at the next loop-cycle the Intrusion Avoidance Algorithm receives the control and attacks the connected Bluetooth device.During the first phase of attack the system sends different AT and numeric commands in order to cause malfunctions by manipulating system configuration - because the intruder device is unknown.
If LoA reaches 64, the second phase follows. The system generates and sends different kinds of data sequences. Now LoA works as an exponent, determines the increasing power of strikes. The second phase causes system overload and buffer overflow to the intruder... and to the system too! It was hard to find balance between efficiency and stability.
My test subject device (Motorola E4) used to fall over around LoA=90.
When LoA reaches 128, the Intrusion Avoidance Algorithm calls the reboot routine (reset by Watchdog timer, prescaller WDTO_60MS) to free up low resources - this point stops the unleashed escalation of LoA.
During the reboot procedure the system finds the 'self defense is in progress' flag in the EEPROM, and now the BT handler will be called I coded, it disconnects the intruder, since it would be unable to do it.
The blue LED lights up, indicates that the HC-05 ENABLE pin is HIGH, and receives AT+DISC and AT+RESET commands from the Mega 2560 board.
The whole procedure is very elegant, fully automated, it does not require any human decision or intervention.Video
Now let the fun begin!