Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
sdk:alarm-via-voice [2017/04/19 12:05]
juraschek
sdk:alarm-via-voice [2022/01/26 15:57] (current)
schmitt
Line 3: Line 3:
  
 The Script will try to reach a phonenumber for a certain time, also retries after a specific time and give up after  a defined timeout. ​ The Script will try to reach a phonenumber for a certain time, also retries after a specific time and give up after  a defined timeout. ​
 +
 +We will see the alarm as received if the Call was picked up. To be sure that a person picked up we only accept calls that last less then 10 seconds. This way we avoid false positives if a answering machine, a voice mail or a pbx will pickup the phone call.
  
 For this example we will work with die DIGITAL INPUT as an alarm. But you can trigger this script on many events. ​ For this example we will work with die DIGITAL INPUT as an alarm. But you can trigger this script on many events. ​
  
 ===== Requirements ===== ===== Requirements =====
-  * NB1600, NB2700, NB3700 with a voice featured modem+  * NB1601, NB800 (Rev B.), NB1600, NB2700, NB3700 with a voice featured modem
   * Voice-License installed   * Voice-License installed
   * A SIM card with phonecalls enabled (some data-SIMs will not work)   * A SIM card with phonecalls enabled (some data-SIMs will not work)
-  ​* NBSW [[ftp://​share.netmodule.com/​router/​public/​system-software/​4.0/​4.0.0.105/​|4.0.0.105]] or higher+  ​
  
  
Line 17: Line 19:
 If there is  not availability or a positive licensing status please contact our [[http://​netmodule.com/​products/​support/​support_request.html| support team]]. In the most cases this is a configuration issue. If there is  not availability or a positive licensing status please contact our [[http://​netmodule.com/​products/​support/​support_request.html| support team]]. In the most cases this is a configuration issue.
  
-{{ :sdk:screenshot_-_160916_-_16_18_33.png?​nolink&​600 |}}+{{ :sdk:bild2.png?​nolink&​600 |}}
  
 Please also make sure your sim card is succefully registered in the mobile network Please also make sure your sim card is succefully registered in the mobile network
  
-{{ :sdk:screenshot_-_160916_-_16_16_15.png?​nolink&​600 |}}+{{ :sdk:alarm_via_voice_wwansignal.png?​nolink&​600 |}}
  
 ===== Configuration ===== ===== Configuration =====
Line 33: Line 35:
 Enable the Administrative Status and set the Call Routing to SDK Enable the Administrative Status and set the Call Routing to SDK
  
-{{ :sdk:screenshot_-_160916_-_16_16_43.png?​nolink&​600 |}}+{{ :sdk:BILD1.png?​nolink&​600 |}}
  
 Add two Endpoint Voice-over-Mobile and Nil-Device Add two Endpoint Voice-over-Mobile and Nil-Device
  
-{{ :sdk:screenshot_-_160916_-_16_45_09.png?​nolink&​600 |}} +{{ :sdk:bild3.png?​nolink&​600 |}} 
-{{ :sdk:screenshot_-_160916_-_16_44_54.png?​nolink&​600 |}}+{{ :sdk:bild4.png?​nolink&​600 |}}
  
  
Line 53: Line 55:
   * Job: combine the script phone-alarm and the trigger din1-on to a job.   * Job: combine the script phone-alarm and the trigger din1-on to a job.
  
-{{ :sdk:screenshot_-_160916_-_16_34_51.png?nolink |}} + 
-{{ :sdk:screenshot_-_160916_-_16_35_03.png?nolink |}} +{{ :sdk:bild5.png?nolink |}} 
-{{ :sdk:screenshot_-_160916_-_17_11_00.png?nolink |}}+ 
 + 
 +{{ :sdk:bild8.png?nolink |}} 
 + 
 +{{ :sdk:bild9.png?nolink |}}
  
  
Line 98: Line 104:
 // How many times should we try to calll; // How many times should we try to calll;
 retries=5;//​ retries=5;//​
 +
 +//maximum time in seconds a call can be connected before we assume it's picked up by a machine
 +maxConnectTime=10;​
 +
  
  
  
 //Enable Debug Messages; //Enable Debug Messages;
-DEBUG=false;+DEBUG=true;
 void debug(string msg) { void debug(string msg) {
     if(DEBUG) {     if(DEBUG) {
Line 142: Line 152:
  
  
-    ​+    ​connectStart=0;​
     callOngoing=true;​     callOngoing=true;​
     while(callOngoing) {     while(callOngoing) {
Line 168: Line 178:
                     break;                     break;
                 case "​connected":​                 case "​connected":​
-                    debug("​handle connected: ​hangup"); +                    debug("​handle connected:"​);​ 
-                    nb_syslog("​Call with %s was answered. ​Alarm was succesfull",​phoneNo);​ +                    nb_syslog("​Call with %s was answered. ​Let's check if we have voicemail answering (max 10sec call)",​phoneNo);​ 
-                    ​sleep(2); +                    ​if (connectStart==0) connectStart=jiffy();         
-                    nb_syslog("​We will terminated the call"​);​ +                    ​ 
-                    nb_voice_call_hangup(event.call.id);​ +                     if (connectStart>​0 && jiffy()-maxConnectTime>​connectStart) { 
-                    exit(0);+                            ​nb_syslog("​We will terminated the call, call was anserwered by a machine, call was connected longer then 10 sec."); 
 +                            ​nb_syslog("​We will retry the call"​);​ 
 +                            ​nb_voice_call_hangup(event.call.id);​ 
 +                            ​connecStart=0; 
 +                        }
                     break;                     break;
                 case "​hungup":​                 case "​hungup":​
 +                    if (connectStart!=0) {
 +                        if (jiffy()-maxConnectTime<​connectStart) {
 +                        nb_syslog("​Call was ended before timeout we assume someone answered the call manually"​);​
 +                        nb_voice_call_hangup(event.call.id);​
 +                        connectStart=0;​
 +                        exit(0);
 +                        }
 +                    }
                     break;                     break;
                 default:                 default:
Line 200: Line 222:
 nb_syslog("​Alarm was not successfull after %i seconds",​jiffy()-startTime);​ nb_syslog("​Alarm was not successfull after %i seconds",​jiffy()-startTime);​
 exit(0); exit(0);
- 
  
 </​code>​ </​code>​