bristlemouth / bm_protocol

Primary Bristlemouth firmware repository
https://www.bristlemouth.org/
Apache License 2.0
10 stars 7 forks source link

get sys info crc from nodes #19

Closed russelldeguzman closed 10 months ago

russelldeguzman commented 10 months ago

This PR aggregates all nodes sys-info crc's into the network's crc.

  1. Topology sampler samples the nodes.
  2. Open a top level cbor array
  3. For each node discovered, request the sys info and add it to subarray
  4. As you process each sys info, then send a request for the cbor map configuration
  5. On receipt of the cbor map configuration, add it to the subarray and then close
  6. When all nodes have been added, close the top level cbor array
  7. Now compute the CRC32 over the entire encoded 2D cbor network configuration

TODO - we print the cbor array now for debug, but in another PR, send all this to Spotter.

Also clang-format

Testing:

A bridge, and two motes network config

83                                      # array(3)
   85                                   # array(5)
      1B C00F1C4D07116874               # unsigned(13839311297089464436)
      6A                                # text(10)
         6272696467652D646267           # "bridge-dbg"
      1A A64F9410                       # unsigned(2790233104)
      1A A89496A1                       # unsigned(2828310177)
      A1                                # map(1)
         78 1C                          # text(28)
            627269646765506F776572436F6E74726F6C6C6572456E61626C6564 # "bridgePowerControllerEnabled"
         00                             # unsigned(0)
   85                                   # array(5)
      1B D158D85954E1F6AD               # unsigned(15085044830065260205)
      6F                                # text(15)
         68656C6C6F5F776F726C642D646267 # "hello_world-dbg"
      1A 1C4B8AEA                       # unsigned(474712810)
      1A 04D44C65                       # unsigned(81022053)
      A0                                # map(0)
   85                                   # array(5)
      1B 2F58E75E9F6554B5               # unsigned(3411731111320310965)
      6F                                # text(15)
         68656C6C6F5F776F726C642D646267 # "hello_world-dbg"
      1A 1C4B8AEA                       # unsigned(474712810)
      1A 04D44C65                       # unsigned(81022053)
      A0                                # map(0)

Turns into:

[[13839311297089464436, "bridge-dbg", 2790233104, 2828310177, {"bridgePowerControllerEnabled": 0}], [15085044830065260205, "hello_world-dbg", 474712810, 81022053, {}], [3411731111320310965, "hello_world-dbg", 474712810, 81022053, {}]]