Pages

Thursday, 10 December 2015

Nightscout on the 640g: On The Go

Asking a four year old to stay near to a Windows PC 24/7 was never going to happen. Whilst my previous efforts at getting the 640g on to Nightscout work well for us at home, particularly overnight, it just couldn't keep up with a four year old's daily routine.

It's time to go Mobile.

Mobile, fully-portable access to 640g pump and CGM data from anywhere in the world.

640g pouch (left) and Bayer+Phone(right)
Options to Consider
Whilst small, light-weight Windows PCs, with a built-in battery, do exist (the Vensmile iPC002 for example) they are bulkier and heavier than most mobile phones and chew through their batteries (of similar capacity of a mobile phone) in much less time than your average smartphone. I've also not come across one that has built in 3G/4G connectivity.

All in all, although I'd be happy to upload my current setup on to one of these for personal use, or for use, by, say, a teenager, I don't want to burden my four year old daughter with a fully functioning Windows mini-pc strapped round her waist.

In terms of connectivity and portable, the obvious answer is a mobile phone, as with the other Nightscout rigs, but how to tackle the current reliance of CareLink on my current 640g Nightscout setup?

My Current Solution
The only thing that needs to be close to the pump is the Bayer Contour Next Link 2.4  meter. The PC running CareLink, Selenium, Java and the Bash scripts can be, well, anywhere.

All Janki has to carry is an Android phone and a spare Bayer Contour Next Link 2.4 meter. And her 640g of course, but that's hard to forget ;-)

To achieve this, I've used several off-the-shelf technologies.

Bayer Contour Next Link 2.4 + Android phone connected via USB OTG cable
USB IP
USB IP is a protocol which allows for USB devices to be remotely connected, over a network, to a client computer (i.e. the PC running CareLink in this case). The server hosting the USB device could - in theory - be just about anything that can handle the power, IO and networking requirements. But for us, for fully mobile use, it has to be a smartphone. The phone must be able to host USB On The Go (OTG).

I chose to use VirtualHere to achieve this. It offers Server and Client software for a variety of platforms, including Android. It's free to use when connecting just one USB device to the server. If you were to need more, or just to show appreciation to the developer, you might consider purchasing a license ($39). I should mention that when I first started to try to use the linux server on my Android phone, Michael, the developer at VirtualHere was very helpful and very quick responding to my questions. (Turns out there was nothing wrong with the VirtualHere setup - Sony / Google had broken USB OTG in the Lollipop upgrade... a rollback to KitKat solved that).

VirtualHere also works beautifully on a Raspberry Pi - here's our remote overnight solution, with the Contour Next Link 2.4 plugged into the Pi by Janki's bedside, instead of being plugged into a Windows laptop running in the room directly underneath her bedroom:


Once the PC's VirtualHere client is properly configured, CareLink does not distinguish between a Bayer physically plugged in or one over USB IP.

Virtual Private Network
USB IP, as implemented by VirtualHere, works most straightforwardly within a single network (Local Area Network, LAN) e.g. your home network.

But what if your little PWD is at school? At friends? Or at the park?

The USB IP server phone would then be, effectively out on the Internet. Thanks to the various firewalls in place (for a good reason) between your CareLink PC and the USB IP server phone on school WiFi or your mobile operator's cellular network, it would not be able to talk to the PC.

The solution is to setup a secure 'tunnel' into your home network by setting up a Virtual Private Network (VPN). If you home work, the chances are this is what you're doing when you log on to your work servers to get shared drives etc.

I've setup an OpenVPN server on a Raspberry Pi and used the Android OpenVPN client to access our CareLink PC remotely and securely.

The settings for this bit are reasonably complicated and will have to wait for another post, but, in a nutshell, they include port forwarding, opening the VirtualHere port, optimising data compression and socket handling to minimise latency (yawn, I know, I'll stop...). Initial testing confirms the phone will deliver at least a day's use between charges when working over 3G/4G.

I'll post details and add files on the Github site in due course.

It still needs some tweaks to optimise and improve stability, but this evening, I've been updating our Nightscout site via 4G (ie the via the Internet), with a phone and Bayer meter resting next to her bed.


Wrapping Up
I appreciate those with Dexcom or with previous generations of Medtronic pumps (either through MiniMed Connect or mmCommander) may wonder why I, at least, am excited by this?

Well, I look at each week with CGM as ~2,000 opportunities to improve my daughter's T1 management, her quality of life now (and in the future).

With no launch date announced for MiniMed Connect on the 640g and no direct access to the 640g data - that I currently know of - I'm just not waiting any longer.

Disclaimers: 
Do not use any of this information or code to make medical decisions! 
Connecting the Bayer meter via your mobile phone may damage your phone and/or the Bayer meter!

Update: If you've landed here looking for Nightscout on your 600-series pump, thanks for stopping by :) The simplest way to get your pump on to Nightscout is to use the 600-series Android Uploader. Enjoy!

7 comments:

  1. Hi Matt,
    this is so great! Thanks for that!
    What if I bought the Lumia 950 for an "all-in" solution, is that possible?

    ReplyDelete
    Replies
    1. Thanks! So, yes saw that both USB IP and VPN should be included in Windows 10 Mobile. Couldn't justify going out to get a handset specifically to try, but would be interested to see if it'd work. The real miracle would be if WM10 could run CareLink, but I'm not sure the builds are sufficiently close to allow that from what I've read..? Again would be great if someone could try and post :-)

      Delete
  2. Hi Matt,

    Congrats:) Have you considered tampering with the user-agent of a browser on android? I remember once trying the dolphin browser to log me on to the carelink portal (as it allows mocking the user agent) and it almost passed the test as the portal thought I was using a mac with safari but as the resolution of my old 4.5" mobile display doesn't exceed 800x600 it didn't let me in -and I haven't bought a mobile with bigger display yet:( Concerning selenium, there's a thing called selendroid for android, if that helps.

    Regards,
    r0ller

    ReplyDelete
    Replies
    1. Thanks :-) That's an idea I hadn't considered. I hadn't heard of selendroid too - thanks. I liked the Windows 10 mobile suggestion above also, as that might work out of the box without (much) tweaking.

      I'd be happy to try anything that reduced the number of steps / systems required to get the data up in the cloud. Every bounce is one too many. Bypassing CareLink would be *the* massive step of course! That would be a great Christmas present :-)

      Best wishes, Matt

      Delete
    2. Hi Matt,

      Bypassing Carelink would be the best, I agree but I've recently had to take a step back since my assumption about the raw sequence id proved to be wrong:( The index I found does seem to have to do something with that but I spent too much time concentrating on one usb capture and the corresponding carelink csv file, which lead me astray. The index I found in the usb capture matched exactly the column in the csv but verifying my assumptions on recent csv downloads and captures falsified it:( So I'm one step back now. I'll need to update the corresponding thread soon in the open aps dev forum too so that others don't follow a false track. However, going on with analysis. I've a few days off between xmas and new year so I'm looking forward to finding something.

      Best regards,
      r0ller

      Delete
    3. Sorry to hear it's being troublesome R0ller. Good luck with your efforts over the next week or so, but I hope you also get some time to enjoy Christmas time too!

      Delete
  3. hello , We saw your solution and I would like to use it for a 3 years old girl
    interessting solution . we are using nitghtscout also ; but because im not an expert very hard to setup. can you explain differently?? does this solution is still OK in 2019.
    Thanks for your help

    ReplyDelete