Skip to content

03. Adding Support of multiple Sensors

Matthias Prinke edited this page Jun 20, 2024 · 1 revision

The SW should be able to receive data from multiple sensors, e.g. a Weather Sensor and a Soil Moisture Sensor.

Option for skipping unwanted sensors (e.g. neighbours') - currently messages are received and decoded regardless of type or ID of sensor!

3 Different solutions have been considered:

Solution 1

  • decode radio messages in order as received
  • save decoded data into temporary buffer
  • copy data into final structure

Pros:

  • easy to implement
  • clean code structure

Cons:

  • memory wasted for temporary buffer
  • time for copying data

Solution 2

  • handle radio messages in predefined order
  • save decoded data into final structure

Pros:

  • easy to implement
  • clean code structure
  • efficient memory utilization

Cons:

  • inefficient usage of CPU time waiting for desired message

Solution 3

  • decode radio messages in order as received
  • save decoded data into final buffer in reception order; check for data already received (either complete or incomplete)
  • map data buffer (order of reception) to predefined order or search for desired sensor ID/type for presentation

Pros:

  • efficient memory utilization
  • efficient usage of CPU time

Cons:

  • somewhat difficult to implement
  • potentially fuzzy code structure

Implemented: Solution #3

Solution #3 has been implemented and the code does not look too bad, IMHO!