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. 

Saturday, 27 August 2016

Firmware update for v11 models

Last weekend I was able to release a new firmware for the v11 models of the BlueFly. The v11 models have a different processor (the PIC24F32KA302 instead of the PIC24F32KA301) which uses different pins for most of the hardware functions. As a consequence there is a slightly different bootloader on the vario, although you do use the same ds30loader program on the PC side.

Firmware updates for BlueFlyVario started with v10, and you can still download the latest firmware for the v10 models from the firmware page of the website. For the v10 models you should follow the instructions in this previous blog post.

Do I need to update the firmware?

If you are happy with the performance of the BlueFly, and you do not need any of the features of the new firmware, then I strongly urge you to leave it alone. Although it only takes me a minute or two, many pilots find it tricky. If you are going to do it then the first step is to check what firmware you currently have.

The firmware for the initial release of the Bluetooth, TTL_GPS and USB models was 11.M09, 11.M10, and 11.M11 respectively. Although I only released the 11.M12 firmware last weekend, I have actually been shipping it with new varios for some weeks. You can see what version of the firmware your device has by using the BFVDesktop app and connecting to your device. That will be tricky if your TTL_GPS model is soldered to the Kobo. For that model try starting up the vario while you are looking at the monitor in xcsoar and read the message from the BlueFly. The first line includes the firmware version.

Key changes in 11.M12

The primary reason for releasing a new verison of the firmware is to support some changes for the Bluetooth model, although there are some other changes as well. In summary the changes are:
  • A new command designed which enables you to change settings on the RN4677 blueotooth model. Read the hardware settings manual to understand how to send a command. The command is:
    • $RNC ABC*, where ABC is the command to send to the RN4677. 
    • When you send that command to the BlueFly it sends back some serial signals to the RN4677 in the following manner:
      • Turns on the BlueFly green LED.
      • Sends $$$ to the RN4677, which puts it into command mode. This stops the BlueFly sending data. 
      • Waits 1000 ms.
      • Sends ABC to the RN4677 followed by the \n character. In most cases ABC is an individual RN4677 command you choose from it's user guide to adjust a setting on the module 
      • Waits 500 ms. 
      • Sends R,1\n to the RN4677 to restart the RN4677 and store the setting.  
      • Waits 500 ms. 
      • Turns of the BlueFly green LED. 
      • Restarts the BlueFly. 
    • It is really possible to screw up the RN4677 by doing this if you are not sure what you are doing. I will be posting some examples in a separate blog post. 
  • The new firmware maintains the volume of start and shutdown beep, regardless of the volume settings.
  • The RSX command now also sends $PMTK104*37 to U1. On the TTL_GPS model that forces the GPS to ditch its ephemeris data (satellite data) and restart. This can be used to recover a GPS which may be stuck in some kind of bad data loop. 
Bootloader changes

There are minor changes to the bootloader procedure for the v11 models. The procedures described in this previous blog post for the v10 still apply, but with the following changes:
  • Step 1 - Get the software: No change, the same ds30loader software is used. 
  • Step 2 - Prepare the hardware: On the v11 you now short the pins below (GND and SDA) to enter the bootloader mode. The names of these pins are shown on the bottom of the board. 


  • Step 3 - Open the ds30laoder application: Use the following different settings for v11, all of the others are the same as v10
    • Model: 32KA302
    • Baud: 115200
  • Step 4 - Start up the Bluefly in bootloader mode: No change; other than the different pins as shown above in step 2. 
  • Step 5 - Program the device: No change
Hardware Settings Reset

After updating the firmware I recommend that you execute a full hardware settings reset. On the v11 models you do that by shorting GND and SCL then starting the vario while the short is in place. Once you hear the high pitched fast beeps you can release the short and all of the settings will be back to the defaults.

TTL_GPS model addendum for the Kobo

Tyson let me know he has been working on updating the firmware on the BlueFlyVario_TTL_GPS with it still connected to the Kobo. In his words:

