Disallow 2 line to pass inbound ringing at the same time - asterisk

I trying to use ooma with asterisk for my home setup, so I have 2 lines assigned to the same number forwarded through FXO gateways into asterisk. Outbound calls seem to work fine, but on inbound I have issue - both lines ring at the same time so on my IP phone I see multiple inbound calls from the same number. What is the simplest way to make that 2 incoming look like 1 call?
I tried to use DEVICE_STATE() function:
[from-ooma1]
exten => s, 1, GotoIf($["${DEVICE_STATE(SIP/ooma2)}"="RINGING"]?hang)
same => n, Goto(incoming,s,1)
same => n(hang),Hangup()
[from-ooma2]
exten => s, 1, GotoIf($["${DEVICE_STATE(SIP/ooma1)}"="RINGING"]?hang)
same => n, Goto(incoming,s,1)
same => n(hang),Hangup()
so on ring on one line if another one is already ringing to drop it. Unfortunately this does not work, as DEVICE_STATE has only 2 states NOT_INUSE and INUSE (or I do not know how to make it to report RINGING state), and I cannot drop on "IN_USE" state.
Note: my subject maybe misleading, to clarify - I need to prevent two lines ringing at the same time, but when first line answered and still in use, second one should allows to pass incoming call.

You can count calls to any single entity by using function GROUP
[macro-stdvoip]
; ${ARG1} - full dial string
; Return ${DIALSTATUS} = CHANUNAVAIL if ${VOIPMAX} exceeded
exten => s,1,Set(GROUP()=trunkgroup1) ;Set Group
exten => s,2,GotoIf($[${GROUP_COUNT(trunkgroup1)} > ${VOIPMAX}]?103) ;Exceeded?
exten => s,3,Dial(${ARG1}) ;dial it
exten => s,103,SetVar(DIALSTATUS=CHANUNAVAIL) ;deny call
https://www.voip-info.org/wiki/view/Asterisk+func+group

Just in case somebody needs similar solution here is what works for me:
[from-ooma]
exten => 1,1,Set(CALLERID(number)=O:9${CALLERID(number)})
same => n,Set(GROUP()=ooma)
same => n,GotoIf($[${GROUP_COUNT(ooma)}>${GROUP_COUNT(ooma-answer)} + 1]?hang)
same => n,Goto(incoming,s,1)
same => n(hang),Hangup()
[macro-resetG]
exten => s,1,Set(GROUP()=${IF($[ "${ARG1:0:8}" = "SIP/ooma" ]?ooma-answer)})
same => n,MacroExit
[incoming]
exten => s,1,Verbose(1,Caller ${CALLERID(all)} incoming call)
same => n,Dial(SIP/1&SIP/2,20,TtM(resetG^${CHANNEL}))
same => n,Hangup()
so I use another group to count how many calls from ooma is answered (condition in macro is used because there could be other incoming calls)

Related

Reduce the time lapse when using goto

When using the Goto command I realize that I have a time lapse of about 5 seconds before the next extension is reached. Is there a way to reduce it?
[test]
...
exten => 1001,3,Background(chooseOption)
exten => 1001,4,WaitExten(3)
exten => 1,1,Goto(francais,s,1)
exten => 2,1,Goto(english,s,1)
exten => i,1,Goto(test,1001,3)
exten => t,1,Goto(test,1001,3)
[francais]
exten => s,1,Background(IVR2)
5 seconds are in between the time the caller presses 1 and the time IVR2 starts.
There is no timelapse in goto.
You have other issue. In your context you have 1-digit and 4 digits extensions(mixed). So it wait for (possible) input to match 4 digit.
For fast reaction you should create other context which have only 1 digit ext and do goto that context, after that use Background. So will be only 1 digits answer and it will NOT wait.
Or you can use application Read which support length of input.

Calling same plsql Procedure more than once in a package parallely

Have one plsql package "OMX_BEACON_MIG" where am calling
PROCEDURE handle_NR_Site(
i_old_plan_inst_id NUMBER,
i_new_plan_inst_id NUMBER,
i_old_act_id NUMBER,
i_new_act_id NUMBER )
To process action ids i.e., if i have 4 action id's then i am calling this procedure 4 times since " i_old_plan_inst_id" , "i_new_plan_inst_id","i_old_act_id","i_new_act_id" are different for every action.
Is there any solution where i can call this procedure only once and all the 4 actions are processed ate once?
Or is there anyway to carry out calling this function parallely instead of calling one by one?
Please guide.
Oracle has a very nice utility dbms_scheduler to run jobs in parallel . You can call the below function four times with different parameters to execute them in parallel.
dbms_scheduler.create_job(job_name => dbms_scheduler.generate_job_name('MY_JOB_'),
job_type => 'PLSQL_BLOCK',
job_action => 'begin handle_NR_Site(i_old_plan_inst_id => param1, i_new_plan_inst_id => param2, i_old_act_id => param3, i_new_act_id => param4 ); end;',
comments => 'Thread 1 descriptionn',
enabled => true,
auto_drop => true);
The jobs will run in background. Query the table DBA_SCHEDULER_JOB_RUN_DETAILS to get the execution status.
For more detailed explanation check the link:
https://oracle-base.com/articles/10g/scheduler-10g

