Tapping an iOS / iPad OS Device On The Shoulder

I know this is a long shot but…

As some of you know I’’m experimenting with sending “jobs” (parcels of work) to a BlueTooth-attached Raspberry Pi. This is via SSH.

I return data using Secure Shellfish.

The above components work:

  • Pi over Bluetooth
  • SSHing into the Pi
  • Retrieving data via Secure Shellfish

But what about notifying me - on the iPad - when the processing on the Pi has completed?

I’d be happy with a literal notification. I could use PushCut to tap on the notification - to kick off the retrieval, for example.

Here’s the long-shot exam question:

How can I create a notification on iPad OS from a Raspberry Pi - where the only networking available is the BlueTooth connection between the Pi and the iPad?

Use case is the usual one: 35,000 feet without airline WiFi.

I would assume the Pi can be taught the iPad’s Bonjour name.

I think the issue might be that off device generated notifications would need to connect in the process to an official Apple Push Notification server for the security requirements to be met. Connecting to the APN at 35k’ I think would be where you hit an issue.

Given the proximity, what about having the notification on the RPI? Adding a low power screen (hat) to display a message, an audible tone, or a flashing LED sequence off some LEDs connected up to some GPIO pins?

I rather thought that would be the case. Hence my “long shot’. But there are a couple of possibilities here…

  1. TCP/IP Sockets programming. (But I know of no Sockets client on iOS.)
  2. Casting this as a web service - or even just a simple web serving with “Get URL” on the Shortcuts side. I already have Apache/PHP on the Pi and could do Node or Nginx.

The latter seems more feasible - so long as the GET doesn’t time out. It probably won’t as each “microservice” is probably only a very few seconds long.

The choice of web server/server code would depend on how flexible it is in “on Pi” automation.

Option 1 I think is unlikely to be viable. Option 2 however should be.

I’ve been experimenting (at some point I’ll detail my full set-up notes I a blog post) over the holiday period with a Pi Zero W as a web hook provider using this:

Using this could potentially give you a step up on converting your work packages into “hook-able” pieces of work by just triggering the scripts you likely already have and returning the output.

1 Like

Thanks @sylumer.

So the idea of a webhook is that it would - using Pushcut - tap the iOS device on the shoulder.

I still think it would be simpler if used my Pi’s Apache/PHP server (which is up whenever the Pi is) to provide services - and compose from Shortcuts.

I can use the PHP exec() function to actually execute scripts on the Pi.

(If the GET times out it probably indicates the ‘service’ is too coarse grained. I’ve no idea how to set a timeout in the Shortcuts action, nor eg Scriptable or Drafts.)

This should be a fun project, actually. And maybe worth writing up in my blog - once I’ve completed migrating all 526 posts.

That isn’t what I was suggesting in this case as that would rely on connectivity to the Pushcut relay, which your particular scenario precludes.

Webhook listens for connections and as a result can trigger scripts and return output back to a request. You could trigger directly from Shortcuts to the RPI, and get information back, or notification that say a file was ready to be downloaded (Secure Shellfish is your friend :wink:).

It’s a prebuilt trigger mechanism and was just a suggestion of a way to quickly hook in a script/command to a web request without having to build one. Install and configure vs. coding.

If you already have a framework to quickly trigger the scripts and receive completion info from a web request, then you would not benefit from the above.

1 Like

Is the RPi nearby or far away?

If nearby… Would it be possible for the RPi to turn on an iBeacon that would then get detected by your iPad and thus trigger a PushCut notification?

If far away… Could the RPi email you after completing the job?

Greetings,
—Alexander

The Pi is nearby - either TCP/IP over Bluetooth or TCP/IP over WiFi on the same WiFi network.

(When the Pi is switched off I expect nothing of it; Likewise when I’m not on the same network.)

Experiment with Apache/PHP worked well - though I haven’t yet tested PHP’s exec() function.

From a previous discussion On Martin’s RPI where the use of iBeacons was discussed, the RPI is potentially on a small isolated network with no Internet access… on a plane (as noted at the top of this thread).

iBeacon had some potential, but also a number of challenges. It would also be rather slow to cycle for multiple packets of work.

Without Internet access, the RPI would need to host a mail service for the iPad to access and download mail from.

So, I’ve been playing with the concept of using Apache/PHP on the Pi as a provider of “services”. It works quite nicely. I will note - more for the benefit of anyone else trying this approach - two things:

  • The services (PHP code) are running with the web server’s userid.
  • You have to be careful with relative working directories.

I have some fix ups for my naive and not-so-naive code to do.

But the principle is working well enough in practice for me to think I’m going to do a write up at some point. (Shortly after I finish my blog migration project, I think.)

On Point 2 - if the PHP code detects workdir=blah is set in the URL’s query string (using isset($_GET['workdir']) my code now does a chdir() to that working directory.

(Yes, I’m evolving the thread I started - in the hope that anyone trying the ‘tame webserver’ can make progress quicker than I have.)