"Thought you might be interested in this small program I wrote. Converts the hex files into a shell script that can be directly run on the kobo to do the flash upgrade.

https://github.com/twhitehead/blueflyvario-hex2sh

Just finished using it to upgrade to the latest firmware for my BlueFlyVario_TTL_GPS_v10 model. Seemed to go good."

I am still waiting to find time to try it out. Let me know how much success you have.


Monday, 22 August 2016

BlueFlyVario_TTL_GPS_v11 component updates

This quick post describes a minor modification to the package contents with the BlueFlyVario_TTL_GPS_v11. The package now includes:
  • The BlueFlyVario_TTL_GPS_v11 main board programmed with the latest firmware.
  • A small piece of neoprene to protect the sensor.
  • 50mm of blue PVC heatshrink.
  • About 20cm of 4 core flat telephone cable.
There is also a slight change to the component layout on the most recent PCBs to allow for easier manufacture. The Rev 4 PCB layout has much more evenly spaced components, and is shown below with the components now included in the package.


Cable

The 4 core flat telephone cable included with the package is much more appropriate for soldering inside the Kobo. Strip the outer covering and use the wires individually. I used this type of cable on the Kobo Glo HD Install shown in this previous blog post. If you really want the 4x1P right angled header and 4x1P Dupont connector with wires please let me know when you order and I can include it in the package. 


Neoprene

The little piece of neoprene included with BlueFlyVario_TTL_GPS is really important. When placed properly it stops light from hitting the sensor, but allows air to permeate through so pressure changes filter through the two little holes on top of the MS5611 pressure sensor. 
  • I originally include the neoprene shown below. This has sticky tape on one side, and black squishy foam on the other. Unfortunately some pilots remove the sticky tape and put it on the sensor the wrong way; blocking the two little holes with the sticky glue and rendering the sensor pretty much useless. 
  • So, then I changed to different neoprene which does not have sticky tape on it so it does not matter which way it is placed on. Unfortunately it was a slightly different composition, and when that neoprene is squished on to the sensor really tight with the heatshrink it can restrict the airflow associated with pressure changes; to the extent that it affects the sensitivity of the vario to changing height. If you have this neoprene and it is not working for you please let me know and I can ship you some of the other stuff. 
  • Now I have changed back to supplying the original type of neoprene. The correct orientation is shown in the image below. The black squishy foam side should be the only thing which touches the sensor. Please put it on the right way!


Sunday, 14 August 2016

New BlueFly USB models released

I am pleased to release two new USB models of the BlueFly today. These models complement the Bluetooth and TTL_GPS models by providing devices which can connect via USB. Both are available for purchase on the new website http://blueflyvario.com/shop. This post is pretty long as there are many different ways you can use these two new varios.

Which BlueFly vario do you want? Choose between:
  • The Bluetooth model to connect to Android or iOS for use with flight apps.
  • The TTL_GPS model to solder to a Kobo or other device with a TTL Serial port.
  • The USB model as a stand alone audio vario; or for connection to USB ports on many devices.
  • The USB_GPS model for a wired connection to a Kobo or other device with a USB port, but without an inbuilt GPS.
BlueFlyVario_USB_v11

The new USB model is designed for use as a stand alone audio vario. In many ways it is similar to the BlueFlyVario_USB_v10. However, it now shares the more powerful battery and enclosed sky blue case as the Bluetooth model. In some ways it is a cheaper version of the Bluetooth model with a FTDI FT230X USB to serial chip instead of the more expensive Bluetooth module.


The package includes the items shown above:
  • BlueFlyVario_USB_v11 main board programmed with the latest firmware, and with a small piece of neoprene protecting the sensor.
  • 600 mAh Lithium Polymer battery.
  • 4 x 5mm nylon M3 hex standoffs and 4 x 6mm M3 nylon screws.
  • The skyblue BlueFly case.
