Monday, 29 August 2016

Force Bluetooth SPP Mode

Yesterday I posted about a firmware update with a new hardware command for adjusting settings on the RN4677 bluetooth module. Today I will tell you how to use this new command to force the RN4677 to use Bluetooth SPP mode. This was motivated by getting the BlueFlyVario_Bluetooth_v11 to work with some Android devices (like the WayteQ x995). The procedures described here will also help with some apps (FlyMe and XCTrack).

Some background

The RN4677 bluetooth module from Microchip included on the BlueFlyVario_Bluetooth_v11 is a very capable device. You can find a comprehensive user guide here: http://www.microchip.com/wwwproducts/en/RN4677. This module allows the BlueFly to connect to iOS devices using Bluetooth Low Energy (otherwise known as BLE, or Bluetooth 4.0), while also being able to connect to a very wide variety of Android and Windows PC Bluetooth adapters using Bluetooth Simple Port Protocol (otherwise known as SPP, which is available on Bluetooth 2.0 or 2.1 devices).



A full description of how these protocols work is beyond the scope of this post. However, it is sufficient to say that if your Android device supports BLE (most new devices) and SPP (almost all devices), then it is possible that an Android app might try to connect to the BlueFly over BLE. If that happens then the connection will probably fail. So far, I do not think that there are any Android apps which have BLE working with the BlueFly. It is something which is on my todo list for the BlueFlyVario app.

Step 1: Connect to the BFVDesktop application

The first step is to get your BlueFly connected to the BFVDesktop application (download from here) via a PC with a Bluetooth adapter. If your Bluetooth adapter supports BLE and you can not seem to avoid it then you can force a non BLE connection by disabling part of the driver. A quick way to do this is to open Device Manager and disable 'Microsoft Bluetooth LE Enumerator' in the Bluetooth section. Make sure to remove the BlueFly device, then add it again and complete the pairing process. Use the paired virtual serial port in the BFVDesktop application. You should see the data streaming in.

Step 2: Make sure you can communicate with the BlueFly 

Send a few test commands using 'Raw Tx:' Try $BTN* to simulate button presses. You should hear beeps.

Step 3: Adjust settings on the RN4677

Send the command $RNC SG,2*

Note the space between RNC and SG. When you send this command the BlueFly does the following:
  • Puts the RN4677 module into command mode (by sending $$$ from the processor the the RN4677); this kills the connection. 
  • Sends the RN4677 the SG,2 command (see page 17 here: http://ww1.microchip.com/downloads/en/DeviceDoc/50002377A.pdf - You can use the RNC command to the Bluefly to progressively send any series of set commands the RN4677; but be careful unless you know what you are doing)
  • Sends the RN4611 the command R,1; which resets it and stores the setting
  • Restarts the BlueFly
Step 4: Restart everything

You will then need to restart the BFVDesktop app to connect again. Unfortunately, there is no easy way to check the settings on the RN4677 unless you have a TTL-Serial adapter and can solder it in between the processor and the RN4677.

After that, un-pair the BlueFly from your Android device, restart the device and the BlueFly, and then try paring and connecting again. XCTrack and FlyMe should now work!

Further Steps

If that does not work you might also want to try further configuring the RN4677 authentication modes. On some devices that affects how they connect after pairing:
  • $RNC SA,1* will change the RN4677 from 'SSP just works' mode to 'SSP pin code confirm mode.
  • $RNC SA,4* will change the RN4677 to legacy 4 digit pin mode. The default pin is 1234.
There are many other settings you can mess with (and mess up) on the RN4677. If you really screw it up please contact me. 

No comments:

Post a Comment