Sebastian Bub avatar Sebastian Bub committed 76a6790

added a sample for boxcar.io for notifications to a smart phone

Comments (0)

Files changed (3)

 
 The following configuration is given:
 
-You have a script which send notifications (i.e. email or sms or iPhone push notifications):
+You have a script which sends notifications (you can use the sample script which is located in `src/main/resources/script/sample.boxcar.io.cmd.sh` for iPhone push notifications or Android notifications based on [boxcar.io](http://boxcar.io) (configuration is done in `cmd.conf` for scripts):
 
 ```
+EXTCMD.NO=1
+
 EXTCMD.NAME.1=notify
-EXTCMD.COMMANDNAME.1=/path/to/my/script.sh
-EXTCMD.TIMEOUT.1=5000
+EXTCMD.COMMANDNAME.1=/xxx/src/main/resources/script/sample.boxcar.io.cmd.sh
+EXTCMD.TIMEOUT.1=2000
 ```
 
 * You have a GPIO input port which is connected to a door-is-open-sensor named `doorIsOpenIN`.

cmd.conf.MAY_BE_CHANGED

 
 # you may define multiple commands, just count up the suffix (starting with 1) and specify the maximum 
 # (0 means nothing is read)
+# do not forget to remove the comments below!
 EXTCMD.NO=0
 
 # a name to address, e.g. the name 'date' must be addressed like CMDdate
-#EXTCMD.NAME.1=date
+#EXTCMD.NAME.1=sample
 # define a full qualified path and name to call the command
-#EXTCMD.COMMANDNAME.1=/usr/bin/date
+#EXTCMD.COMMANDNAME.1=/xx/yyy/sample.sh
 # timeout in milliseconds
 #EXTCMD.TIMEOUT.1=200
 
 
-#EXTCMD.NAME.2=sample
-#EXTCMD.COMMANDNAME.2=/xxx/sample.sh
+#EXTCMD.NAME.2=notify
+#EXTCMD.COMMANDNAME.2=/home/pi/raspberry-pi-gpio-web-control/src/main/resources/script/sample.boxcar.io.cmd.sh
 #EXTCMD.TIMEOUT.2=2000
 
 

src/main/resources/script/sample.boxcar.io.cmd.sh

+#!/bin/bash
+
+# Copyright 2012 der-bub.de
+# http://www.der-bub.de
+# Author: Sebastian Bub (sebastian@der-bub.de)
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+# This script is an example on how to send notifications to iPhone and Android smartphones.
+#
+# It is based on a service call http://boxcar.io
+#
+# Before you go on there, please install cURL first with the command
+#             sudo apt-get install curl
+#
+# In order to use the script, simply "Join" on their website and use the bottom navigation
+# to create your own Provider (click "Provider API). After creating they show an example URL,
+# and your API key (NOT the API secret). The API key must be set below and your email address
+# you have used for joining boxcar.io.
+#
+# Install their App on your device and allow notifications.
+
+
+# the key is provided by boxcar.io after you have created your provider (NOT the API secret)
+API_KEY=xxx
+
+# same email address you have used for joining boxcar.io
+EMAIL_ADRESS=xxx@xxx.xxx
+
+
+# set headline and message depending on the parameter you give to the script
+case $1 in
+1)
+	HEADLINE="Notification 1"
+	MSG="A notification msg 1"
+	;;
+2)
+	HEADLINE="other Notification 2"
+	MSG="An other notification msg 2"
+	;;
+*)
+	# default headline and message
+	HEADLINE="Raspberry"
+	MSG="A message from Raspberry Pi GPIO Web Control"
+esac
+
+###############################
+
+# curl executable
+CURL_EXE=/usr/bin/curl
+# maximum time for the request
+MAX_TIME=2
+
+
+
+$CURL_EXE -d "email=$EMAIL_ADRESS"                  \
+     -d "&notification[from_screen_name]=$HEADLINE" \
+     -d "&notification[message]=$MSG"               \
+     -m $MAX_TIME -f                                \
+     http://boxcar.io/devices/providers/$API_KEY/notifications > /dev/null 2>&1
+
+exit $?
+
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.