DC Metro API – Show Real-Time Train Arrivals with Javascript

I’ve worked with Twitter, Instagram and Facebook APIs. Those are always a bundle of unpredictable joy/not, as APIs usually are. The WMATA (DC Metro) API is fairly easy to work with by comparison. They don’t have to worry about anyone’s personally identifiable information (PII), hence, less headaches for developers. They provide an adequate level of documentation and are reasonably responsive over email. All issues I had while working with this code were easy enough to resolve, using the ol’ Googley machine and common sense. A business lead I worked with was extra enthusiastic about the project, so he did email the API developers a few times and they responded on the same day.

The rate limit is 10 calls/second and 50,000 calls per day, which should work just fine for most uses. I’d pay extra attention here if you have multiple versions of the code during development (using the live end point) or, if you have a live version out and are working on changes, while using the live API (which is sometimes unavoidable, since there’s no dev end point).

In general, if you call it 3 times a minute or every 20 seconds, as the WMATA’s own real time arrivals web app does, you’ll be more than ok. Here’s a screenshot:

You can see their list of real time arrival stations here. It works rather well and uses their Real-Time Rail Predictions API, but one thing I’d certainly do differently – it’s literally reloading the whole page every 20 seconds to update the data. I’m guessing a backend developer put this together real quick, while working under several deadlines. A simple AJAX call can fix this (there are multitudes of examples of this on StackOverflow alone).

Note: if their app/API feed is down, their real time arrivals link just shows a mostly blank page:

Again, I’m guessing this was done in a hurry.

Retrieve Your cordova app’s localStorage Data Directly From iOS Device

Use Case

If WiFi fails, your ajax call fails and your backup re-submit code fails, you may need a last ditch solution of physically grabbing your form data from inside your PhoneGap app, off of an individual iOS device.


Make sure the app is coded to save data locally using HTML5 localStorage API.

Once the localStorage functionality is tested and working, and you have your PhoneGamp / cordova app running on an iPad, you can use PhoneView to access the file system on your the iPad.

Install DB Browser for SQLite on your Mac. Under the hood, cordova saves your localStorage data as a simple SQLite database.

Retrieve the Data

  1. Connect your device to your Mac and open PhoneView Demo
  2. Go to Apps in the main nav on the left.
  3. Click on Settings in the top nav icons bar and you’ll see this dialog window:
  4. Check the “Show Entire Disk in Disk Mode” and “Show All Apps in Apps Mode (Developers Only)” boxes. You’ll get a warning confirmation popup, which you should accept by clicking OK.
  5. You’ll now see your custom cordova app listed under Apps:

  6. The folders you want is yourApp/Library/Caches/ and yourApp/Documents/Backups/. The file should be called something like “file__0.localstorage” in /Library/Caches or “localstorage.appdata.db” in /Documents/Backups. It’s essentially a SQLite file, and can be opened using an app that lets you view SQLite files.
  7. To open it, you need to first copy the Library folder to your Mac.
  8. Click the Library folder to to select it
  9. Click on Copy from iPhone button in the top icons navbar
  10. Choose a location to save it on your machine.
  11. Launch DB Browser for SQLite
  12. Open your recently copied “file__0.localstorage” or “localstorage.appdata.db” files from your Mac in DB Browser for SQLite
  13. Click on the Browse Data tab towards the top of the interface
  14. You should see your localStorage Key / Value pairs listed as a SQL table:
  15. If you stored your Values as Arrays, your actual data may be stored as a BLOB data type and not plain text
  16. Select your BLOB value in the table and look at the right side of the interface, under Edit Database Cell
  17. Make sure the Mode is set to “Binary”
  18. You should be able to see your data with very bad kerning
  19. Click the “Export” button above the cell content area
  20. Save your file as .txt and open the .txt in any text editor, like SublimeText, to access your data as plain text.

Meraki MDM and iOS 10.0.2 – “App Already Scheduled For Management” and “Unable to install right now” Error Messages

The Symptoms

The issues this time were very similar, almost identical to what I’ve written about here. Meraki’s individual device page Activity Logs would show us the following error over and over again: “App… Already Scheduled For Management”. On the remote end, in a different city, an on-site event lead would be trying to install and getting the vague “Unable to install right now” popup message repeatedly.

The Workaround

We’ve tried everything from uninstalling all provisioning profiles from our iPads (via Settings > General > Profiles) to sending uninstall/reinstall signals from the Meraki dashboard, both from the individual device page and from the individual app page.

We eventually worked past our “Unable to install right now” message but then got stuck with grey stub icons for our apps that said “Waiting…” under the grey image.

Nothing worked until we did a full factory reset of each iPad, re-set up our Apple ID via the Settings app, re-downloaded the free Meraki app, re-registered with Meraki using our network ID.

