Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offline xdrip #1248

Merged
merged 64 commits into from Oct 29, 2019
Merged

Offline xdrip #1248

merged 64 commits into from Oct 29, 2019

Conversation

scottleibrand
Copy link
Contributor

Cleaned-up version of #1139, in an openaps/oref0 branch for easier testing.

We'll need some folks who use xDrip to test. To do so, follow the https://openaps.readthedocs.io/en/latest/docs/Customize-Iterate/update-your-rig.html#alternative-step-1b-test-a-feature-branch-not-recommended-for-initial-setup instructions to test the offline-xdrip feature branch.

@sulkaharo
Copy link
Collaborator

Yay @scottleibrand thanks. Commenting here too - we've had this on our production rig from the first commits and after the latest fixes in Jan, I haven't had any issues + the offline looping has worked in a plane & boat & underground. I'll have access to the xDrip phone in the evening and can post shots of where to configure this in xDrip.

@PedanticAvenger
Copy link
Contributor

Ok, I've experienced a repeated problem moving between dev and offline-xdrip branches. While on dev system operates correctly, but once I move to offline-xdrip looping ceases. The errors in ns-loop.log show as..

Starting oref0-ns-loop at Wed May 1 21:03:02 MDT 2019:
module.js:550
    throw err;
    ^

Error: Cannot find module 'network'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.Module._load (module.js:475:25)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/root/src/oref0/bin/oref0-get-ns-entries.js:27:15)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)

@PedanticAvenger
Copy link
Contributor

edison/explorer and I haven't tested deeply to see if the offline aspect works. I had xdrip forwarding to the appropriate port but still wouldn't loop. Switching back to dev immediately resolved.

@p5nbTgip0r
Copy link
Contributor

p5nbTgip0r commented May 15, 2019

The only issues I saw were that the node packages network, yargs, and request did not seem to get installed. After setting up and installing the branch I saw in the ns-loop.log there were errors about missing the network and request modules and I also saw errors about missing yargs in the pump loop logs.

Navigating to /root/src/oref0/node_modules and running the command npm install network request yargs seemed to fix the errors. I'm not entirely sure why this is necessary, but I'm hoping it was just from me having an old node_modules folder from my installation on the dev branch.

The functionality added in this branch seems to work well. I haven't had a chance to test in day to day life yet, however I forced BT tethering by disabling Wi-Fi on the rig and disabled networking on my phone to simulate being offline and the ns-loop.log pulls from xDrip's local server with no issue. When it is able to pull from Nightscout, it tries that first and then resorts to xDrip's server if necessary.

To make testing this branch a little easier I would suggest merging the changes in oref0-setup.sh on the dev branch into this branch as the Go pump binaries not downloading made setting up this branch a little more difficult than necessary. I opened a pull request for this at #1255

Other than the setup hiccups I had, which I'm hoping were my fault due to an old node_modules folder, I would say it looks good to me. I will try this out for a few days and report back if any issues arise.

cluckj and others added 4 commits May 15, 2019 07:09
* Remove binary download options

* Add radiotags to runagain, and fix bug for radiofruit hardware type
Mount the Edison's FAT32 partition to give us enough room to install golang.
Pass radiotags to oref0-setup.sh from oref0-runagain.sh.
Fixes issue of `Cannot find module 'network'` in the ns-looplog.
rebecca-draben and others added 15 commits October 27, 2019 11:34
Add 2019

Co-Authored-By: viq <vicviq@gmail.com>
* Have autotune sync to NS nightly after autotune runs

This will keep Nightscout in sync with autotune after the nightly run.

* always round insulin to carb ratios to 0.1g

* round basal rates to 0.01 U/h, not 0.001

* sleep 60s to generate a new profile.json
* Standalone MRAA installer for OpenAPS v0.7.0

Addresses #1270

* Add oref0-mraa-install to package.json
* Unused local variables

* Unused local variables
* per #1288, only use minZTUAMPredBG if enableUAM, and use minGuardBG otherwise

* upload preferences.json to devicestatus

* use --preferences instead of positional arguments

* yargs entry for --preferences

* upload oref0 package.json version string

* redact sensitive fields in preferences.json

* reduce size of large logfiles like new -date ones
* Move the enable SMB into its own dedicated function

This will allow easier SMB conditional implementations

* Forgot to remove the existing logic...

* fix function naming

* function fix round 2
* Non-breaking space detected by eslint
@sulkaharo
Copy link
Collaborator

Tested on Edison, both with 1) not connected to xDrip hotspot, 2) connected to Android with xDrip share disabled and 3) connected to Android with xDrip share enabled and this works as expected (data is loaded from Nightscout when xDrip is not available and xDrip when it is available).

@scottleibrand
Copy link
Contributor Author

We don't use xDrip at all, so running this on one of our rigs for regression testing. In the ns-loop.log, I now see this scary error:

Load from xDrip failed { Error: connect ECONNREFUSED 10.0.1.1:17580
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1191:14)
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '10.0.1.1',
  port: 17580 }
Got Not Changed response from Nightscout, assuming no new data is available
My router IP is 10.0.1.1
Trying to load CGM data from local xDrip
Load from xDrip failed { Error: connect ECONNREFUSED 10.0.1.1:17580
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1191:14)
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '10.0.1.1',
  port: 17580 }
Got CGM results from Nightscout

We should change that to not show that error for people not using xDrip.

@sulkaharo
Copy link
Collaborator

Doh, yes ECONNREFUSED should be also caught in the error statement. Sec

@scottleibrand
Copy link
Contributor Author

scottleibrand commented Oct 27, 2019

Better, but still getting a bunch of unnecessary logging:

Starting oref0-ns-loop at Sun Oct 27 12:48:02 PDT 2019:
My router IP is 10.0.1.1
Trying to load CGM data from local xDrip
Load from local xDrip timed out, likely not connected to xDrip hotspot
Got CGM results from Nightscout
My router IP is 10.0.1.1
Trying to load CGM data from local xDrip
Load from local xDrip timed out, likely not connected to xDrip hotspot
Got Not Changed response from Nightscout, assuming no new data is available
Found recent valid BG:
{"glucose":96,"dateString":"2019-10-27T19:42:48.000Z"}

I think if we got rid of the newline after My router IP to join that line with Trying to load CGM data from local xDrip, so it reads something like:

My router IP is 10.0.1.1; trying to load CGM data from local xDrip

and then get rid of the duplicate logging on the second attempt at hitting xDrip, we'd be down to a non-concerning level of logging for non-xDrip users.

sulkaharo and others added 3 commits October 27, 2019 13:30
* Detect socket timeout and don't log stack trace

* Add  ECONNREFUSED to safe error list, better error message

* Consolidate IP logging to same line as xDrip load notification, remove unused variables

* Disabled xDrip logging after first error
@scottleibrand
Copy link
Contributor Author

With those fixes, this now LGTM. If anyone else wants to test anything before we merge this to dev, please speak up. Otherwise I'll do so sometime after running it for the rest of the day and confirming it doesn't cause any issues for non-xDrip users.

@scottleibrand
Copy link
Contributor Author

Still looks good on one rig. Merging to dev for more folks to test more broadly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet