Pages

Friday 13 November 2015

Nightscout: now on the 640g

I've been a keen follower of Nightscout and the whole We're Not Waiting movement for sometime.

However, as the Nightscout solutions have revolved around the Dexcom G4 and previous generation Medtronic pumps, we've been forced to look, but not touch the Nightscout riches.

Not any more though.

I'm sat downstairs typing this, keeping an eye on Janki's CGM readings from her Medtronic 640g upstairs via Nightscout:


And I love it as much as I thought I would :-)

What this is:

  • Automated (for up to a day currently) transfer of 640g CGM data into Nightscout
  • For remote monitoring inside the home or school classroom environment


And what it isn't:

  • Ready for prime time: this is at Proof of Principle development stage
  • Fully mobile: it is not as mobile as an xdrip / Dexcom receiver solution (read on)
  • Iinstantaneous: there is a 5-10 minute delay on SG data with the current setup
I'm posting this to show other 640g users that there's NS hope, not to claim a final, polished solution exists.


When Janki started on the 640g we knew the radio frequency would be different and that the newly minted Medtronic Nightscout port (mmcommander), then very recently released by Jesus Berian, would not work.

What I didn't realise at the time was that the radio would also be encrypted for the first time [not necessarily a bad thing as the transmitter now calculates SG as well just pushing out raw ISIG] and the radio data packet would also be shaken up...

What to do?


Well, in-between marveling at the very neat solutions - both hardware and software - coming out of Nightscout and hearing of the blood sweat and tears spent by others trying to unlock the 640g we were encouraged to read about Medtronic's MiniMed Connect launch earlier this autumn in the US (on the previous generation of pumps) and to see a community solution (led by Mark Wilson) porting that data over to Nightscout via CareLink (I did look at that code for this project, but have not included it in this solution - it does look like a great platform to develop further then Connect eventually becomes available!)

I know MM Connect exists on the 640g, at least in prototype form. However, Medtronic will not reveal a launch date for the Connect in the UK on the 640g, nor even confirm it's coming (I read a community post quoting 2017 for European release but I have no idea if that's accurate. I hope it isn't).

The Sound of Music

So I started working on a mobile solution, which focused on the pump alarms, using a sound recognition app and just required Janki to carry a small, light-weight mobile phone with her. Although that was useful and works well, particularly for monitoring in the evenings and overnight, it isn't 100% reliable and does not always relay alerts immediately.



Give me the Full Picture
But I really, really wanted Nightscout on the 640g and, after spending time with some of the wonderful UK NS Faculty and NS's one and only Wes Ton the other week, I was more determined than ever to make it work, one way or another.



Anyone reading my September blog on the remote alerts, may have picked up on my thought process of how I was going to achieve this... :-) In a nutshell, my current solution runs using a combination of batch / shell scripts to pull the CGM data from Janki's 640g via CareLink. The CSV file is then extracted from CareLink and relevant data extracted. That dataset is then sent up to our Nightscout website via the standard API using cURL. In its present form it requires a Windows 7+ laptop or tablet (due to CareLink) and an internet connection (3/4G or WiFi).

A Bayer Contour Next Link 2.4 BG meter needs to be plugged in throughout (i.e. you'd be wise to use a spare - linked - meter). The scripts are designed to run for up to 24 hours without user intervention and poll the pump every 5 minutes. [At present I'm using every 10 minutes whilst I get a better feel for any significant battery impact on the pump side - nothing of note yet].

On the Shoulders of Giants...
I'm far from the first person to do something like this in the world of CGM data.

Indeed, I believe John Costik started his remote T1D monitoring in a similar way.

I'm also indebted to Ben West who developed a small suite of utilities (mmcsv) to fetch and parse CareLink CSV files from the previous generation of Medtronic pumps. Although I wasn't able to use the fetch components, have made a number of changes to his efficient code to allow me to use it extract the CGM data from each 640g CSV file.

At the moment, I'm working through the other parameters in the CSV file. From the example data I've seen, the 640g CSV file has significantly more data locked away in it than the older Medtronic pumps. It'll be fun to get as much of that over and up into Nightscout as possible :-)

I'll try to get more info up very soon, but for now, after a week of wonky Enlite sensors and very little sleep, I'm going to leave this one here and just enjoy finally getting automated remote access to Janki's 640g CGM data.

Thank you Estelle for the spare Bayer Contour Next Link 2.4! And a huge thank-you to the developers and supporters of Nightscout who have allowed us to reclaim our T1D data.

