Difference between revisions of "Tether"

From Hackstrich
m
Line 67: Line 67:
 
=== I'm Still Here Packet ===
 
=== I'm Still Here Packet ===
 
* 1 bytes - H
 
* 1 bytes - H
 +
 +
=== Ack Packet ===
 +
* 1 bytes - A
  
 
== Sequence (WIP!) ==
 
== Sequence (WIP!) ==

Revision as of 16:47, 14 April 2018

I keep leaving my backpack behind and would like to stop doing that using technology (because I can't come up with a non-tech solution that works).

Project Status

  • 2018-04-13: Started writing a simulator to get the protocol details worked out ahead of having hardware. RX and TX units work so far, no base station support.
  • 2018-04-11: Bought a TrackR after a bunch of research, it doesn't work very well at all. Started putting together idea for something that will work better. Next steps are to finish figuring out the sequences, especially for when one or both portable units go into/out of base station range. Re-syncing time slots when just the RX unit leaves and comes back seems to be the hardest problem.

Functionality Desired

  • Unit that goes in backpack has long battery life, don't want to have to worry about charging it or replacing batteries often
    • This unit can be heavier as my backpack is always heavy
  • Unit that goes in other bag can require charging more often but needs to be smaller
  • Base station unit that the other units can detect and go into a low power mode when at home/work
  • Should be able to leave my backpack at home (and maybe at work) without any alarm going off, as I do this intentionally
  • Don't want to have to build too much custom hardware, going to try to build this around COTS stuff

Basic Overview

System Components

  • RX Unit - Carried in bag that never gets left behind
  • TX Unit - Carried in bag that sometimes gets left behind
  • Base Station - Installed at home and at work
    • Puts RX/TX into a power-saving mode when nearby
    • Keeps track of accurate time and gives time updates to nearby RX/TX units

Hardware

  • RX Unit
    • Adafruit Feather M0 with RFM95 LoRa Radio - 900MHz - RadioFruit
    • FeatherWing OLED - 128x32 OLED Add-on For All Feather Boards
    • Beeper of some kind
  • TX Unit
    • Adafruit Feather M0 with RFM95 LoRa Radio - 900MHz - RadioFruit
    • FeatherWing OLED - 128x32 OLED Add-on For All Feather Boards
  • Base Station
    • Adafruit Feather HUZZAH with ESP8266 WiFi
    • Adafruit LoRa Radio FeatherWing - RFM95W 900 MHz - RadioFruit
    • DS3231 Precision RTC FeatherWing
    • FeatherWing OLED - 128x32 OLED Add-on For All Feather Boards
    • FeatherWing Doubler (CPU and LoRa on one side, RTC and OLED on the other)

Concepts/Ideas

  • A time slot opens every BEACON_TIME-DRIFT_SAFETY seconds, lasts at least DRIFT_SAFETY/2 seconds or until a beacon is heard
  • Receiver normally synchronizes to transmitter, and listens for only a few seconds around when it expects the transmitter to send something.
  • When near a base station, everything synchronizes to the base station, listening for only a few seconds around when that sends
    • If contact with base station is lost, transmitter picks up again on the same schedule that was in use from the base station

Protocol

Variables

  • INIT_TIMEOUT=180
  • ACK_TIMEOUT=5
  • BEACON_TIME=60
  • BASE_REPORT_TIME=180
  • TIMESLOT_LENGTH=10
  • STILLHERE_MULTIPLE=5

Packet Formats

Beacon Packet

  • 1 byte - B
  • 1 byte - number of seconds until the next beacon will be sent
  • 1 byte - voltage on battery

Base Report Packet

  • 1 byte - R
  • 1 byte - number of seconds until the next base report will be sent
  • 1 byte - base identifier
  • 1 byte - current RTC hours
  • 1 byte - current RTC minutes
  • 1 byte - current RTC seconds

I'm Still Here Packet

  • 1 bytes - H

Ack Packet

  • 1 bytes - A

Sequence (WIP!)

RX Unit

State 'Init'

  1. Listen constantly until beacon or base report heard, (or until INIT_TIMEOUT expires at which point will shut down and alert that no TX found)
  2. Transmit an ACK back and go to sleep until BEACON_TIME-TIMESLOT_LENGTH/2
  3. Transition to state 'Listening'

State 'Listening'

  1. Wake back up, listen until next beacon or until timeslot closes.
    1. If beacon or base report heard, repeat from start of state
    2. If beacon or base report not heard before the timeout, alert the user and transition to state 'TXLost'

State 'TXLost'

  1. Go to sleep for BEACON_TIME*5
  2. Wake up, listen for BEACON_TIME+TIMESLOT_LENGTH for a beacon.
    1. If beacon or base report heard, transition back to state 'Listening'
    2. If beacon or base report not heard, repeat from start of state

TX Unit

State 'Init'

  1. Send beacon.
  2. Wait ACK_TIMEOUT seconds for an ACK to come back.
    1. If ACK received, transition to 'Beaconing' state
  3. Go to sleep for BEACON_TIME/3
  4. Repeat from start of state

State 'Beaconing'

  1. Go to sleep for BEACON_TIME-TIMESLOT_LENGTH/2.
  2. Wake up and listen for TIMESLOT_LENGTH/2 to see if a base station is around.
  3. Listen for beacon or base report
    1. If a base report is received, go to sleep for the received "Next Beacon In" time - TIMESLOT_LENGTH/2.
    2. If nothing received, send a beacon then wait ACK_TIMEOUT seconds for ACK to come back. Log if it doesn't, but don't change behaviour.

Base Station Powerup

  1. Listen until beacon heard from TX.
  2. Go to sleep until BEACON_TIME-DRIFT_SAFETY/2.
  3. Wake up and send a base report.
  4. Listen for DRIFT_SAFETY to see if we
  5. Go to sleep for BASE_REPRT_TIME-DRIFT_SAFETY/2.
  6. Repeat from step 3.