[asterisk-dev] Default Device State (devicestate.c)

Bill Kervaski bill at kervaski.com
Fri Aug 19 13:11:43 CDT 2022


Hi All!

Hacking around in devicestate.c (18.14.0) I can change the following to get the default device state to “NOT_INUSE”.

Wondering if this is a reasonable way to handle this, as my requirement is for all "UNKNOWN" device states to be treated as “NOT_INUSE” without having to invoke a call or an AMI action to set the initial state.

Not knowing what this may impact makes me hesitant to put this into production without someone who knows this subsystem’s blessing, any advice appreciated!

enum ast_device_state ast_devstate_val(const char *val)
{
        if (!strcasecmp(val, "NOT_INUSE"))
                return AST_DEVICE_NOT_INUSE;
        else if (!strcasecmp(val, "INUSE"))
                return AST_DEVICE_INUSE;
        else if (!strcasecmp(val, "BUSY"))
                return AST_DEVICE_BUSY;
        else if (!strcasecmp(val, "INVALID"))
                return AST_DEVICE_INVALID;
        else if (!strcasecmp(val, "UNAVAILABLE"))
                return AST_DEVICE_UNAVAILABLE;
        else if (!strcasecmp(val, "RINGING"))
                return AST_DEVICE_RINGING;
        else if (!strcasecmp(val, "RINGINUSE"))
                return AST_DEVICE_RINGINUSE;
        else if (!strcasecmp(val, "ONHOLD"))
                return AST_DEVICE_ONHOLD;

        return AST_DEVICE_NOT_INUSE; // MY CHANGE
        // return AST_DEVICE_UNKNOWN; 
}




More information about the asterisk-dev mailing list