diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.c b/src/mod/endpoints/mod_skinny/mod_skinny.c index b0c8d6d6cb..09c3a7e3ce 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny.c +++ b/src/mod/endpoints/mod_skinny/mod_skinny.c @@ -1545,6 +1545,25 @@ static switch_status_t cmd_profile_device_send_call_state_message(const char *pr return SWITCH_STATUS_SUCCESS; } +static switch_status_t cmd_profile_device_send_reset_message(const char *profile_name, const char *device_name, const char *reset_type, switch_stream_handle_t *stream) +{ + skinny_profile_t *profile; + + if ((profile = skinny_find_profile(profile_name))) { + listener_t *listener = NULL; + skinny_profile_find_listener_by_device_name(profile, device_name, &listener); + if(listener) { + send_reset(listener, skinny_str2device_reset_type(reset_type)); + } else { + stream->write_function(stream, "Listener not found!\n"); + } + } else { + stream->write_function(stream, "Profile not found!\n"); + } + + return SWITCH_STATUS_SUCCESS; +} + SWITCH_STANDARD_API(skinny_function) { char *argv[1024] = { 0 }; @@ -1556,10 +1575,11 @@ SWITCH_STANDARD_API(skinny_function) "skinny help\n" "skinny status profile \n" "skinny status profile device \n" + "skinny profile device send ResetMessage [DeviceReset|DeviceRestart]\n" "skinny profile device send SetRingerMessage \n" "skinny profile device send SetLampMessage \n" "skinny profile device send SetSpeakerModeMessage \n" - "skinny profile device send CallState \n" + "skinny profile device send CallStateMessage \n" "--------------------------------------------------------------------------------\n"; if (session) { return SWITCH_STATUS_FALSE; @@ -1589,18 +1609,42 @@ SWITCH_STANDARD_API(skinny_function) } else if (argc == 5 && !strcasecmp(argv[0], "status") && !strcasecmp(argv[1], "profile") && !strcasecmp(argv[3], "device")) { /* skinny status profile device */ status = cmd_status_profile_device(argv[2], argv[4], stream); - } else if (argc == 8 && !strcasecmp(argv[0], "profile") && !strcasecmp(argv[2], "device") && !strcasecmp(argv[4], "send") && !strcasecmp(argv[5], "SetRingerMessage")) { - /* skinny profile device send SetRingerMessage */ - status = cmd_profile_device_send_ringer_message(argv[1], argv[3], argv[6], argv[7], stream); - } else if (argc == 9 && !strcasecmp(argv[0], "profile") && !strcasecmp(argv[2], "device") && !strcasecmp(argv[4], "send") && !strcasecmp(argv[5], "SetLampMessage")) { - /* skinny profile device send SetLampMessage */ - status = cmd_profile_device_send_lamp_message(argv[1], argv[3], argv[6], argv[7], argv[8], stream); - } else if (argc == 7 && !strcasecmp(argv[0], "profile") && !strcasecmp(argv[2], "device") && !strcasecmp(argv[4], "send") && !strcasecmp(argv[5], "SetSpeakerModeMessage")) { - /* skinny profile device send SetSpeakerModeMessage */ - status = cmd_profile_device_send_speaker_mode_message(argv[1], argv[3], argv[6], stream); - } else if (argc == 9 && !strcasecmp(argv[0], "profile") && !strcasecmp(argv[2], "device") && !strcasecmp(argv[4], "send") && !strcasecmp(argv[5], "CallState")) { - /* skinny profile device send CallState */ - status = cmd_profile_device_send_call_state_message(argv[1], argv[3], argv[6], argv[7], argv[8], stream); + } else if (argc >= 6 && !strcasecmp(argv[0], "profile") && !strcasecmp(argv[2], "device") && !strcasecmp(argv[4], "send")) { + /* skinny profile device send ... */ + switch(skinny_str2message_type(argv[5])) { + case SET_RINGER_MESSAGE: + if(argc == 8) { + /* SetRingerMessage */ + status = cmd_profile_device_send_ringer_message(argv[1], argv[3], argv[6], argv[7], stream); + } + break; + case SET_LAMP_MESSAGE: + if (argc == 9) { + /* SetLampMessage */ + status = cmd_profile_device_send_lamp_message(argv[1], argv[3], argv[6], argv[7], argv[8], stream); + } + break; + case SET_SPEAKER_MODE_MESSAGE: + if (argc == 7) { + /* SetSpeakerModeMessage */ + status = cmd_profile_device_send_speaker_mode_message(argv[1], argv[3], argv[6], stream); + } + break; + case CALL_STATE_MESSAGE: + if (argc == 9) { + /* CallStateMessage */ + status = cmd_profile_device_send_call_state_message(argv[1], argv[3], argv[6], argv[7], argv[8], stream); + } + break; + case RESET_MESSAGE: + if (argc == 7) { + /* ResetMessage */ + status = cmd_profile_device_send_reset_message(argv[1], argv[3], argv[6], stream); + } + break; + default: + stream->write_function(stream, "Unhandled message %s\n", argv[5]); + } } else { stream->write_function(stream, "Unknown Command [%s]\n", argv[0]); } @@ -1694,6 +1738,13 @@ static switch_status_t skinny_list_devices(const char *line, const char *cursor, return status; } +static switch_status_t skinny_list_reset_types(const char *line, const char *cursor, switch_console_callback_match_t **matches) +{ + switch_status_t status = SWITCH_STATUS_FALSE; + SKINNY_PUSH_DEVICE_RESET_TYPES + return status; +} + static switch_status_t skinny_list_stimuli(const char *line, const char *cursor, switch_console_callback_match_t **matches) { switch_status_t status = SWITCH_STATUS_FALSE; @@ -1701,14 +1752,14 @@ static switch_status_t skinny_list_stimuli(const char *line, const char *cursor, return status; } -static switch_status_t skinny_list_ring_type(const char *line, const char *cursor, switch_console_callback_match_t **matches) +static switch_status_t skinny_list_ring_types(const char *line, const char *cursor, switch_console_callback_match_t **matches) { switch_status_t status = SWITCH_STATUS_FALSE; SKINNY_PUSH_RING_TYPES return status; } -static switch_status_t skinny_list_ring_mode(const char *line, const char *cursor, switch_console_callback_match_t **matches) +static switch_status_t skinny_list_ring_modes(const char *line, const char *cursor, switch_console_callback_match_t **matches) { switch_status_t status = SWITCH_STATUS_FALSE; SKINNY_PUSH_RING_MODES @@ -1737,7 +1788,7 @@ static switch_status_t skinny_list_stimulus_modes(const char *line, const char * return status; } -static switch_status_t skinny_list_speaker_mode(const char *line, const char *cursor, switch_console_callback_match_t **matches) +static switch_status_t skinny_list_speaker_modes(const char *line, const char *cursor, switch_console_callback_match_t **matches) { switch_status_t status = SWITCH_STATUS_FALSE; SKINNY_PUSH_SPEAKER_MODES @@ -1830,19 +1881,21 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_skinny_load) switch_console_set_complete("add skinny status profile ::skinny::list_profiles"); switch_console_set_complete("add skinny status profile ::skinny::list_profiles device ::skinny::list_devices"); - switch_console_set_complete("add skinny profile ::skinny::list_profiles device ::skinny::list_devices send SetRingerMessage ::skinny::list_ring_type ::skinny::list_ring_mode"); + switch_console_set_complete("add skinny profile ::skinny::list_profiles device ::skinny::list_devices send ResetMessage ::skinny::list_reset_types"); + switch_console_set_complete("add skinny profile ::skinny::list_profiles device ::skinny::list_devices send SetRingerMessage ::skinny::list_ring_types ::skinny::list_ring_modes"); switch_console_set_complete("add skinny profile ::skinny::list_profiles device ::skinny::list_devices send SetLampMessage ::skinny::list_stimuli ::skinny::list_stimulus_instances ::skinny::list_stimulus_modes"); - switch_console_set_complete("add skinny profile ::skinny::list_profiles device ::skinny::list_devices send SetSpeakerModeMessage ::skinny::list_speaker_mode"); - switch_console_set_complete("add skinny profile ::skinny::list_profiles device ::skinny::list_devices send CallState ::skinny::list_call_states ::skinny::list_line_instances ::skinny::list_call_ids"); + switch_console_set_complete("add skinny profile ::skinny::list_profiles device ::skinny::list_devices send SetSpeakerModeMessage ::skinny::list_speaker_modes"); + switch_console_set_complete("add skinny profile ::skinny::list_profiles device ::skinny::list_devices send CallStateMessage ::skinny::list_call_states ::skinny::list_line_instances ::skinny::list_call_ids"); switch_console_add_complete_func("::skinny::list_profiles", skinny_list_profiles); switch_console_add_complete_func("::skinny::list_devices", skinny_list_devices); - switch_console_add_complete_func("::skinny::list_ring_type", skinny_list_ring_type); - switch_console_add_complete_func("::skinny::list_ring_mode", skinny_list_ring_mode); + switch_console_add_complete_func("::skinny::list_reset_types", skinny_list_reset_types); + switch_console_add_complete_func("::skinny::list_ring_types", skinny_list_ring_types); + switch_console_add_complete_func("::skinny::list_ring_modes", skinny_list_ring_modes); switch_console_add_complete_func("::skinny::list_stimuli", skinny_list_stimuli); switch_console_add_complete_func("::skinny::list_stimulus_instances", skinny_list_stimulus_instances); switch_console_add_complete_func("::skinny::list_stimulus_modes", skinny_list_stimulus_modes); - switch_console_add_complete_func("::skinny::list_speaker_mode", skinny_list_speaker_mode); + switch_console_add_complete_func("::skinny::list_speaker_modes", skinny_list_speaker_modes); switch_console_add_complete_func("::skinny::list_call_states", skinny_list_call_states); switch_console_add_complete_func("::skinny::list_line_instances", skinny_list_line_instances); switch_console_add_complete_func("::skinny::list_call_ids", skinny_list_call_ids); diff --git a/src/mod/endpoints/mod_skinny/skinny_protocol.c b/src/mod/endpoints/mod_skinny/skinny_protocol.c index 6032c285c6..a5d7788902 100644 --- a/src/mod/endpoints/mod_skinny/skinny_protocol.c +++ b/src/mod/endpoints/mod_skinny/skinny_protocol.c @@ -76,7 +76,7 @@ struct skinny_table SKINNY_MESSAGE_TYPES[] = { {"AlarmMessage", ALARM_MESSAGE}, {"OpenReceiveChannelAckMessage", OPEN_RECEIVE_CHANNEL_ACK_MESSAGE}, {"SoftKeySetReqMessage", SOFT_KEY_SET_REQ_MESSAGE}, - {"SOftKeyEventMessage", SOFT_KEY_EVENT_MESSAGE}, + {"SoftKeyEventMessage", SOFT_KEY_EVENT_MESSAGE}, {"UnregisterMessage", UNREGISTER_MESSAGE}, {"SoftKeyTemplateReqMessage", SOFT_KEY_TEMPLATE_REQ_MESSAGE}, {"FeatureStatReqMessage", FEATURE_STAT_REQ_MESSAGE}, @@ -98,7 +98,8 @@ struct skinny_table SKINNY_MESSAGE_TYPES[] = { {"ButtonTemplateResMessage", BUTTON_TEMPLATE_RES_MESSAGE}, {"CapabilitiesReqMessage", CAPABILITIES_REQ_MESSAGE}, {"RegisterRejMessage", REGISTER_REJ_MESSAGE}, - {"KeepAliveAckMessageMessage", KEEP_ALIVE_ACK_MESSAGE}, + {"ResetMessage", RESET_MESSAGE}, + {"KeepAliveAckMessage", KEEP_ALIVE_ACK_MESSAGE}, {"OpenReceiveChannelMessage", OPEN_RECEIVE_CHANNEL_MESSAGE}, {"OCloseReceiveChannelMessage", CLOSE_RECEIVE_CHANNEL_MESSAGE}, {"SoftKeyTemplateResMessage", SOFT_KEY_TEMPLATE_RES_MESSAGE}, @@ -198,6 +199,15 @@ struct skinny_table SKINNY_CALL_STATES[] = { }; SKINNY_DECLARE_ID2STR(skinny_call_state2str, SKINNY_CALL_STATES, "CallStateUnknown") SKINNY_DECLARE_STR2ID(skinny_str2call_state, SKINNY_CALL_STATES, -1) + +struct skinny_table SKINNY_DEVICE_RESET_TYPES[] = { + {"DeviceReset", SKINNY_DEVICE_RESET}, + {"DeviceRestart", SKINNY_DEVICE_RESTART}, + {NULL, 0} +}; +SKINNY_DECLARE_ID2STR(skinny_device_reset_type2str, SKINNY_DEVICE_RESET_TYPES, "DeviceResetTypeUnknown") +SKINNY_DECLARE_STR2ID(skinny_str2device_reset_type, SKINNY_DEVICE_RESET_TYPES, -1) + /*****************************************************************************/ /* SKINNY FUNCTIONS */ /*****************************************************************************/ @@ -1081,6 +1091,18 @@ switch_status_t send_dialed_number(listener_t *listener, return SWITCH_STATUS_SUCCESS; } +switch_status_t send_reset(listener_t *listener, + uint32_t reset_type) +{ + skinny_message_t *message; + message = switch_core_alloc(listener->pool, 12+sizeof(message->data.reset)); + message->type = RESET_MESSAGE; + message->length = 4 + sizeof(message->data.reset); + message->data.reset.reset_type = reset_type; + skinny_send_reply(listener, message); + return SWITCH_STATUS_SUCCESS; +} + /* Message handling */ switch_status_t skinny_handle_alarm(listener_t *listener, skinny_message_t *request) { diff --git a/src/mod/endpoints/mod_skinny/skinny_protocol.h b/src/mod/endpoints/mod_skinny/skinny_protocol.h index c6b1a29d55..f3be6ea5c2 100644 --- a/src/mod/endpoints/mod_skinny/skinny_protocol.h +++ b/src/mod/endpoints/mod_skinny/skinny_protocol.h @@ -342,6 +342,12 @@ struct register_rej_message { char error[33]; }; +/* ResetMessage */ +#define RESET_MESSAGE 0x009F +struct reset_message { + uint32_t reset_type; /* See enum skinny_device_reset_types */ +}; + /* KeepAliveAckMessage */ #define KEEP_ALIVE_ACK_MESSAGE 0x0100 @@ -490,6 +496,7 @@ union skinny_data { struct define_time_date_message define_time_date; struct button_template_message button_template; struct register_rej_message reg_rej; + struct reset_message reset; struct open_receive_channel_message open_receive_channel; struct close_receive_channel_message close_receive_channel; struct soft_key_template_res_message soft_key_template; @@ -612,7 +619,7 @@ uint32_t func(const char *str)\ status = SWITCH_STATUS_SUCCESS;\ } -struct skinny_table SKINNY_MESSAGE_TYPES[51]; +struct skinny_table SKINNY_MESSAGE_TYPES[52]; const char *skinny_message_type2str(uint32_t id); uint32_t skinny_str2message_type(const char *str); #define SKINNY_PUSH_MESSAGE_TYPES SKINNY_DECLARE_PUSH_MATCH(SKINNY_MESSAGE_TYPES) @@ -749,6 +756,15 @@ const char *skinny_call_state2str(uint32_t id); uint32_t skinny_str2call_state(const char *str); #define SKINNY_PUSH_CALL_STATES SKINNY_DECLARE_PUSH_MATCH(SKINNY_CALL_STATES) +enum skinny_device_reset_types { + SKINNY_DEVICE_RESET = 1, + SKINNY_DEVICE_RESTART = 2 +}; +struct skinny_table SKINNY_DEVICE_RESET_TYPES[3]; +const char *skinny_device_reset_type2str(uint32_t id); +uint32_t skinny_str2device_reset_type(const char *str); +#define SKINNY_PUSH_DEVICE_RESET_TYPES SKINNY_DECLARE_PUSH_MATCH(SKINNY_DEVICE_RESET_TYPES) + /*****************************************************************************/ /* SKINNY FUNCTIONS */ /*****************************************************************************/ @@ -869,6 +885,8 @@ switch_status_t send_dialed_number(listener_t *listener, char called_party[24], uint32_t line_instance, uint32_t call_id); +switch_status_t send_reset(listener_t *listener, + uint32_t reset_type); #endif /* _SKINNY_PROTOCOL_H */