To assemble the vario use the same procedure as the BlueFlyVario_Bluetooth_v11. The battery on the USB model should last much longer than 10 hours. The actual duration will depend on your audio settings. Charge it with a phone charger with a micro USB connection, or by connecting it to a USB port. 

For advanced users the BlueFlyVario_USB_v11 is the most hackable model yet:
  • It is compatible with the same shields as the Bluetooth_v11 model. 
  • The button and speaker both have headers underneath them if you want to remove either and wire in other components. 
  • On the PCB U2 is connected to the FT230X chip (which is then connected to the USB port), but there are exposed headers if you want to plug U2 directly into a TTL connection. 
  • You can close SJ1 if you want to power the vario directly from the USB power instead of the battery. Do not close this jumper if the battery is still connected or it will get uncontrolled voltage to the battery and it may be damaged.
  • U1 is exposed for shields or to connect to another UART device which sends NMEA strings. There is space on the USB model for a PA6H GPS, which brings us to the next model.  
  • You can close SJ2 if you want to connect VBackup of the GPS to the battery power (for the model shown below).



BlueFlyVario_USB_GPS_v11

The USB_GPS model is exactly the same circuit board as the USB model, however it has a PA6H GPS soldered in place. If you are just going to use the vario as a stand alone audio vario then the GPS adds no value. However, if you want to make a wired USB connection to an Android or Windows device which does not already have a GPS, or you want to connect to the USB port of some models of the Kobo, then this might be the vario for you. 


Note that I have not tested the USB_GPS model with a wide variety of devices. If you are considering using this vario please make sure that your device has an operating system which can access the serial output from FTDI based chips, and that xcsoar or whatever app you are going to use can find that serial output in the operating system. 

Connecting to PC

If you have either of the USB models you will probably want to connect it to a PC to adjust some hardware settings. When you connect it with a standard USB cable your PC should install the appropriate FTDI drivers in Windows 7 and 10. Use the BFVDesktop application (available in the software section of the support page) to connect to the installed serial port. 

Connecting to Android

To connect to Android you will need a USB-OTG cable and Android 4.0 or later. See the image below for an example of the connection required. You will probably use a procedure similar to that described in this blog post. You might also want to use the FTDI UART Terminal app to test the connection or send Hardware Settings as described in Annex A of the manual. That app is shown in the image below; make sure to set the baud rate at 57600. 


Connecting to Kobo with xcsoar

Establishing a connection to the Kobo USB port with the FT230X chip in the USB models is a little more involved. 
  1. First you need to modify the USB PID on the BlueFly FT230X chip. The standard PID on the FT230X is '6015'. This PID is not recognized by the standard ftdi_sio driver on the modified Kobo kernel. If you modify it to the PID associated with the FT232 chip ('6001'), then FTDI drivers work appropriately. This step is achieved by using the FT_PROG EEPROM Programming Utility from FTDI on a Windows PC. With your BlueFly connected you will 'Scan and Parse' to find the FT230X chip. Then navigate to 'USB Device Descriptor'|'VID PID', select 'Custom PID' in the drop down, change the PID from 6015 to 6001, then 'Program Devices' to write that to the BlueFly FT230X. 
  2. You need a USB OTG Y cable as shown below. The UART chip in the Kobo needs external power to work (the BlueFly does not provide it). This will work best if the BlueFly and Kobo are fully charged. If not, the external power pack will be quickly drained as both the Kobo and the BlueFly are charged from it.
  3. After you have installed xcsoar on your kobo you need to enable USB-OTG from the System menu at the start up screen. This will reboot the kobo and make its linux use a different kernel which has the ftdi_sio drivers. I have tested this step with the Kobo Mini and the Kobo Glo HD with xcsoar version 6.8.6. 
  4. In xcsoar navigate to Menu|Config|Devices|Edit, change the port to ttyUSB0, baud 57600, driver BlueFly. After clicking ok you might have to Disable and Enable a few times. Click the Monitor to see the data stream. 

If you connect the USB models to other devices please contact me and I will update this post.