--- app_sms.c.147592 2008-10-09 09:21:32.000000000 +1300 +++ app_sms.c 2008-10-13 21:39:50.000000000 +1300 @@ -1860,6 +1860,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 */ @@ -1874,9 +1878,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);