--- app_sms.c.148985 2008-10-15 19:45:16.000000000 +1300 +++ app_sms.c 2008-10-15 19:57:06.000000000 +1300 @@ -1958,6 +1958,10 @@ res = h.err; goto done; } + + if (chan->_state != AST_STATE_UP) { /* make sure channel is answered before any TX */ + ast_answer(chan); + } if (ast_test_flag(&flags, OPTION_ANSWER)) { h.framenumber = 1; /* Proto 2 */ @@ -1972,10 +1976,6 @@ sms_messagetx(&h); } - if (chan->_state != AST_STATE_UP) { - ast_answer(chan); - } - res = ast_set_write_format(chan, __OUT_FMT); if (res >= 0) { res = ast_set_read_format(chan, AST_FORMAT_SLINEAR);