As ever, feel free to post a comment below, on Facebook or on Twitter :-)

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!

17 comments:

  1. Can you explain how you are causing the Nextlink to work with the Carelink software to upload every 5 minutes?

    FWIW, I also developed decocare, and mmblelink, and have been also working on the Nextlink. If you can capture some "sniffs" of the usb traffic to the Nextlink, we can provide you with a way to upload to NS straight from pump memory in the same way.
    * https://github.com/bewest/bayer-medtronic-interface
    * https://github.com/bewest/decoding-bayer

    USBLyzer is a free one for windows.

    ReplyDelete
    Replies
    1. Sure Ben - will get in touch directly in a minute and give this a spin. Would be great to pull this direct without going via CareLink clunkiness... :-)

      Delete
    2. Connection StatusDevice connectedCurrent Configuration1SpeedFull (12 Mbit/s)Device Address2Number Of Open Pipes2
      Device Descriptor Contour Link USB Device
      OffsetFieldSizeValueDescription0bLength112h1bDescriptorType101hDevice2bcdUSB20200hUSB Spec 2.04bDeviceClass100hClass info in Ifc Descriptors5bDeviceSubClass100h6bDeviceProtocol100h7bMaxPacketSize0140h64 bytes8idVendor21A79hBayer Health Care LLC10idProduct26210h12bcdDevice20100h1.0014iManufacturer101h"Bayer HealthCare LLC"15iProduct102h"Contour Link USB Device"16iSerialNumber103h"0000000001033442"17bNumConfigurations101h
      Configuration Descriptor 1 Bus Powered, 300 mA
      OffsetFieldSizeValueDescription0bLength109h1bDescriptorType102hConfiguration2wTotalLength20029h4bNumInterfaces101h5bConfigurationValue101h6iConfiguration104h"Full Speed Configuration"7bmAttributes180hBus Powered4..0: Reserved...00000 5: Remote Wakeup..0..... No6: Self Powered.0...... No, Bus Powered7: Reserved (set to one)
      (bus-powered for 1.0)1....... 8bMaxPower196h300 mA
      Interface Descriptor 0/0 HID, 2 Endpoints
      OffsetFieldSizeValueDescription0bLength109h1bDescriptorType104hInterface2bInterfaceNumber100h3bAlternateSetting100h4bNumEndpoints102h5bInterfaceClass103hHID6bInterfaceSubClass100h7bInterfaceProtocol102h8iInterface105h"Hid Interface"
      HID Descriptor
      OffsetFieldSizeValueDescription0bLength109h1bDescriptorType121hHID2bcdHID20111h1.114bCountryCode100h5bNumDescriptors101h6bDescriptorType122hReport7wDescriptorLength2002Ah42 bytes
      Endpoint Descriptor 04 4 Out, Interrupt, 1 ms
      OffsetFieldSizeValueDescription0bLength107h1bDescriptorType105hEndpoint2bEndpointAddress104h4 Out3bmAttributes103hInterrupt1..0: Transfer Type......11 Interrupt7..2: Reserved000000.. 4wMaxPacketSize20040h64 bytes6bInterval101h1 ms
      Endpoint Descriptor 83 3 In, Interrupt, 1 ms
      OffsetFieldSizeValueDescription0bLength107h1bDescriptorType105hEndpoint2bEndpointAddress183h3 In3bmAttributes103hInterrupt1..0: Transfer Type......11 Interrupt7..2: Reserved000000.. 4wMaxPacketSize20040h64 bytes6bInterval101h1 ms
      Interface 0 HID Report Descriptor Vendor-Defined 1
      Item Tag (Value)Raw DataUsage Page (Vendor-Defined 65)06 40 FF Usage (Vendor-Defined 1)09 01 Collection (Application)A1 01 Usage Page (Vendor-Defined 256)06 FF FF Usage Minimum (Undefined)19 00 Usage Maximum (Vendor-Defined 127)29 7F Logical Minimum (0)15 00 Logical Maximum (127)25 7F Report Size (8)75 08 Report Count (64)95 40 Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)81 02 Usage Page (Vendor-Defined 256)06 FF FF Usage Minimum (Undefined)19 00 Usage Maximum (Vendor-Defined 127)29 7F Logical Minimum (0)15 00 Logical Maximum (127)25 7F Report Size (8)75 08 Report Count (64)95 40 Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit)91 02 End CollectionC0

      Delete
    3. Thanks for sharing Pasi - Ben now has similar analysis from our stick, including a CL upload. Hopefully not too much has changed... :-)

      Delete
  2. Great work. So glad there are clever determined people like you in the parents of t1 community!

    ReplyDelete
    Replies
    1. Hi Matt,
      I am wondering if you could be kind enough to advise me how to get started with night scout, my daughter has a 640G and enlite CGM. much appreciated Malak

      Delete
    2. Hi Malak, Sorry for the delay getting back to you. Sure, well things have moved on quite a bit since I put this together :) I'd recommended using the Android app for the 600-series, led by Lennart, which can be found at https://github.com/pazaan/600SeriesAndroidUploader/wiki
      Good luck :)

      Delete
  3. Amazing work Matt...my daughter of 4 is on 640g, we so desperate for NS...a piece of mind that I would pay in blood for. The NS team are game changers! We were at one point going to switch to Dex just for NS. But we need the auto suspend/resume and other benefits the 640g provides over the rest. I hope you all realise the work you do has such a positive effect on lives across the world. I just wish I was at your level of understanding to develop a work around.

    ReplyDelete
  4. Many thanks for your kind comments Shaik. Our daughter is now 4 also and I could put a tick against all of those thoughts you make. I hope by showing that it can work on NS, it does bring hope to others who would benefit from NS. I'm hopeful that with other experienced devs involved this can be developed into a solution that, eventually is just as flexible and reliable as G4 users enjoy.

    ReplyDelete
  5. Matt this is all great stuff. Just got back from my 4 year old daughter's school to do a set change as she has been reading over 20 for a couple of hours. NS would be amazing for us. Is there anything we can do to help you develop this further?

    ReplyDelete
  6. Thanks Adele. Sounds like we're in the same boat. I'm focusing on testing at home, working with school to get this in her classroom. Also hoping devs with more CL CSV experience can tweak the tweaks and also see if we can ditch CL altogether... Once the dust settles will be posting more on getting it out there and getting it tested :-)

    ReplyDelete
  7. Hi Matt,

    When you say "my current solution runs using a combination of batch / shell scripts to pull the CGM data from Janki's 640g via CareLink. The CSV file is then extracted from CareLink and relevant data extracted.", you mean by CareLink the portal itself, right? If not, I'd be interested in how you convert the raw data pulled out from the 640G, as I'm also at the point where I can get the raw data out of the pump through the Bayer Contour NextLink2.4 using my own program but I can't interpret/convert it to anything meaningful:( Could you please, share how you do it?

    Thanks&regards,
    r0ller

    ReplyDelete
  8. Hi r0ller, thanks for the message. Yep at the moment via CL portal itself (see http://littlet1d.blogspot.co.uk/2015/11/nightscout-on-640g-first-details.html). That's certainly not how I'd like it to roll long term but it does allow us monitoring at home and within a classroom potentially. So, sorry at the moment I haven't looked at getting the info directly without the CL bounce. Like you (recognised you from the OpenAPS dev group) I'd be looking at Ben West's efforts with the older stick in the hope that not everything has changed. But it sounds like you're making some progress? If you message me via the FB page we can pick this up. Hopefully I'll get the CSV translation stuff up in a repo soon and I can let you know the location of that too. Cheers, Matt

    ReplyDelete
    Replies
    1. Hi Matt,

      Yepp, I did make some progress and have just updated the project on github. But as I indicated it on the OpenAPS forum, it's currently only capable of downloading the blood glucose measurements, not that of the CGM. However, it's already in a shape with which anyone can play. I also do know which commands the official CL java upload issues so I just need to modify it to get everything downloaded by my app on its own. But first, I'd need to be able to interpret the data I usually capture with wireshark. Foretunately, yesterday I already found the first anchor point in the structure which is the raw sequence number that can as well be found in the CSV that the CL portal itself offers for download. Using that it seems, I can now seperate the data stream into records. However, everything else in the records seem to be quite bogus at least I haven't yet found any obvious connection between any other column of the CSV and the bytes of a record:( I'll post these results as well on the forum today so that others can join in decoding MM640G CGM data.

      Regards,
      r0ller

      Delete
    2. Me again, sorry but forgot to mention that I'm not on FB. I already have a big brother called google and I'm not pretty sure if I need another one.

      Regards,
      r0ller

      Delete
    3. r0ller, sounds like great progress. I'd love to see CL bypassed to make this truly, completely mobile. I noticed Ben West picked up on the raw sequence and its importance when he put together mmcsv. Kind of getting the feeling might just be a case of finding the right key now...
      Hope to get mmcsv changes and extensions up on github next day or two, t1 depending...

      Delete