Project of the Internet of Things course at Politecnico di Milano.
Description of the project available here.
The application logic is implemented in the SmartBraceletC module. The FakeSensorP module is used to emulate position and kinematic sensors for the child bracelet.
For simulation purposes, nodes with an odd address are set to be parent bracelets, nodes with an even address are set to be child bracelets. This is easily done by reading the TOS_NODE_ID variable, that is assigned during the simulation.
Parent and child bracelets are coupled if they have consecutive addresses (1-2, 3-4, ...): 20 randoms keys are preloaded in the header file, then each node assigns itself a key depending on its address (nodes 1 and 2 shares the first key, nodes 3 and 4 the second and so on). This allows to run a simulation with up to 20 couples of bracelets.
As defined in the SmartBracelet.h header, each message contains:
- message type (pairing for pairing request, paired for pairing completion, info for standard communication from child to parent),
- sender unique key and node address (a received message is accepted only if sender and receiver keys are the same and if the sender address is the same to the paired one)
- status and position (meaningful only if the sender is a child bracelet)
Each node runs a timer whose period set accordingly to the bracelet current state:
- after the boot: the timer is used to periodically send pairing messages
- when the two bracelets are paired: the timer is used to periodically send the state to the parent or show the alarm if no message is received by the parent within one minute.
For simulation purposes, the position (X and Y coordinates) and kinematic status sensor are emulated using the FakeSensor module. The position value is a couple of random integers. The kinematic status is drawn accordingly to the given probability distribution, starting from the random value generated by the fake sensor.
The behavoir of the application has been simulated using the TOSSIM library in three different scenarios. In order to run the simulation, the source code must be compiled using make micaz sim
.
Simulation script: SimulationDebug.py
Simulation log: simulation_log_debug.txt
Carried out using 2 couples of motes, displaying all the debug messages (all the debug channels are enabled in TOSSIM). The entire pairing process can be seen from the log file, showing all the received messages. Then, in the operating phase all the debug messages of the radio module are shown.
Simulation script: SimulationRelease.py
Simulation log: simulation_log_release.txt
Carried out using 2 couples of motes, displaying only the messages and alarms that would be actually displayed in the screens of the final verion of the bracelets.
Simulation script: SimulationOutOfRange.py
Simulation log: simulation_log_out_of_range.txt
Carried out using 1 couple of motes, displaying all the debug messages, turing off one mote at a certain time to emulate a node going out of range. From that moment, the missing alarm is shown on the parent's bracelet.