{"id":216,"date":"2021-09-25T19:16:46","date_gmt":"2021-09-25T19:16:46","guid":{"rendered":"https:\/\/www.jeskevic.info\/?p=216"},"modified":"2021-09-25T19:16:46","modified_gmt":"2021-09-25T19:16:46","slug":"too-much-thinking-too-little-doing","status":"publish","type":"post","link":"https:\/\/www.jeskevic.info\/?p=216","title":{"rendered":"Too much thinking, too little doing"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Like, how will the project look like? Which features will be implemented?  How should the packet look like?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A lot of packet processing is done by nRF24L01+ (like address processing, CRC, ACK&#8230;.) But some things still should be done. So:<\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\">nRFF project<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The idea of this project is to combine some ideas and create a lightweight secure mesh (or, dynamic-tree) network, with an MQTT-like interface.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Targets:<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>Security (with modern SDR, packets without any protection can be easily decoded)<ul><li><em>nonce<\/em> to prevent replay attack<\/li><li><em>XXTEA<\/em> block coding &#8211; lightweight and secure for short packets<\/li><\/ul><\/li><li>Message-based (like MQTT)<ul><li>eliminated the need of knowing the exact module address &amp; co<\/li><li>network can be easily extended with new modules<\/li><li>12 bit message id (+4 bit for message counter)<\/li><\/ul><\/li><li>Mesh network (more preicesily: dynamic-tree)<ul><li>dynamically configurable network<ul><li>one server, for managing network and message distributions<\/li><li>static addresses for fixed devices for manual network configuration<\/li><li>dynamic addresses for flexible network configurations, which can be stored for faster connection<\/li><li>dynamic addresses for moving devices, which are never stored<\/li><\/ul><\/li><\/ul><\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Limitations<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>24 bytes pro message. Can be solved by multi-packet transmision<\/li><li>12 bit message ID<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Packet structure<\/h3>\n\n\n\n<pre class=\"wp-block-code\" style=\"font-size:12px\"><code>typedef struct  {\r\n    uint8_t  version;    \/\/ protocol version\r\n    uint8_t  dir_size;   \/\/ DONW | SERVICE | MULTIPACKET | DATA_SIZE&#91;5]\r\n    uint16_t msg_cnt_id; \/\/ COUNTER&#91;4] | MESSAGE_ID&#91;12]\r\n    uint32_t nonce;      \/\/ 32 bits\r\n    uint8_t  data&#91;24];   \/\/ 24 bytes max in one packet (total packet size 32 bytes)\r\n} NRFF_PACKET;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">And this packet will be coded with XXTEA algorithm. Don&#8217;t know what to do with the length, but I want to use the dynamic length feature. (just to save some radio-on time, and instead of 8 words send only 3, if needed).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"line-height:1\">So, my plan is to test and try:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>dynamic payload feature<\/li><li>XXTEA coding<\/li><li>Message-based packets<\/li><li>Automatic mesh network configuration<\/li><\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Network config<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Each device should have its own ID (=MAC), 1 byte should be enough. (e.g. 1-255). If it has no static address, it searches next available host. After this, it receives an address. <\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Addressing<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\">The root device address is <strong>0<\/strong>. Devices connected to root become addresses <strong>1~6<\/strong>. Next in the chain, e.g. connected to <strong>1<\/strong> will become 0o<strong>11<\/strong>,  0o<strong>21<\/strong>&#8230; and so on. Because of max. device count for one module is 5 (one connection goes to the host), it is practical to use the octal system.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let see one example:<\/p>\n\n\n\n<pre class=\"wp-block-code\" style=\"font-size:14px\"><code>0: (0)\r\n\u251c\u2500\u2500 1: 1\r\n\u2502   \u251c\u2500\u2500 11: 4\r\n\u2502   \u2502   \u251c\u2500\u2500 111: 8\r\n\u2502   \u2502   \u2514\u2500\u2500 211: 9\r\n\u2502   \u2502       \u2514\u2500\u2500 1211: 10\r\n\u2502   \u2502           \u2514\u2500\u2500 11211: 11 # here is 11211 is address, 11 is ID\r\n\u2502   \u251c\u2500\u2500 21: 5\r\n\u2502   \u251c\u2500\u2500 31: 6\r\n\u2502   \u2514\u2500\u2500 41: 7\r\n\u251c\u2500\u2500 2: 2\r\n\u251c\u2500\u2500 3: 3\r\n\u2514\u2500\u2500 5: 33<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Yeah, I&#8217;ve made python script to convert to the tree view (above) something like this (pairs address:ID):<\/p>\n\n\n\n<pre class=\"wp-block-code\" style=\"font-size:12px\"><code>{0o1:1, 0o2:2, 0o3:3, 0o11:4, 0o21:5, 0o31:6, 0o41:7, 0o111:8, 0o211:9, 0o1211:10, 0o11211:11, 0o5:33}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">I think this is really nice visualization, which should help me with testing and designing the network.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Like, how will the project look like? Which features will be implemented? How should the packet look like? A lot of packet processing is done by nRF24L01+ (like address processing, CRC, ACK&#8230;.) But some things still should be done. So:<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[55],"tags":[52,54,49],"class_list":["post-216","post","type-post","status-publish","format-standard","hentry","category-programming","tag-nrf24l01","tag-nrff","tag-python","entry"],"_links":{"self":[{"href":"https:\/\/www.jeskevic.info\/index.php?rest_route=\/wp\/v2\/posts\/216","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jeskevic.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jeskevic.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jeskevic.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jeskevic.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=216"}],"version-history":[{"count":1,"href":"https:\/\/www.jeskevic.info\/index.php?rest_route=\/wp\/v2\/posts\/216\/revisions"}],"predecessor-version":[{"id":217,"href":"https:\/\/www.jeskevic.info\/index.php?rest_route=\/wp\/v2\/posts\/216\/revisions\/217"}],"wp:attachment":[{"href":"https:\/\/www.jeskevic.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=216"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jeskevic.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=216"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jeskevic.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=216"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}