Differences

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

Link to this comparison view

sdk:voicetodigitalout [2024/08/22 10:27] – created fachetsdk:voicetodigitalout [2024/08/22 10:30] (current) fachet
Line 41: Line 41:
 } }
 /* not reached */ /* not reached */
-<code>+</code> 
 +===== SDK-Script ===== 
 +<code - voicetodigitalout.are > 
 +/* DESC: This script can be used to switch a digital out port by phone calls 
 + * 
 + * Copyright (C) 2024 NetModule AG, Switzerland (rfa) 
 + */ 
 +TELON = "+49...";  // call from this number switches ON 
 +TELOFF = "+49..";  // call from this number switches OFF 
 +  
 +nb_syslog("Alarm numbers ON: %s  OF: %s", TELON, TELOFF); 
 +while (true) { 
 +  msg = nb_voice_event(1).call.calling; // check event with 1sec timeout 
 +  if (!is_void(msg)) { 
 +    msg = left(msg, strlen(msg) - 5); // trim phone number 
 +    msg = right(msg, strlen(msg) - 6); 
 +    nb_syslog("called by %s", msg); 
 +    if (msg == TELON) { 
 + nb_syslog("Alarm ON"); 
 + nb_dio_set("out1", 1); 
 +    } else if (msg == TELOFF) { 
 + nb_syslog("Alarm OFF"); 
 + nb_dio_set("out1", 0); 
 +    } 
 +  } 
 +
 +/* not reached */ 
 +</code>