用oFono收發短信

收發短信是oFono所支持的一項基本功能。用phonesim也可以模擬短信的收發。oFono本身不會保存短信,而是希望第三方plugin如sms history來把短信保存到sim卡或者SD卡上。
1. 啓動oFono並power on modem。
2. ./ofono/test/receive-sms 用來監聽是否有新的短信
3. 通過send-sms腳本可以發短信。比如
xxx@xxx:~/ofono/test$ ./send-sms 135xxxxxxxx "Hello World"
從oFono console log中可以看到短信發送的全過程。它會把短信encode成PDU格式,用AT+CMGS發送出去。你還可以設置短信delivery report來確認短信是否真正發送出去了。
ofonod[3372]: src/sms.c:sms_send_message() ref: 0, offset: 0
ofonod[3372]: src/sms.c:tx_queue_entry_new() pdu_len: 25, tpdu_len: 24
ofonod[3372]: Sending SMS on modem: 0x9009680
ofonod[3372]: InternalMessageId: 2
ofonod[3372]: To: 1xxxxxxxxxx:
ofonod[3372]: Local Time: 2010-09-17T10:23:12+0800
ofonod[3372]: Text: Hello World
ofonod[3372]: Pcui:< /r/n^MODE:3,3/r/n
...
ofonod[3372]: Pcui:> AT+CMGS=24/r
ofonod[3372]: Pcui:< /r/n>
ofonod[3372]: Pcui:&gt; 0031000B813165646315F50000A70BC8329BFD065DDF723619
ofonod[3372]: Pcui:< /r/n
ofonod[3372]: Pcui:&lt; /r/n^MODE:3,3/r/n
ofonod[3372]: Pcui:&lt; /r/n+CMGS: 5/r/n/r/nOK/r/n
ofonod[3372]: drivers/atmodem/sms.c:at_cmgs_cb() Got MR: 5
ofonod[3372]: src/sms.c:tx_finished() tx_finished
ofonod[3372]: SMS 2 submitted successfully
ofonod[3372]: Submission Time: 2010-09-17T10:23:53+0800
ofonod[3372]: Pcui:> AT+COPS=3,0/r
ofonod[3372]: Pcui:< /r/nOK/r/n
ofonod[3372]: Pcui:> AT+COPS?/r
ofonod[3372]: Pcui:< /r/n+COPS: 0,0,"CHINA  MOBILE",0/r/n/r/nOK/r/n
ofonod[3372]: drivers/atmodem/network-registration.c:cops_cb() cops_cb: CHINA  MOBILE, 460 00 0
ofonod[3372]: src/network.c:current_operator_callback() 0x9009da8, 0x900d438
ofonod[3372]: Pcui:&lt; /r/n^MODE:3,3/r/n
ofonod[3372]: Pcui:&lt; /r/n+CDS: 26/r/n0891683108200105F006040D91683165646315F5019071013284230190710132802300/r/n
ofonod[3372]: drivers/atmodem/sms.c:at_cds_notify() Got new Status-Report PDU via CDS: 0891683108200105F006040D91683165646315F5019071013284230190710132802300, 26
ofonod[3372]: src/sms.c:ofono_sms_status_notify() len 35 tpdu len 26
ofonod[3372]: src/sms.c:handle_sms_status_report()
4. 哈,我收到了來自oFono的Hello World,於是我從手機上回復了。oFono很快收到了我的回覆。
ofonod[3372]: Pcui:&lt; /r/n+CMTI: "ME",0/r/n
ofonod[3372]: drivers/atmodem/sms.c:at_cmti_notify() Got a CMTI indication at ME, index: 0
ofonod[3372]: Pcui:> AT+CMGR=0/r
ofonod[3372]: Pcui:< /r/n+CMGR: 0,,34/r/n0891683108200105F0240D91683165646315F50000019071016265230F5474D8BD9EBB8E6F3A28FFAE8700/r/n/r/nOK/r/n
ofonod[3372]: drivers/atmodem/sms.c:at_cmgr_notify()
ofonod[3372]: drivers/atmodem/sms.c:at_cmgr_notify() Got PDU: 0891683108200105F0240D91683165646315F50000019071016265230F5474D8BD9EBB8E6F3A28FFAE8700, with len: 34
ofonod[3372]: src/sms.c:ofono_sms_deliver_notify() len 43 tpdu len 34
ofonod[3372]: src/sms.c:handle_deliver()
ofonod[3372]: src/sms.c:sms_dispatch()
ofonod[3372]: Incoming SMS on modem: 0x9009680
ofonod[3372]: InternalMessageId: 3
ofonod[3372]: From: +861xxxxxxxxxx
ofonod[3372]: Local Sent Time: 2010-09-17T10:26:56+0800
ofonod[3372]: Remote Sent Time: 2010-09-17T10:26:56+0800
ofonod[3372]: Text: Thanks.Got you!
ofonod[3372]: Pcui:> AT+CMGD=0/r
ofonod[3372]: Pcui:&lt; /r/nOK/r/n
xxx@xxx:~/ofono/test$ ./receive-sms
Thanks.Got you!
    LocalSentTime = 2010-09-17T10:26:56+0800
    SentTime = 2010-09-17T10:26:56+0800
    Sender = +861xxxxxxxxxx
怎麼樣,是不是很簡單?
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章