Skip to content

Prepare Edison for OpenAPS with Yocto

Scott Leibrand edited this page Sep 18, 2016 · 69 revisions

Important

It is recommended to follow Prepare the Edison for OpenAPS guide so that the config is as-close to the Raspberry Pi as possible. This fits best with OpenAPS documentation. The following setup is based on @ps2 and @amazaheri experiments configuring OpenAPS using Intel's latest yocto 3.0 and has been used and validated in a 24/7 setup at home and at school. There are other people in community who had successfully configured their system using the following setup and others who have had some issues currently being looked at by us and Intel support team. Please try these steps on your development rig first before configuring your production system.

Make sure your edison has a recent build installed

root@edison:~# configure_edison --version
159.devkit
(Or just 159 is fine too)

If the above command errors, or shows an older version, please update your edison following the instructions here: https://software.intel.com/en-us/iot/hardware/edison/downloads

Note: If you run latest image 3.0

cat /etc/version

should show 201603141535 , we have configured and verified these steps on Release Yocto 3.0. If you experience any issues with connman on 3.0 per Intel's support team suggestion you can try the previous build 280915.

Initial Setup

After logging in using console port, login as root. For first time no password required, to assign a root's password and enable SSH through port 22 run:

configure_edison --setup

Disable Services

You don't need these services on this system:

systemctl disable redis
systemctl stop redis

Set your timezone

Replace the America/Chicago part with your time zone. You can ls the directories (or press tab) to see what's available.

ln -nfs /usr/share/zoneinfo/America/Chicago /etc/localtime

Configuring wifi

To configure wifi simply run:

configure_edison --wifi

For more advanced scenarios like multiple SSIDs, roaming and Bluetooth you can try connman. To use connman you need to stop and disable the wpa_supplicant service and start and enable the connman service:

systemctl enable connman
systemctl start connman

Then run connmanctl and follow these steps:

connmanctl> scan wifi
connmanctl> services (Showing a list of available SSIDs and assigned ids)
connmanctl> agent on
connmanctl> connect wifi_xxxxxxxxxx_xxxxxxxxxx_managed_psk 

If prompted, type in your passkey for the wifi you are connecting

connmanctl> exit

REBOOT - You should reboot to make sure everything works as expected. Make sure you have a USB handy to connect to the serial console.

For More information refer to Wi-Fi User Guide for Intel® Edison Products

The Connman Documentation is also very useful.

Connman Wifi Troubleshooting

If you receive the message below, it may disappear if you reboot:

Error /net/connman/service/wifi_....._managed_psk: Not registered

Install git and cronie

Run:

opkg update
opkg upgrade
opkg install rsync
opkg install git

Install other dependencies.

wget https://pypi.python.org/packages/source/i/importlib/importlib-1.0.3.tar.gz#md5=3ddefaed1eea78525b9bd4ccf194881d
tar -xzvf importlib-1.0.3.tar.gz
cd importlib-1.0.3
cp -a importlib /usr/lib/python2.7/
cd ..
wget https://pypi.python.org/packages/source/p/pyserial/pyserial-3.0.1.tar.gz#md5=c8521e49f8852196aac39431e0901703
tar -xzvf pyserial-3.0.1.tar.gz
cd pyserial-3.0.1
python setup.py install
cd ..
wget https://pypi.python.org/packages/source/s/setuptools/setuptools-19.7.tar.gz#md5=b016816564e09b500a02857f79fc8a68
tar -xzvf setuptools-19.7.tar.gz
cd setuptools-19.7
python setup.py install
cd ..
wget https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz#md5=3a73c4188f8dbad6a1e6f6d44d117eeb
tar -xzvf pip-8.0.2.tar.gz
cd pip-8.0.2
python setup.py install
cd ..
git clone https://github.com/openaps/openaps-contrib.git
cd openaps-contrib
python setup.py install

cd ..
git clone https://github.com/oskarpearson/mmeowlink.git mmeowlink-source
cd mmeowlink-source
git checkout master
pip install -e .

easy_install -ZU openaps

npm install -g json
npm install -g oref0

Configuring hotspot connectivity through bluetooth:

If you want to use connman to connect your rig to your hotpot (like your iPhone), while you can use wifi option, preferably you can connect via bluetooth. Using connman at school has been proven to be solid and covers roaming and auto connecting without requiring to use a custom script or a cron job! For more information on how to use bluetoothctl command refer to Intel Edison Bluetooth Guide or https://wiki.archlinux.org/index.php/Bluetooth

Note: Make sure to turn on Bluetooth tethering for Android and Personal Hotspot (tethering) for iPhone first.

Simply following the screenshots here and you are good to go:

  1. Run bluetoothctl

  2. Once bluetoothctl is running, and you see the '[bluetooth]' prompt, run scan on. You can also type exit to quit bluetoothctl.

  3. For an iPhone: make sure your phone is on, unlocked, and in the bluetooth settings menu. An entry should then be displayed in the bluetoothctl output, saying something like 'yourphonenamehere'. You will need to pair with the long string of numbers next to it (something like 7C:01:02:03:04:05)

  4. Pair the device:

  5. Verify the device is connected:

  6. Save BT connection so connman automatically connects to it:

  7. Enjoy!

The auto connect setting with BT works sporadically, we have a case with Intel as we speak. For now running:

connmanctl connect bluetooth_xxxxxxxxxxxx_xxxxxxxxxxxx

Should connect your Edison to your smartphone.

Bluetooth Troubleshooting

If you get an error similar to this, you may need to restart your phone and try connecting again.

Error /net/connman/service/bluetooth_984FEE04304F_0C771A341747: Input/output error

If you get this message, then make sure that you have enabled your phone's "personal hotspot" or network sharing:

Error /net/connman/service/bluetooth_984FEE04304F_0C771A341747: Operation aborted

Using RileyLink and Mmeowlink (Optional)

  • git clone or pull mmeowlink and switch to rileylink_support branch and install the latest:
git checkout rileylink_support
pip install -e .
  • Install bluepy
pip install bluepy
  • Run:
 rfkill unblock bluetooth
 hcitool lescan
  • Find your RileyLink device address. It will start with 00:07:80

  • Add a device using opens toolkit as follows and pass both RileyLink device address and pump serial number as parameters:

openaps device add pump mmeowlink rileylink [RileyLink Device Address] [Pump Serial Number]

You should be able to do normal openaps 'use' commands.

One issue however is in aliases, stringing report requests like this don't seem to work:

history = ! bash -c "(openaps report invoke monitor/model.json monitor/status.json)"

You need to separately invoke each report like this:

history = ! bash -c "(openaps report invoke monitor/model.json && openaps report invoke monitor/status.json)"

Also, please note that your loop will run much slower than using a TI stick.

Logging

To view logs you need to use journalctl command as there are no syslog as in ubilinux, you can archive per boot and get logs for specific process:

journalctl -u connman

You can also export the logs to a specific format like JSON:

journalctl -u connman -o json > connman-log.json

Remote Management

MeshCentral or Weaved services let you connect easily and securely to your Edison from a mobile app or browser window anywhere in the world! This is really helpful for troubleshooting and basic service is free!

To install and configure follow the steps for MeshCentral or Weaved

MeshCentral Screenshots: