Skip to content

Setup and Configuration

Barış Kurtlutepe edited this page Feb 25, 2019 · 29 revisions

Setup

In order to run omnipy, you need to set up two devices and install a variety of software on the two of them. Here are the 5 steps to get omnipy up and running with AndroidAPS:

Step 1: Android - Get a clean device

Cleandroid

Your android device will come with a preinstalled Android operating system and you only need to install the (yet) unofficial AndroidAPS version that has built-in support for omnipy.

Android users unfortunately don't have much say when it comes to preinstalled software on their phones, but it is advised to not install any software other than AndroidAPS on your device. If you have the experience and possibility to root your device, it may prove beneficial to do it, if you can eliminate the possibility of your phone's OS to interfere with the operation of AndroidAPS software and the phone's general management of connectivity options / battery optimizations. Be aware there is a real danger that you may lose some hardware functionality, due to many custom roms providing some sort of compatible device drivers, but not the actual ones from the manufacturer. If you exactly know what you're doing, then please go ahead. Otherwise stay away from experimenting on a device which is going to host a critical application for your well-being.

Step 2: Install Raspbian on the Raspberry Pi

Download

Download the "Raspbian lite" operating system as a zip file from this link

Extract the image from the zip file and write to SD-Card

--- to be described ---

Modify the contents of the SD-Card for wireless networking

--- to be described ---

Step 3: Install omnipy on the Raspberry Pi

Find the IP address of your raspberry pi and connect to it

In the previous step you have configured your raspberry pi to connect to your wireless network. --- to be described ---

Install omnipy

Once at the command prompt, type the following to clone this repository to your pi:

cd
sudo apt install git -y
git clone https://github.com/winemug/omnipy.git

And then type the following to start installation:
bash omnipy/scripts/pi-setup.sh

Welcome to omnipy installation script
This script will aid you in configuring your raspberry pi to run omnipy

Press Enter to continue...

After you press Enter, the script will run through a set of steps for updating your system and installing necessary components. No user input is necessary for the first 7 steps and on a raspberry pi zero this will take about 15 minutes. Sample output below:

**Step 1/10: Updating package repositories**
Get:1 http://archive.raspberrypi.org/debian stretch InRelease [25.4 kB]
Get:2 http://raspbian.raspberrypi.org/raspbian stretch InRelease [15.0 kB]
Get:3 http://archive.raspberrypi.org/debian stretch/main armhf Packages [212 kB]     
---- more text ----

**Step 2/10: Upgrading existing packages**
Reading package lists... Done
Building dependency tree   
---- followed by a lot more text ----

**Step 3/10: Updating omnipy**
No local changes to save
Already up-to-date.

**Step 4/10: Installing dependencies**
Reading package lists... Done
Building dependency tree       
Reading state information... Done
---- followed by more text ----

**Step 5/10: Configuring and installing bluepy**
Cloning into 'bluepy'...
---- more and more text ----

**Step 6/10: Enabling bluetooth management for users**
---- some more text ----

Next step will require you to set-up a password for the HTTP API. The password is not stored on the raspberry pi, so it's not possible to retrieve it. You can however reset the password by running the setup script again.

Step 7/10: Omnipy HTTP API Password configuration
Enter new password (min. 8 characters): 
Repeat password: 
Password has been set.

The next step is for testing connection to your RileyLink as well as verifying firmware version, make sure you have the RileyLink turned on (blue / green lights flash upon start-up) before answering the question with Yes. Sample output:

Step 8/10: RileyLink test

This step will test if your RileyLink device is connectable and has the
correct firmware version installed.

Do you want to test the Rileylink now? (y/n) y

connecting to RL..
Connected. Verifying radio settings..
{'mac_address': '88:6b:0f:44:fc:1b', 'battery_level': 82}
All looks good.

Note: The battery level always reports 82, either a bug in my RileyLink or a bug in general.

In the next step, we will set up a Bluetooth Personal Area Network (PAN) in order to have the raspberry pi connect to the android device:

Step 9/10: Setting up bluetooth personal area network

Do you want to set up a bluetooth personal area network? (y/n) 

After answering the question with Y, you will get a similar output to the one below:

Removing existing bluetooth devices
hci0 Set Powered complete, settings: powered bondable ssp br/edr le secure-conn 

Activating bluetooth pairing mode
hci0 Set Connectable complete, settings: powered connectable bondable ssp br/edr le secure-conn 
hci0 Set Discoverable complete, settings: powered connectable discoverable bondable ssp br/edr le secure-conn 
hci0 Set Bondable complete, settings: powered connectable discoverable bondable ssp br/edr le secure-conn 
bt-agent: no process found
Agent registered
Default agent requested
Bluetooth device is now discoverable

Open bluetooth settings on your phone to search for and pair with this device
If you have already paired it on your phone, please unpair it first, then pair again

Waiting for connection..........

Now go to your android device, open Bluetooth Settings and make sure Bluetooth is turned on. In this document I will refer to my Samsung Galaxy S7 running Lineage OS. How the screens look, text reads is different across most Android devices but the concept is the same.

Enable Bluetooth

Choose "Pair new device" and wait for the Raspberry Pi to appear in the list. If you have not configured a custom host name for your raspberry, then it will be called "raspberrypi":

Pair new device

Click on the name of your raspberry pi and the pairing should complete within a couple of seconds. Once that's done, the setup script will display the relevant information such as:

Paired with Samsung Galaxy S7 (34:8A:7B:9C:F7:23).

Please enable bluetooth tethering on your phone if it's not already enabled
Waiting for connection.

Now you should open on your android device Connection Settings or Network Settings

Connection Settings

then click on Mobile Hotspot or Tethering in the settings and enable Bluetooth Tethering, e.g:

Bluetooth Tethering

After you have enabled bluetooth tethering on your phone, the raspberry pi will connect to your phone via bluetooth and setup will confirm this with an output similar to below:

**Connection test succeeeded. IP address: 192.168.44.162**

And the last step will set up the omnipy service, without requiring user interaction.

**Step 10/10: Creating and starting omnipy services**
Created symlink /etc/systemd/system/multi-user.target.wants/omnipy.service → /etc/systemd/system/omnipy.service.
Created symlink /etc/systemd/system/multi-user.target.wants/omnipy-beacon.service → /etc/systemd/system/omnipy-beacon.service.

**Setup completed.**

Omnipy is now installed and the service is running. Upon restart everything should start automatically including the bluetooth network connection. As a final step though, you should restart your raspberry pi to finish installation of some of the packages that were upgraded. Type in the following to restart your raspberry pi:

sudo reboot

Step 4: Install Android APS

----- to be described -----

Various Notes

Networking

There are many options to network these two devices. Here is some of them:

  • Bluetooth tethering on android device (preferred method)
  • Wireless hot-spot on the android device
  • Wireless AP on the raspberry pi
  • Wi-Fi direct
  • USB tethering