Share My Creation PanicPuck - A low-cost, subscription-free ‘panic button’

I had looked into panic buttons (small portable devices that send an SOS by SMS, for instance for elderly people who took a fall and need help) and they either seem to be rubbish, or come with a monthly or annual subscription service and thought: that should and could be done differently (and cheaper). It can be. It is.

The heart of the solution is the Puck.js (http://www.espruino.com/Puck.js), which is yours for about 30 GBP + shipping, in my case around 40 EUR. The solution itself consists of 2 components:
  • JavaScript code running on the Puck and (BLE) broadcasting either the Puck’s battery level (which also serves as a heartbeat) or a panic message, indicating that the user has clicked the Puck’s button a number of times (the number is set in the JavaScript code - all configurable values are set at the bottom of that code).
  • An Android app that listens to BLE broadcasts and sends an SMS (e.g., to a friend or relative) when a panic message is detected.
Attached to this post you will find both these components, and possibly some additional useful stuff that is part of the B4A project:
The bottom line:
If the user presses the Puck’s button ‘x’ times within the configured time interval, the Puck will start broadcasting a 'panic' message and all of its LEDs will start flashing, telling the user that now a panic message is being broadcast, and the app will pick this message up and then send an SMS to the configured phone number; the default text (which can be changed in the preferences) is "I have pressed the PANIC button, please call me and if I don't pick up, please call emergency services". Once the user presses the button an additional time, the panic message is no longer broadcast; instead, a battery level message is sent out.

Caveats:
- For some reason - I don’t know why and it might be a mistake of mine, but this does the trick for me and I don’t intend to publish the app on Google Play so it’s irrelevant to me - in the Manifest, leave targetSDKversion to 14; with 26, the BLE stuff doesn't work.
- When 'scanning' is enabled, the app will consume more battery power as it will then use a partial lock to ensure the CPU stays alive even when the device is on lock screen (there’s no point in having a panic button that doesn’t do that).
- The Puck’s JavaScript code in the example is set to only count 500ms presses to avoid false positives (you may want to read - a lot - on the Espruino site to see what I mean). In other words, the user must press the Puck's button for half a second, 'x' times, within the configured interval.

Quick start guide:
- Install the JavaScript code on the Puck; modify it so that the 'puckname' variable has a value you will recognise. Modify other configurable values too, if desired.
- Install the app on the phone.
- Set the preferences in the app (see menu).
- In the 'Scan' menu, enable 'Show all'.
- Check out the BLE broadcasting devices that are shown in the CustomListview now, and tap your Puck, so that it will be saved as 'the relevant one'.
- Start scanning and hope the app will never send you an SMS.

Enjoy!
 

Attachments

  • PanickPuck.zip
    67.4 KB · Views: 119
  • THIS RUNS ON PanicPuc.txt
    3.3 KB · Views: 125
Top