Ticket #80 (closed development: fixed)
Support direct Bluetooth SPP interface from Instrumentation Control Toolbox (2011b)
|Reported by:||atorf||Owned by:|
This ticket is a summary and rough guide on how to implement the new "direct Bluetooth SPP" interface of MATLAB 2011b's Instrumentation Control Toolbox. For details on this interface, see http://www.mathworks.com/help/toolbox/instrument/bs5lmbi.html
For connection establishment, sub-function BT_OpenHandle in trunk/mfiles/COM_OpenNXTEx.m would have to be adapted, and maybe the code in COM_OpenNXTEx calling it. If new fields have to be added to our handle struct, see inside trunk/mfiles/private/createHandleStruct.m for the function closures.
With the new interface, the complete concept of "serial ports" is gone, as one directly talks to connected NXT devices. This means, the currently implemented idea Bluetooth-ini-files has to be revised. At the moment, it is "one config-file per virtual port", i.e. one config file for many possible NXT devices. Device selection happens via Bluetooth driver or a Linux script.
Without serial ports, config-files need to be "device specific", so they should contain an NXT device name or (better) its MAC (unique serial no.). Another way is to treat the new interface just as our current way to connect multiple NXTs via Bluetooth — i.e. via the extended syntax of COM_OpenNXTEx. However, then m-files are device-specific, and have to be adapted when used with different NXT devices. This was exactly the reason why "device independent config-files" were developed…
Anyway, once the design issue of how to manage NXT devices based on names or MACs is decided, and once connection handling is updated in COM_OpenNXTEx (especially BT_OpenHandle in there), the files trunk/mfiles/COM_SendPacket.m and trunk/mfiles/COM_CollectPacket.m can be updated (sub-functions BT_SendPacket and BT_CollectPacket). This should be straight forward and without a problem.
Key issue is the intended workflow for users: Where and how is the NXT device chosen that should be connected to? In earlier toolbox versions, we once had an "automatic BT connection feature" which was dropped later on for various reasons (see VersionGuide, ReleaseNotes and especially ticket #9 for a discussion).
In my personal opinion, it would be best to follow the idea of our btconnect-script trunk/tools/LinuxConnection/btconnect and try to implement this exact functionality somehow into MATLAB. Adding / mangling this functionality directly into COM_OpenNXTEx might make things more complex or break the workflow current users are used to. But that's just a "maybe", things would just have to be thought through and tested!
The main advantage of this effort would be better hardware compatibility and more stable Bluetooth support. In our early hardware tests from 2007 (BluetoothAdapter) we found that the combination Bluetooth + NXT + MATLAB is a very tricky one. While the LEGO NXT device is very picky with supported BT hardware anyway (LEGO's "fault"), even some of LEGO's recommended hardware failed with MATLAB. Hopefully with the new direct SPP interface, this additional limitation would fall, and the RWTH - Mindstorms NXT Toolbox would support all the BT hardware which runs with the LEGO NXT device!
The price for this possible improvement is the necessary development described in this ticket, and the introduction of a new dependency for users: MATLAB 2011b and the Instrumentation Control Toolbox. Previous toolboxes rely on 2008b and no additional toolbox!
Any comments are very welcome!