This shows you the differences between two versions of the page.
— | sdk:scripts:dio-monitor [2015/05/05 15:04] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== SDK Script dio-monitor.are ====== | ||
+ | <code c dio-monitor.are> | ||
+ | /* DESC: This script monitors the DIO ports and sends a SMS to the specified phone number. | ||
+ | * Copyright (C) 2012 NetModule AG, Switzerland | ||
+ | */ | ||
+ | |||
+ | void usage() | ||
+ | { | ||
+ | print(" | ||
+ | print(" | ||
+ | print(" | ||
+ | exit(1); | ||
+ | } | ||
+ | |||
+ | void sendsms(tel, | ||
+ | { | ||
+ | id = nb_sms_send(tel, | ||
+ | if (id) { | ||
+ | printf(" | ||
+ | } else { | ||
+ | print(" | ||
+ | } | ||
+ | } | ||
+ | |||
+ | if (argc != 3) { | ||
+ | usage(); | ||
+ | } | ||
+ | |||
+ | din = argv[1]; | ||
+ | tel = argv[2]; | ||
+ | |||
+ | in1 = nb_dio_get(" | ||
+ | in2 = nb_dio_get(" | ||
+ | |||
+ | while (1) { | ||
+ | if (left(din, | ||
+ | cin1 = nb_dio_get(" | ||
+ | if (cin1 != in1) { | ||
+ | msg = sprintf(" | ||
+ | sendsms(tel, | ||
+ | in1 = cin1; | ||
+ | } | ||
+ | } | ||
+ | if (left(din, | ||
+ | cin2 = nb_dio_get(" | ||
+ | if (cin2 != in2) { | ||
+ | msg = sprintf(" | ||
+ | sendsms(tel, | ||
+ | in2 = cin2; | ||
+ | } | ||
+ | } | ||
+ | sleep(3); | ||
+ | } | ||
+ | |||
+ | exit(0); | ||
+ | |||
+ | </ | ||