Good times were had by all. Dinner was eventually served. Experiential / Live Events marketing + wireless technology = be prepared to have your tech guys on standby.

Meraki MDM and iOS 9.3.1 – “App Already Scheduled For Management” Error Message

We kept getting this message on two out of five iPads recently, first with iOS 9.2.1. We updated to 9.3.1, same issue. We’ve had this “App Already Scheduled For Management” message come up in the Event Log and Activity Log in the dashboard, on each individual device page.

There were some unique symptoms this time around:

  1. The app would get prompted for an Install, we’d tap that Trust/Install button
  2. Immediately after, iOS would prompt us for an App Store / iTunes login
  3. We’d cancel, as we’ve done lots of times in the past
  4. our MDM app published for enterprise distribution would start installation and quick shortly after, giving a generic “unable to install right now” message.

Note – I was working with a buddy who was located remotely, so I had to rely on them telling me what their screen looks like and what the messages are, etc. I didn’t have the privilege of looking at the device as I’m trying to “Re-push to all”, “Re-push to missing” from the Systems Manager app page or “Update” or “Install” from each registered device’s page.

Usually, clicking “cancel” on the iTunes / App Store login works just fine.

This time, it turns out the remotely located buddy / their teammate started creating the iTunes / App Store account but didn’t finish. So, they created the user name and login but didn’t click through all of the “Agree” type fine print pages in the sign up process. As a result, I’m guessing iOS disabled the ability to install ANY and ALL apps, until this unfinished iTunes process was completed.

Sure enough, after the remotely located employee re-logged into iTunes/App Store and finished that sign up process, our enterprise MDM app managed via Meraki’s Systems Manager installed within a few minutes, after I re-pushed it.

Up and Running with NW.js on OS X

Formerly known as node-webkit, NW.js lets you convert pretty much any HTML5 project into a desktop app.

First, make sure you have the right versions of npm and node installed. I updated npm and ended up updating node via nvm to maintain various versions of node and getting the right one for NW.js.

To launch the test app, I ran this command via Terminal:

open -n -a nwjs --args "/Users/your_usr_name/path_to_project/html_nwjs_test"

There’re a few other options on the project’s Github page. Do check it out.

