Differences

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

Link to this comparison view

Next revision Both sides next revision
sdk:scripts:voice-dispatcher-audio [2015/05/05 15:04]
127.0.0.1 external edit
sdk:scripts:voice-dispatcher-audio [2020/03/18 09:47]
fachet
Line 2: Line 2:
 <code c voice-dispatcher-audio.are>​ <code c voice-dispatcher-audio.are>​
 /* DESC: This script implements an audio voice dispatcher /* DESC: This script implements an audio voice dispatcher
 + * The first audio Interface (line-in/​out) is used for the GSM-Call audio.
 + * - Dialing os controlled via digital in 1 (in1)
 + ​* ​  If it is set high (1), the predefined nummer is called. ​
 + ​* ​  Must be set to high (1) to acknowledge incomming calls.
 + ​* ​  Any call will be terminated when it goes low (0).
 + * - Incomming calls are signaled at digital out 1 (out1). ​
 + ​* ​  ​It'​s set to high (1) when call is incomming and statys high during call.
 + ​* ​  It will go to low (0) when the call is ended.
 + *
  * Copyright (C) 2012 NetModule AG, Switzerland  * Copyright (C) 2012 NetModule AG, Switzerland
 + ​* ​
  */  */
  
-INTERVAL = 3;           /​* ​seconds */+INTERVAL = 1;           /​* ​polling status change every x seconds */
 NUMBER = "​+123456789"; ​ /* number to call when DI1 = on */ NUMBER = "​+123456789"; ​ /* number to call when DI1 = on */
  
Line 83: Line 93:
                     nb_syslog("​unable to initate call to %s", NUMBER);                     nb_syslog("​unable to initate call to %s", NUMBER);
                 }                 }
 +              nb_dio_set("​out2",​ 1); /* call is active */
             } else {             } else {
                 nb_syslog("​not calling %s as endpoint %s is not available",​ NUMBER, audesc);                 nb_syslog("​not calling %s as endpoint %s is not available",​ NUMBER, audesc);
Line 99: Line 110:
                 }                 }
             }             }
 +            nb_dio_set("​out2",​ 0); /* no active call */
         }         }
  
Line 132: Line 144:
                 if (nb_voice_call_route(call,​ audesc) == 0) {                 if (nb_voice_call_route(call,​ audesc) == 0) {
                     nb_syslog("​routing call %d to %s", id, audesc);                     nb_syslog("​routing call %d to %s", id, audesc);
 +                    nb_dio_set("​out2",​ 1); /* ring, incomming call */
                 } else {                 } else {
                     nb_syslog("​unable to route call %d to %s", id, audesc);                     nb_syslog("​unable to route call %d to %s", id, audesc);
                     nb_voice_call_hangup(call);​                     nb_voice_call_hangup(call);​
 +                    nb_dio_set("​out2",​ 0); /* error, no active call */
                 }                 }
                 break;                 break;
Line 146: Line 160:
                     if (austate == "​available"​) {                     if (austate == "​available"​) {
                         nb_syslog("​hanging up call %d as audio is busy", id);                         nb_syslog("​hanging up call %d as audio is busy", id);
-                        nb_voice_call_hangup(call);​ 
                     } else {                     } else {
                         /* wait until IN1 has been closed */                         /* wait until IN1 has been closed */
Line 157: Line 170:
                                 if (nb_voice_call_accept(call) == 0) {                                 if (nb_voice_call_accept(call) == 0) {
                                     nb_syslog("​accepted call %d", id);                                     nb_syslog("​accepted call %d", id);
- +                                    ​/* nb_voice_call_volume(call,​ 7); increase volume level to max */ 
-                                    if (1) { +                                    return; ​/* call established */
-                                        ​/* increase volume level */ +
-                                        ​nb_voice_call_volume(call,​ 7); +
-                                    } +
- +
-                                    return;+
                                 } else {                                 } else {
                                     nb_syslog("​unable to accept call %d", id);                                     nb_syslog("​unable to accept call %d", id);
Line 175: Line 183:
                     nb_syslog("​hanging up call %d", id);                     nb_syslog("​hanging up call %d", id);
                     nb_voice_call_hangup(call);​                     nb_voice_call_hangup(call);​
 +                    nb_dio_set("​out2",​ 0); /* error, no active call */
                 }                 }
                 break;                 break;
Line 200: Line 209:
  
 d = new dispatcher();​ d = new dispatcher();​
 +nb_dio_set("​out1",​ 0); /* clear signaling */
 dump(d); dump(d);
 d.run(); d.run();