Whereabouts Software, Part 1 - MySQL DB

The Whereabouts code is comprised of three parts: the webserver code that fetches the data from the iPhones, the database that stores the information, and the Arduino that represents the server data in physical form in the clock.

This post is on the MySQL database that hosts the location data.  I've attached a SQL file that can be loaded into an empty database.  Some tweaking will need to be done for your specific environment which I will detail below.

whereabouts.sql

The 'clock_location' table is a key/value pair table that represents the physical locations on the clock.  The names in the 'name' field are important and must match exactly (case-sensitive) the values that will be used in the Arduino code for clock locations.  The twelve locations provided are the ones I used but may be modified as needed.

The history table is an empty table that will be populated each time the location fetching code is run.  This will be purged after 30 days by the same code.

The location table is a mapping of location coordinates to common names, IDs, clock locations, and users.  This will need to be populated with your own data before use.  Here's how it should be populated:

  • id - autoincrement table primary key
  • clock_location_id - the ID for the clock position.  What location should be pointed at by this location?
  • name - a user-friendly name for this location.  This is only used by humans, so go nuts.
  • latitude/longitude - the lat/long coordinates for this location
  • user_id - the ID of the user that this location is valid for.  A given location might not be the same for all family members!

The user table maps the users to how location data is fetched.  Here's how it should be populated:

  • id - autoincrement table primary key
  • username - A human-readable name for this user.  This will be used in the fetch_current.php script and the Arduino code.  Make sure that this matches in the Arduino code!
  • location_source - this should be 'GPS' for those with iPhones.  To override a location and 'force' a user to be represented at a given location, put 'clock_<clock_location.id>' in this field.  To have a user use the same location as another user (useful for children) put 'user_<user.id>' in this field.
  • apple_id - When using more than one phone on "Find My iPhone" you will need to get the ID of the device and put it here.
  • hand_id - This was supposed to add more flexibility to the Arduino code, but for now it's not used.

Comments

Popular posts from this blog

V-22 Osprey Project - Flight Control

V-22 Osprey Project - Design Changes for v3

V-22 Osprey Project - Tuning and Setup