Ada Maps: no visible subprogram matches the specification for "="

I've been using Ada.Containers.Indefinite_Hased_Maps to create my own custom hashed maps, and it worked quite well until I tried to use a vector as the element type. Here is an example of the problematic code:
package String_Vectors is new Ada.Containers.Vectors(Element_Type => Unbounded_String, Index_Type => Natural);
subtype String_Vector is String_Vectors.Vector;
package Positive2StringVector_HashMaps is new Ada.Containers.Indefinite_Hashed_Maps --Compiler fails here
(Element_Type => String_Vector,
Key_Type => Positive,
Hash => Positive_Hash,
Equivalent_Keys => Positive_Equal);
Basically, I cannot Positive2StringVector_HashMaps package, because the compiler comes up with:
no visible subprogram matches the specification for "="
From what I understand, it isn't finding the equality operator for the String_Vector , am I correct? If I am, what is the proper way of implementing it? And if I'm not, what am I doing wrong??
You don’t need to implement
function “=“ (L, R : String_Vectors.Vector) return Boolean
yourself, because there already is one in String_Vectors; see ALRM A.18.2(12). So you write
package Positive2StringVector_HashMaps is new Ada.Containers.Indefinite_Hashed_Maps
(Element_Type => String_Vector,
Key_Type => Positive,
Hash => Positive_Hash,
Equivalent_Keys => Positive_Equal,
“=“ => String_Vectors.”=");
By the way, is there some reason you used Ada.Containers.Vectors on Unbounded_String rather than Indefinite_Vectors on String? (wanting to change the length of a contained string would count as a Good Reason!)

passing integers as parameter in drupal menu

I'm using drupal 6
Suppose I have
$items['path/yo'] = array(
'page callback' => 'callback_function',
'page arguments' => array(1),
'type' => MENU_CALLBACK,
);
It will instead pass in the part of the path that is in the 1-th position (in this case it will pass 'yo') into the callback_function function...
But what if I'm actually TRYING to pass in the integer 1 into the function? How would I do that without casting it as string first and then reconverting to integer...
php type conversion is very well done, you have to be careful with type casting however especially with 0 and 1 as they can be strings, numbers or booleans.
You can use type checks in your conditionals (such as === !==). In your current example it isn't a string first it's a number. It would pass 1 into callback_function.
function callback_function($args) {
print_r($args);
}
Will give you the arguments passed. In this case $args[0] would be the number 1. You shouldn't have to worry if it's a number or a string in 99% of cases because if you use it as a number php will convert it to a number and if you use it as a string php will treat it as a string. Just be careful with conditional statements and be sure to read this: http://php.net/manual/en/language.operators.comparison.php
For example to see if it is the number 1:
if(1 === $args[0]) echo "Numbah one!";
Will only print "Numbah one!" if it's a number type and the number 1. You can typecast it if you like with
(int)$args[0];
(string)$args[0];
(boolean)$args[0];
respectively.
You might also check out this article:
http://drupal.org/node/1473458
$items['path/yo'] = array(
'page callback' => 'callback_function',
'page arguments' => array("1"),
'type' => MENU_CALLBACK,
);
See Wolfe's answer as well. If you enter (int) 1, it will be arg(1). Enter strings to be passed to the page callback as-is.

define an argument value for a step in an Oracle job chain

I'm building a job chain in Oracle (11R2) DBMS Scheduler. The chain has two steps. Each step runs the same program, but with different arguments. I can see how how to define the chain, the steps, the rules, etc - but I cannot figure how to set the argument values for the steps.
When I build jobs that are single calls to programs, I set the arguments like this:
dbms_scheduler.set_job_argument_value(
job_name => 'MY_JOB',
argument_position => 1,
argument_value => 'foo');
My question is: Which dbms_scheduler func/proc would I call to set the arguments for a job step? Using the examples below, how would set an argument for 'STEP_1' in 'MY_CHAIN'?
Thanks,
John
DBMS_SCHEDULER.CREATE_CHAIN (
chain_name => 'MY_CHAIN',
rule_set_name => NULL,
evaluation_interval => NULL,
comments => 'Chain calls 2 steps. Same program but with different arg values.');
DBMS_SCHEDULER.DEFINE_CHAIN_STEP (
chain_name => 'MY_CHAIN',
step_name => 'STEP_1',
program_name => 'MY_PROGRAM');
DBMS_SCHEDULER.DEFINE_CHAIN_STEP (
chain_name => 'MY_CHAIN',
step_name => 'STEP_2',
program_name => 'MY_PROGRAM');
DBMS_SCHEDULER.CREATE_JOB (
job_name => 'MY_CHAIN_JOB',
job_type => 'CHAIN',
job_action => 'MY_CHAIN',
repeat_interval => 'freq=daily;byhour=12;byminute=0;bysecond=0',
enabled => TRUE);
I believe that you'd have to define two different programs for this, although they can of course reference the same stored procedure or executable.
In the case o the former unless I'm going to be modifying the argument values I tend to use anonymous block program types to specify the arguments to stored procedures -- it's complex enough without adding in all that program argument stuff.

Resources