Het ontvangen van SMS berichten op een USB dongle via Kannel is over het algemeen geen moeilijke klus.
Echter verschilt het per dongle blijkbaar op welk slot deze begint met tellen in de SIM storage.
Kannel begint netjes bij 1 en telt door totdat deze het einde van de storage heeft doorzocht, echter komt dan met een fout.
2014-07-29 12:15:59 [3038] [6] DEBUG: AT2[huawei_k3770_00]: --> AT+CPMS?^M 2014-07-29 12:15:59 [3038] [6] DEBUG: AT2[huawei_k3770_00]: <-- +CPMS: "SM",1,20,"SM",1,20,"SM",1,20 2014-07-29 12:15:59 [3038] [6] DEBUG: AT2[huawei_k3770_00]: <-- OK 2014-07-29 12:15:59 [3038] [6] DEBUG: AT2[huawei_k3770_00]: 1 messages waiting in memory 2014-07-29 12:15:59 [3038] [6] DEBUG: AT2[huawei_k3770_00]: --> AT+CMGR=1^M 2014-07-29 12:15:59 [3038] [6] DEBUG: AT2[huawei_k3770_00]: <-- OK 2014-07-29 12:15:59 [3038] [6] DEBUG: AT2[huawei_k3770_00]: not deleted. 2014-07-29 12:15:59 [3038] [6] DEBUG: AT2[huawei_k3770_00]: --> AT+CMGR=2^M 2014-07-29 12:15:59 [3038] [6] DEBUG: AT2[huawei_k3770_00]: <-- OK 2014-07-29 12:15:59 [3038] [6] DEBUG: AT2[huawei_k3770_00]: not deleted. 2014-07-29 12:15:59 [3038] [6] DEBUG: AT2[huawei_k3770_00]: --> AT+CMGR=3^M 2014-07-29 12:15:59 [3038] [6] DEBUG: AT2[huawei_k3770_00]: <-- OK 2014-07-29 12:15:59 [3038] [6] DEBUG: AT2[huawei_k3770_00]: not deleted. 2014-07-29 12:15:59 [3038] [6] DEBUG: AT2[huawei_k3770_00]: --> AT+CMGR=4^M 2014-07-29 12:15:59 [3038] [6] DEBUG: AT2[huawei_k3770_00]: <-- OK 2014-07-29 12:15:59 [3038] [6] DEBUG: AT2[huawei_k3770_00]: not deleted. 2014-07-29 12:15:59 [3038] [6] DEBUG: AT2[huawei_k3770_00]: --> AT+CMGR=5^M 2014-07-29 12:15:59 [3038] [6] DEBUG: AT2[huawei_k3770_00]: <-- OK 2014-07-29 12:15:59 [3038] [6] DEBUG: AT2[huawei_k3770_00]: not deleted. 2014-07-29 12:15:59 [3038] [6] DEBUG: AT2[huawei_k3770_00]: --> AT+CMGR=6^M 2014-07-29 12:15:59 [3038] [6] DEBUG: AT2[huawei_k3770_00]: <-- OK 2014-07-29 12:15:59 [3038] [6] DEBUG: AT2[huawei_k3770_00]: not deleted. 2014-07-29 12:15:59 [3038] [6] DEBUG: AT2[huawei_k3770_00]: --> AT+CMGR=7^M 2014-07-29 12:15:59 [3038] [6] DEBUG: AT2[huawei_k3770_00]: <-- OK 2014-07-29 12:15:59 [3038] [6] DEBUG: AT2[huawei_k3770_00]: not deleted. 2014-07-29 12:15:59 [3038] [6] DEBUG: AT2[huawei_k3770_00]: --> AT+CMGR=8^M 2014-07-29 12:15:59 [3038] [6] DEBUG: AT2[huawei_k3770_00]: <-- OK 2014-07-29 12:15:59 [3038] [6] DEBUG: AT2[huawei_k3770_00]: not deleted. 2014-07-29 12:15:59 [3038] [6] DEBUG: AT2[huawei_k3770_00]: --> AT+CMGR=9^M 2014-07-29 12:16:00 [3038] [6] DEBUG: AT2[huawei_k3770_00]: <-- OK 2014-07-29 12:16:00 [3038] [6] DEBUG: AT2[huawei_k3770_00]: not deleted. 2014-07-29 12:16:00 [3038] [6] DEBUG: AT2[huawei_k3770_00]: --> AT+CMGR=10^M 2014-07-29 12:16:00 [3038] [6] DEBUG: AT2[huawei_k3770_00]: <-- OK 2014-07-29 12:16:00 [3038] [6] DEBUG: AT2[huawei_k3770_00]: not deleted. 2014-07-29 12:16:00 [3038] [6] DEBUG: AT2[huawei_k3770_00]: --> AT+CMGR=11^M 2014-07-29 12:16:00 [3038] [6] DEBUG: AT2[huawei_k3770_00]: <-- OK 2014-07-29 12:16:00 [3038] [6] DEBUG: AT2[huawei_k3770_00]: not deleted. 2014-07-29 12:16:00 [3038] [6] DEBUG: AT2[huawei_k3770_00]: --> AT+CMGR=12^M 2014-07-29 12:16:00 [3038] [6] DEBUG: AT2[huawei_k3770_00]: <-- OK 2014-07-29 12:16:00 [3038] [6] DEBUG: AT2[huawei_k3770_00]: not deleted. 2014-07-29 12:16:00 [3038] [6] DEBUG: AT2[huawei_k3770_00]: --> AT+CMGR=13^M 2014-07-29 12:16:00 [3038] [6] DEBUG: AT2[huawei_k3770_00]: <-- OK 2014-07-29 12:16:00 [3038] [6] DEBUG: AT2[huawei_k3770_00]: not deleted. 2014-07-29 12:16:00 [3038] [6] DEBUG: AT2[huawei_k3770_00]: --> AT+CMGR=14^M 2014-07-29 12:16:00 [3038] [6] DEBUG: AT2[huawei_k3770_00]: <-- OK 2014-07-29 12:16:00 [3038] [6] DEBUG: AT2[huawei_k3770_00]: not deleted. 2014-07-29 12:16:00 [3038] [6] DEBUG: AT2[huawei_k3770_00]: --> AT+CMGR=15^M 2014-07-29 12:16:00 [3038] [6] DEBUG: AT2[huawei_k3770_00]: <-- OK 2014-07-29 12:16:00 [3038] [6] DEBUG: AT2[huawei_k3770_00]: not deleted. 2014-07-29 12:16:00 [3038] [6] DEBUG: AT2[huawei_k3770_00]: --> AT+CMGR=16^M 2014-07-29 12:16:00 [3038] [6] DEBUG: AT2[huawei_k3770_00]: <-- OK 2014-07-29 12:16:00 [3038] [6] DEBUG: AT2[huawei_k3770_00]: not deleted. 2014-07-29 12:16:00 [3038] [6] DEBUG: AT2[huawei_k3770_00]: --> AT+CMGR=17^M 2014-07-29 12:16:00 [3038] [6] DEBUG: AT2[huawei_k3770_00]: <-- OK 2014-07-29 12:16:00 [3038] [6] DEBUG: AT2[huawei_k3770_00]: not deleted. 2014-07-29 12:16:00 [3038] [6] DEBUG: AT2[huawei_k3770_00]: --> AT+CMGR=18^M 2014-07-29 12:16:00 [3038] [6] DEBUG: AT2[huawei_k3770_00]: <-- OK 2014-07-29 12:16:00 [3038] [6] DEBUG: AT2[huawei_k3770_00]: not deleted. 2014-07-29 12:16:00 [3038] [6] DEBUG: AT2[huawei_k3770_00]: --> AT+CMGR=19^M 2014-07-29 12:16:01 [3038] [6] DEBUG: AT2[huawei_k3770_00]: <-- OK 2014-07-29 12:16:01 [3038] [6] DEBUG: AT2[huawei_k3770_00]: not deleted. 2014-07-29 12:16:01 [3038] [6] DEBUG: AT2[huawei_k3770_00]: --> AT+CMGR=20^M 2014-07-29 12:16:01 [3038] [6] DEBUG: AT2[huawei_k3770_00]: <-- +CMS ERROR: 500 2014-07-29 12:16:01 [3038] [6] ERROR: AT2[huawei_k3770_00]: CMS ERROR: +CMS ERROR: 500 2014-07-29 12:16:01 [3038] [6] ERROR: AT2[huawei_k3770_00]: CMS ERROR: Unknown error. -> maybe Sim storage is full? I'll have a look at it. (500) 2014-07-29 12:16:01 [3038] [6] DEBUG: AT2[huawei_k3770_00]: failed to get message 20.
Zoals je kan zien stuurt Kannel het AT commando “AT+CPMS?” naar de dongle om te vragen hoeveel berichten deze heeft om zijn SIM storage.
De dongle reageert door “+CPMS: “SM”,1,20,”SM”,1,20,”SM”,1,20″ terug te sturen naar Kannel en daarmee wordt aangegeven dat er 1 bericht is en een storage van max. 20 berichten.
Dit kan je ook zien door het bericht “1 messages waiting in memory”. Echter begint Kannel op dit punt met het ophalen van alle berichten door het AT commando “AT+CMGR=1” voor bericht nummer 1.
Dit doet Kannel voor alle 20 berichten slots op de dongle totdat deze op bericht 20 een onbekende fout krijgt.
Wat opvalt in het bovenstaande is dat Kannel geen bericht ziet op slot 1 van de dongle en een fout krijgt op de het 20e slot van de dongle.
Het lijkt er dus sterk op de dat het eerste bericht niet op slot 1 staat, maar op slot 0, waardoor het laatste slot zich bevind op slot 19 en niet op 20.
Kannel houdt hier echter geen rekening mee en er is ook geen optie in de configuratie om dit aan te passen.
Uiteindelijk heb ik de oplossing gevonden door Kannel 1.4.3 te downloaden en uit te pakken op de schijf.
Vervolgens heb ik het bestand gateway-1.4.3/gw/smsc/smsc_at.c aangepast, hier stond namelijk hardcoded in dat Kannel moet beginnen bij slot 1 i.p.v. slot 0.
Op lijnnummer 1074 staat het volgende:
/* * loop till end of memory or collected enouch messages */ for (i = 1; i <= privdata->sms_memory_capacity && message_count < privdata->sms_memory_usage; ++i) { /* if (meanwhile) there are pending CMTI notifications, process these first * to not let CMTI and sim buffering sit in each others way */ while (gwlist_len(privdata->pending_incoming_messages) > 0) { at2_read_pending_incoming_messages(privdata); } /* read the message and delete it */ message_count += at2_read_delete_message(privdata, i); }
De regel “for (i = 1; i <= privdata->sms_memory_capacity &&” heb ik aangepast naar “for (i = 0; i <= privdata->sms_memory_capacity-1 &&”.
Daarna heb ik Kannel opnieuw gecompiled. Dit bleek de oplossing te zijn voor het probleem:
2014-07-29 20:23:08 [8472] [6] DEBUG: AT2[huawei_k3770_00]: --> AT+CPMS?^M 2014-07-29 20:23:08 [8472] [6] DEBUG: AT2[huawei_k3770_00]: <-- +CPMS: "SM",1,20,"SM",1,20,"SM",1,20 2014-07-29 20:23:08 [8472] [6] DEBUG: AT2[huawei_k3770_00]: <-- OK 2014-07-29 20:23:08 [8472] [6] DEBUG: AT2[huawei_k3770_00]: 1 messages waiting in memory 2014-07-29 20:23:08 [8472] [6] DEBUG: AT2[huawei_k3770_00]: --> AT+CMGR=0^M 2014-07-29 20:23:08 [8472] [6] DEBUG: AT2[huawei_k3770_00]: <-- +CMGR: 0,,26 2014-07-29 20:23:08 [8472] [6] DEBUG: AT2[huawei_k3770_00]: <-- 0791135604880101040B911346262298F100004170920222538007C6B31A4D36A301 2014-07-29 20:23:08 [8472] [6] DEBUG: AT2[huawei_k3770_00]: received message from SMSC: +316540881010 2014-07-29 20:23:08 [8472] [6] DEBUG: AT2[huawei_k3770_00]: Numeric sender (international) <+316*******> 2014-07-29 20:23:08 [8472] [6] DEBUG: AT2[huawei_k3770_00]: User data length read as (7) 2014-07-29 20:23:08 [8472] [6] DEBUG: AT2[huawei_k3770_00]: Udh decoding done len=7 udhi=0 udhlen=0 udh='' 2014-07-29 20:23:08 [8472] [9] DEBUG: send_msg: sending msg to box: <127.0.0.1> 2014-07-29 20:23:08 [8472] [9] DEBUG: boxc_sender: sent message to <127.0.0.1> 2014-07-29 20:23:08 [8472] [8] DEBUG: boxc_receiver: got ack 2014-07-29 20:23:08 [8472] [6] DEBUG: AT2[huawei_k3770_00]: <-- OK 2014-07-29 20:23:08 [8472] [6] DEBUG: AT2[huawei_k3770_00]: --> AT+CMGD=0^M 2014-07-29 20:23:08 [8472] [6] DEBUG: AT2[huawei_k3770_00]: <-- OK
Zoals je ziet begint Kannel nu bij 0 met het AT commando “AT+CMGR=0” en haalt nu het bericht op van de dongle.
Hij zoekt nu ook niet meer alle 20 slots langs voor het het bericht. tot slot hierbij nog de uitkomst van de diff:
--- smsc_at.c 2014-07-29 20:14:35.031516586 +0200 +++ smsc_at.c.old 2014-07-30 12:31:27.905691199 +0200 @@ -1071,7 +1071,7 @@ /* * loop till end of memory or collected enouch messages */ - for (i = 0; i <= privdata->sms_memory_capacity-1 && + for (i = 1; i <= privdata->sms_memory_capacity && message_count < privdata->sms_memory_usage; ++i) { /* if (meanwhile) there are pending CMTI notifications, process these first