Solution found with an awful(but working) workaround: instead of using patterns
I use one extension per peer
I define first the numeric pattern(grandstream http app can sen’t sms only to numeric)
exten => _XXXX,1,NoOp(SMS receiving dialplan invoked)
same => n,NoOp(To ${MESSAGE(to)})
same => n,NoOp(From ${MESSAGE(from)})
same => n,NoOp(Body ${MESSAGE(body)})
same => n,Set(ACTUALTO=${CUT(MESSAGE(to),@,1)})
same => n,ExecIf($["${ACTUALTO}" = “sip:1001”]?set(ACTUALTO2=phone1))
same => n,ExecIf($["${ACTUALTO}" = “sip:1008”]?set(ACTUALTO2=phone2))
same => n,MessageSend(sip:${ACTUALTO2},"${CALLERID(name)}"${MESSAGE(from)})
same => n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
same => n,GotoIf($["${MESSAGE_SEND_STATUS}" != “SUCCESS”]?sendfailedmsg)
same => n,Hangup()
same => n(sendfailedmsg),Set(MESSAGE(body)="[${STRFTIME(${EPOCH},%d%m%Y-%H:%M:%S)}] Your message to ${EXTEN} has failed. Retry later.")
same => n,Set(ME_1=${CUT(MESSAGE(from),<,2)})
same => n,Set(ACTUALFROM=${CUT(ME_1,@,1)})
same => n,MessageSend(${ACTUALFROM},ServiceCenter)
same => n,Hangup()
then (in the sms context) the exten phone2
exten => phone2,1,NoOp(SMS receiving dialplan invoked)
same => n,NoOp(To ${MESSAGE(to)})
same => n,NoOp(From ${MESSAGE(from)})
same => n,NoOp(Body ${MESSAGE(body)})
same => n,Set(ACTUALTO=${CUT(MESSAGE(to),@,1)})
same => n,ExecIf($["${ACTUALTO}" = “sip:phone1”]?set(ACTUALTO2=phone1))
same => n,ExecIf($["${ACTUALTO}" = “sip:phone2”]?set(ACTUALTO2=phone2))
same => n,MessageSend(sip:${ACTUALTO2},"${CALLERID(name)}"${MESSAGE(from)})
same => n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
same => n,GotoIf($["${MESSAGE_SEND_STATUS}" != “SUCCESS”]?sendfailedmsg)
same => n,Hangup()
same => n(sendfailedmsg),Set(MESSAGE(body)="[${STRFTIME(${EPOCH},%d%m%Y-%H:%M:%S)}] Your message to ${EXTEN} has failed. Retry later.")
same => n,Set(ME_1=${CUT(MESSAGE(from),<,2)})
same => n,Set(ACTUALFROM=${CUT(ME_1,@,1)})
same => n,MessageSend(${ACTUALFROM},ServiceCenter)
same => n,Hangup()
then (in the sms context) the exten phone1
exten => phone1,1,NoOp(SMS receiving dialplan invoked)
same => n,NoOp(To ${MESSAGE(to)})
same => n,NoOp(From ${MESSAGE(from)})
same => n,NoOp(Body ${MESSAGE(body)})
same => n,Set(ACTUALTO=${CUT(MESSAGE(to),@,1)})
same => n,ExecIf($["${ACTUALTO}" = “sip:phone1”]?set(ACTUALTO2=phone1))
same => n,ExecIf($["${ACTUALTO}" = “sip:phone2”]?set(ACTUALTO2=phone2))
same => n,MessageSend(sip:${ACTUALTO2},"${CALLERID(name)}"${MESSAGE(from)})
same => n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
same => n,GotoIf($["${MESSAGE_SEND_STATUS}" != “SUCCESS”]?sendfailedmsg)
same => n,Hangup()
same => n(sendfailedmsg),Set(MESSAGE(body)="[${STRFTIME(${EPOCH},%d%m%Y-%H:%M:%S)}] Your message to ${EXTEN} has failed. Retry later.")
same => n,Set(ME_1=${CUT(MESSAGE(from),<,2)})
same => n,Set(ACTUALFROM=${CUT(ME_1,@,1)})
same => n,MessageSend(${ACTUALFROM},ServiceCenter)
same => n,Hangup()
I had make some text and works fine, I can chat between linphone and hardphone.
I have tried the pattern _phone[12] and phone[12] but fail
Thanks to all for help