{"id":338,"date":"2010-12-26T18:39:09","date_gmt":"2010-12-26T17:39:09","guid":{"rendered":"http:\/\/tronche.com\/blog\/less-technical\/uncategorized\/2010\/12\/lego-mindstorms-what-does-bluetoothwrite-send\/"},"modified":"2010-12-26T18:39:09","modified_gmt":"2010-12-26T17:39:09","slug":"lego-mindstorms-what-does-bluetoothwrite-send","status":"publish","type":"post","link":"https:\/\/tronche.com\/blog\/2010\/12\/lego-mindstorms-what-does-bluetoothwrite-send\/","title":{"rendered":"Lego Mindstorms: what does BluetoothWrite send ?"},"content":{"rendered":"<p>I&#8217;m trying to get some telemetry working between a mobile robot and a PC over bluetooth.<\/p>\n<p>[http:\/\/bricxcc.sourceforge.net\/nbc\/ NXC] has all the features you need to send messages between robots and a PC. There are functions to send boolean, integers and so on, using a &#8220;mailbox&#8221; dispatching of messages, for example &#8221;SendRemoteNumber&#8221;.<br \/>\n<!--more--><br \/>\nI&#8217;m trying to get some telemetry working between a mobile robot and a PC over bluetooth.<\/p>\n<p>[http:\/\/bricxcc.sourceforge.net\/nbc\/ NXC] has all the features you need to send messages between robots and a PC. There are functions to send boolean, integers and so on, using a &#8220;mailbox&#8221; dispatching of messages, for example &#8221;SendRemoteNumber&#8221;. However I&#8217;ve decided to use the simpler &#8221;BluetoothWrite&#8221; primitive.<\/p>\n<p>And here&#8217;s what I got at the other side, sending strings of &#8216;*&#8217; of progressive length:<\/p>\n<p> $ cat < \/dev\/rfcomm0 | od -cx\n 0000000 001  \\0  \\0 002  \\0   *  \\0 003  \\0   *   *  \\0 004  \\0   *   *\n           0001    0200    2a00    0300    2a00    002a    0004    2a2a\n 0000020   *  \\0 005  \\0   *   *   *   *  \\0 006  \\0   *   *   *   *   *\n           002a    0005    2a2a    2a2a    0600    2a00    2a2a    2a2a\n\nIn summary, each message sent with ''BluetoothWrite'' results on the PC in the payload length coded on 2 bytes, LSB, then the data sent, including a trailing \\0 if you send a string without converting it to a byte array first.\n\n<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>I&#8217;m trying to get some telemetry working between a mobile robot and a PC over bluetooth. [http:\/\/bricxcc.sourceforge.net\/nbc\/ NXC] has all the features you need to <a class=\"mh-excerpt-more\" href=\"https:\/\/tronche.com\/blog\/2010\/12\/lego-mindstorms-what-does-bluetoothwrite-send\/\" title=\"Lego Mindstorms: what does BluetoothWrite send ?\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-338","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/posts\/338","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/comments?post=338"}],"version-history":[{"count":0,"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/posts\/338\/revisions"}],"wp:attachment":[{"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/media?parent=338"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/categories?post=338"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/tags?post=338"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}