If your package.json has a “window” node that looks like what I have below (aka no window chrome, no taskbar functionality), keep in mind that on OS X you can just launch Activity Monitor and use that utility to shut your app down when you’re ready:

  "name": "HTML5 Desktop Test App",
  "main": "index.html",
  "window": {
    "title": "HTML5 Screensaver Test",
    "frame": false,
    "toolbar": false,
    "fullscreen": true,
    "always-on-top": true,
    "show_in_taskbar": false

I’m sure Windows Task Manager or Windows Explorer has a similar option.

When the app’s ready, nw-builder seems like a good option to create executables for multiple platforms (win32, win64, osx32, osx64, linux, etc). It seems a bit annoying that for Windows, nw-builder outputs a bunch of .dll files along with the .exe.

Notes on Cisco’s Meraki Systems Manager as an MDM Solution

A few of the devs on my team recently got a chance to try out the free version of Meraki’s Systems Manager. In this case, I’m using MDM as an acronym for Mobile Device Management. We used the system on and off for most of 2015 to distribute some apps published using an enterprise provisioning profile for iOS.

Use cases

Our usual scenario involved a series of iPads, often 10 – 30 of them. They would be sent out to an event space on a convention floor, a mall booth, an outdoor event space (like Six Flags). Sometimes the devices would be used for user registration, running on a local network inside a stadium. One project involved a bunch set up outside a traveling food truck, that drove from town to town. A few projects required sweeps registration or mailing list sign up of some sort. One large project involved multiple Elo Touch Screens that ran Windows Pro and traveled between mostly outdoor events. Since most of our events involved using Meraki with a series of iPads, I’ll use the .ipa app upload process as the example going forward.

Overall impression

Overall, if your app is under 30MB in file size, Meraki is a great solution. Just set up your account, go to

  • Systems Manager > MDM > Apps
  • select “Add New” in the upper right corner of the page and “iOS enterprise app” from the dropdown.
  • Under Location, choose “Upload an ipa” from the dropdown and follow the given options, as needed. Click Save Changes and you’re set.
  • Add devices (Systems manager > MDM > add devices) and use tags to automatically install your app on the appropriate device
  • Once the app’s live and installed, you can update using the same App page (Systems Manager > MDM > Apps, click your app name)

Some issues we came up against

  • The Meraki dashboard doesn’t seem to allow you to search “Clients” (Systems manager > Monitor > Clients, what the system calls the devices you’ve registered) by convenient terms like serial number or device name. Sometimes I have a lot of devices with a given tag and I need to make sure a specific device is in that list. Being able to search by device serial number would save me time.
  • Enterprise apps larger than 30MB in size are often problematic to update. It often took multiple attempts over a few days to get the update to work, even after on-site connectivity was good for other purposes, such as playing back a streaming video off of sites like CNN.com.
  • On-site firewall at YMCA branches (using YMCA WiFi) were blocking remote app updates.
  • Spotty venue WiFi (read: convention floor WiFi) and sometimes spotty MiFi connections are an issue if your app requires an update or needs to send more than just text data. App updates for apps bigger than a few MB, required taking the device to another location with strong, consistent WiFi.
  • When you’re stuck on an issue, such as an app just won’t install, no matter what you do, there’s not much google-able info out there. Stackoverflow is very helpful to keep you moving, past bugs and roadblocks, but not with the free version of Meraki’s System’s Manager. We haven’t yet had the need to contact Meraki support (given our previous experience with trying to reach out to support with free products, we pursued the issues on our own, so far successfully).

Some conclusions

I’d highly recommend Meraki for smaller sized apps, especially ones that are not likely to require an app update during your short term event’s duration. For longer term installations, larger apps, be prepared to budget for and plan for on-site travel for one of your developers, technologists or IT guys to help with initial installs or especially problematic app updates.

This has less to do with MDM, and more with network connectivity, but your MDM will largely depend on how good your connection is. Seriously consider / advise your client to purchase a data plan for the device, rather than relying on WiFi alone. Find out ahead of time, which mobile service has a reputation for working best in your target location. Don’t use Verizon, if AT&T is generally known to have better service in your event’s target area. If your devices are PCs, by all means, run hard lines (Ethernet) and bypass wireless issues all together. Just keep in mind, the longer those Ethernet cables, the lower the signal tends to be.

Note to Self: Hooking Up an Arduino Uno to WiFi So It Can Text Me

What I’m working with

I have an Arduino Uno R3 with a bunch of sensors, LEDs, a small breadboard, various jumper wires, a multimeter.

Goal: detect with sensor, send me a text

I want to build a prototype that can read sensor data and notify me via text message (SMS) or Email when certain conditions are true. For example, I just created a quick human motion detector alarm using this tutorial, with slight modifications because my piezo buzzer is different:

Roadblock: No built-in WiFi with an Uno

My Arduino Uno R3 was great to get started with. It’s simpler than a Leonardo or a Yun. The Yun has built-in WiFi and a built-in mini Linux server. An RFDuino is smaller and has built-in WiFi. I wanted to start with the simple stuff first. Now that I’ve worked my way up to building more complex prototypes, internet connectivity is a must.

Other Option: Uno + Laptop + WiFi = Interwebs

There are ways to have an Uno send a text or email by keeping it hooked up to a laptop or PC that’s running a python script that talks to a web service or your local web server. I can also use BreakoutJS or NodeJS library like Johny-Five in a similar fashion, where the Uno has to be connected to my laptop so it can have internet connectivity. I want my toys to be free-standing, independent of a laptop, so, it looks like I’ll need to get a WiFi Shield or a WiFi breakout board.

WiFi Options for Uno

So far, Adafruit’s CC3000 looks like the best option for laptop-free Arduino Uno WiFi solution. It claims to be faster than other WiFi shields / boards because it’s not using UART. I need to look into this further.

I’ll need to order CC3000 WiFi Shield from Adafruit and sign up for a web service provider that lets me call their API, something like Amazon Web Services (SNS service), Twillio, TelAPI, TextBelt. The AWS account allows up to 100 free texts/mo and small fee if you go over. TextBelt is free but describes itself as “fairly reliable”.

CC3000 Shield v. the CC3000 Breakout Board



  • breakout board, you have to solder it but if I switch to an Arduino Mini tomorrow, it will still work since it connects to a breadboard and not the board directly

With CC3000 there’s the initial one-time cost of buying a few soldering tools. I guess, in that sense an official Arduino WiFi Shield won’t require soldering, even though it costs a bit more than double. I need to see if that UART speed issue is a factor.

Future iterations

There’s a cool tutorial from Open Home Automation to set up a motion detecting HUB with two micro controllers, one (or more) for the sensor and the other as the central hub.

This is a work-in-progress. To be continued…

Trying Out Arduino Analog Dial, Servo and Multimeter

Playing with MakeyMakey and Phillips Hue API

It’s useless #prototyping Friday. Used my #makeymakey , w/ spacebar clip hooked up to a paint can, with chicken scratch Javascript code w/ a keydown() event handler that listens for keyCode=32 (spacebar) and sends an ajax PUT request to the #hueapi #phillipshue which turns light 1 along with an html body tag background-color prop to red.