sim800: adding support for Simcom SIM800 modem
PATCH 1/3 sim800: adding support for Simcom SIM800 modem
From: clem <[email protected]>
--- Makefile.am | 4 + plugins/sim800.c | 424 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 428 insertions(+) create mode 100644 plugins/sim800.c
Makefile.am +4 -0
@@ -496,6 +496,10 @@ builtin_sources += plugins/speedupcdma.c builtin_modules += samsung builtin_sources += plugins/samsung.c +builtin_modules += sim800 +builtin_sources += plugins/sim800.c + + builtin_modules += sim900 builtin_sources += plugins/sim900.c
plugins/sim800.c new file +424 -0
424 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH 2/3 sim800: add udev detection
From: clem <[email protected]>
--- plugins/udevng.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
plugins/udevng.c +49 -0
@@ -710,6 +710,53 @@ static gboolean setup_telitqmi(struct modem_info *modem)return TRUE; } +static gboolean setup_sim800 (struct modem_info *modem) +{ +const char *mdm =NULL , *aux =NULL , *gps =NULL , *diag =NULL ; +GSList *list; + +DBG ("%s" , modem->syspath); + +for (list = modem->devices; list; list = list->next) { +struct device_info *info = list->data; + +DBG ("%s %s %s %s" , info->devnode, info->interface, + info->number, info->label); + +if (g_strcmp0 (info->label,"aux" ) ==0 ) { +DBG ("setting aux as info->devnode" ); + aux = info->devnode; +if (mdm !=NULL ) +break ; + }else if (g_strcmp0 (info->label,"modem" ) ==0 ) { + mdm = info->devnode; +if (aux !=NULL ) +break ; + }else if (g_strcmp0 (info->interface,"255/0/0" ) ==0 ) { +if (g_strcmp0 (info->number,"00" ) ==0 ) + mdm = info->devnode; +else if (g_strcmp0 (info->number,"01" ) ==0 ) + gps = info->devnode; +else if (g_strcmp0 (info->number,"02" ) ==0 ) + aux = info->devnode; +else if (g_strcmp0 (info->number,"03" ) ==0 ) + mdm = info->devnode; + } + } + +DBG ("modem=%s aux=%s gps=%s diag=%s" , mdm, aux, gps, diag); + +if (mdm ==NULL ) { +DBG ("modem did not set up" ); +return FALSE; + } + +ofono_modem_set_string (modem->modem,"Device" , mdm); +ofono_modem_set_string (modem->modem,"Modem" , mdm); + +return TRUE; +} +/* TODO: Not used as we have no simcom driver */ static gboolean setup_simcom (struct modem_info *modem) {
@@ -1282,6 +1329,7 @@ static struct { { "telit", setup_telit, "device/interface" }, { "telitqmi", setup_telitqmi }, { "simcom", setup_simcom }, + { "sim800", setup_sim800 }, { "sim7100", setup_sim7100 }, { "zte", setup_zte }, { "icera", setup_icera },
@@ -1654,6 +1702,7 @@ static struct { { "alcatel", "option", "1bbb", "0017" }, { "novatel", "option", "1410" }, { "zte", "option", "19d2" }, + { "sim800", "option", "05c6", "9000" }, { "simcom", "option", "05c6", "9000" }, { "sim7100", "option", "1e0e", "9001" }, { "telit", "usbserial", "1bc7" },
Signature · 1 line
2.7.4
PATCH 3/3 sim800: adding documentation to inform about the udev rule the user must add
In reply to ClémentVielFrom: clem <[email protected]>
--- doc/sim800-modem.txt | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 doc/sim800-modem.txt
doc/sim800-modem.txt new file +7 -0
@@ -0,0 +1,7 @@ +SIM800 modem usage +=================== + +To enable SIM900 module support you need to put the following +udev rule into appropriate file in /{etc,lib}/udev/rules.d: + +KERNEL=="ttyUSB0", ENV{OFONO_DRIVER}="sim800"
Signature · 1 line
2.7.4
Re: [PATCH 3/3] sim800: adding documentation to inform about the udev rule the user must add
Hi,
Quoted 1 line · ClémentViel
From: clem <[email protected]>
Can you fix your Author information (see AUTHORS for an example). Otherwise I cannot take these...
Quoted 13 lines
--- doc/sim800-modem.txt | 7 +++++++ 1 file changed, 7 insertions(+)create mode 100644
doc/sim800-modem.txtdoc/sim800-modem.txt new file +0
-0
doc/sim800-modem.txt line 7
Quoted 7 lines
doc/sim800-modem.txt new file +7
-0@@ -0,0 +1,7 @@ +SIM800 modem usage +=================== + +To enable SIM900 module support you need to put the following +udev rule into appropriate file in /{etc,lib}/udev/rules.d: + +KERNEL=="ttyUSB0", ENV{OFONO_DRIVER}="sim800"
So sim800 is a serial device right? I take it you're running it from a serial converter here?
Regards,
-Denis
Re: [PATCH 2/3] sim800: add udev detection
In reply to ClémentVielHi,
Quoted 38 lines · ClémentViel
From: clem <[email protected]>
--- plugins/udevng.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)plugins/udevng.c +24
-0@@ -710,6 +710,53 @@ static gboolean setup_telitqmi(struct modem_info *modem)return TRUE; } +static gboolean setup_sim800 (struct modem_info *modem) +{ +const char *mdm =NULL , *aux =NULL , *gps =NULL , *diag =NULL ; +GSList *list; + +DBG ("%s" , modem->syspath); + +for (list = modem->devices; list; list = list->next) { +struct device_info *info = list->data; + +DBG ("%s %s %s %s" , info->devnode, info->interface, + info->number, info->label); + +if (g_strcmp0 (info->label,"aux" ) ==0 ) { +DBG ("setting aux as info->devnode" ); + aux = info->devnode; +if (mdm !=NULL ) +break ; + }else if (g_strcmp0 (info->label,"modem" ) ==0 ) { + mdm = info->devnode; +if (aux !=NULL ) +break ; + }else if (g_strcmp0 (info->interface,"255/0/0" ) ==0 ) { +if (g_strcmp0 (info->number,"00" ) ==0 )
plugins/udevng.c static gboolean setup_telitqmi(struct modem_info *modem) · line 746
Quoted 10 lines
plugins/udevng.c +10
-0+ mdm = info->devnode; + else if (g_strcmp0(info->number, "01") == 0) + gps = info->devnode; + else if (g_strcmp0(info->number, "02") == 0) + aux = info->devnode; + else if (g_strcmp0(info->number, "03") == 0) + mdm = info->devnode; + } + } +
So I'm confused now. If sim800 is a serial device, why do you have all this here? Shouldn't this be handled by setup_serial_modem ?
Quoted 26 lines
plugins/udevng.c +14
-0+DBG ("modem=%s aux=%s gps=%s diag=%s" , mdm, aux, gps, diag); + +if (mdm ==NULL ) { +DBG ("modem did not set up" ); +return FALSE; + } + +ofono_modem_set_string (modem->modem,"Device" , mdm); +ofono_modem_set_string (modem->modem,"Modem" , mdm); + +return TRUE; +} +/* TODO: Not used as we have no simcom driver */ static gboolean setup_simcom (struct modem_info *modem) {@@ -1282,6 +1329,7 @@ static struct { { "telit", setup_telit, "device/interface" }, { "telitqmi", setup_telitqmi }, { "simcom", setup_simcom }, + { "sim800", setup_sim800 }, { "sim7100", setup_sim7100 }, { "zte", setup_zte }, { "icera", setup_icera },
plugins/udevng.c static struct { · line 1708
Quoted 7 lines
plugins/udevng.c +1
-0@@ -1654,6 +1702,7 @@ static struct { { "alcatel", "option", "1bbb", "0017" }, { "novatel", "option", "1410" }, { "zte", "option", "19d2" }, + { "sim800", "option", "05c6", "9000" }, { "simcom", "option", "05c6", "9000" }, { "sim7100", "option", "1e0e", "9001" }, { "telit", "usbserial", "1bc7" },
Regards,
-Denis
Hi,
Quoted 2 lines · ClémentViel
From: clem <[email protected]>
You might want to describe how this is different from sim900 that it warrants a fully separate driver?
If there are only minor differences, then this can be handled via UDEV attributes or querying +CGMM, etc.
Quoted 6 lines
--- Makefile.am | 4 + plugins/sim800.c | 424 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 428 insertions(+)create mode 100644
plugins/sim800.c
<snip>
Quoted 5 lines
plugins/sim800.c new file +5
-0+ +static void sim800_post_sim (struct ofono_modem *modem) +{ +struct sim800_data *data =ofono_modem_get_data (modem); +struct ofono_gprs *gprs;
plugins/sim800.c line 373
Quoted 10 lines
plugins/sim800.c new file +10
-0+struct ofono_gprs_context *gc; + +DBG ("%p" , modem); + +/* Dirty Hack : give some time to sim800 for multiplexing +* to be effective and avoid VOICE_DLC to be +* flooded thus leading to a "famine" situation +*/ + +sleep (2 );
No sleeps inside plugins. That blocks the entire daemon and we can't have that. How does this help you anyway? GAtChat is a queue, so only 1 command is outstanding at a time.
Quoted 4 lines
plugins/sim800.c new file +4
-0+ofono_sms_create (modem,OFONO_VENDOR_SIMCOM ,"atmodem" , + data->dlcs[SMS_DLC ]); + +
plugins/sim800.c line 387
Quoted 10 lines
plugins/sim800.c new file +10
-0+ gprs =ofono_gprs_create (modem,0 ,"atmodem" , data->dlcs[GPRS_DLC ]); +if (gprs ==NULL ) +return ; + + gc =ofono_gprs_context_create (modem,OFONO_VENDOR_SIMCOM , +"atmodem" , data->dlcs[GPRS_DLC ]); +if (gc) +ofono_gprs_add_context (gprs, gc); +} +
Regards,
-Denis
Re: [PATCH 3/3] sim800: adding documentation to inform about the udev rule the user must add
In reply to Denis KenziorQuoted 7 lines · Denis Kenzior
Hi,
Quoted 1 line · ClémentViel
From: clem <[email protected]>
Can you fix your Author information (see AUTHORS for an example). Otherwise I cannot take these...
Yep, I'll do it the right way
Quoted 16 lines
Quoted 16 lines
--- doc/sim800-modem.txt | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 doc/sim800-modem.txtdoc/sim800-modem.txt new file +3
-0@@ -0,0 +1,7 @@ +SIM800 modem usage +=================== +
Quoted 8 lines
doc/sim800-modem.txt line 7
Quoted 5 lines
doc/sim800-modem.txt new file +4
-0+To enable SIM900 module support you need to put the following +udev rule into appropriate file in /{etc,lib}/udev/rules.d: + +KERNEL=="ttyUSB0", ENV{OFONO_DRIVER}="sim800"So sim800 is a serial device right? I take it you're running it from a serial converter here?
Yes, there is a converter. I let "ttyUSB0" as the starter kit provided by SimCom comes with a converter.
Quoted 5 lines
Regards,
-Denis
Re: [PATCH 3/3] sim800: adding documentation to inform about the udev rule the user must add
On Wed, Sep 19, 2018 at 11:51:26AM -0500, Denis Kenzior wrote:
Hi,
Quoted 18 lines
Hi,
Quoted 2 lines · ClémentViel
From: clem <[email protected]>
You might want to describe how this is different from sim900 that it warrants a fully separate driver?
If there are only minor differences, then this can be handled via UDEV attributes or querying +CGMM, etc.
Quoted 6 lines
--- Makefile.am | 4 + plugins/sim800.c | 424 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 428 insertions(+) create mode 100644 plugins/sim800.c
I guess I went straightforward and because sim800 wasn't supported I wanted to add it as a plugin. Sim800 is really close from sim900, in fact theey are compatible. But because sim800 series are newer. sim800 have more AT commands than sim900 so maybe the compatibility won't be complete if the two drivers are merged...
Quoted 14 lines
<snip>
Quoted 11 lines
plugins/sim800.c new file +11
-0+ +static void sim800_post_sim (struct ofono_modem *modem) +{ +struct sim800_data *data =ofono_modem_get_data (modem); +struct ofono_gprs *gprs; +struct ofono_gprs_context *gc; + +DBG ("%p" , modem); + +/* Dirty Hack : give some time to sim800 for multiplexing +* to be effective and avoid VOICE_DLC to be
Quoted 8 lines
plugins/sim800.c line 373
Quoted 4 lines
plugins/sim800.c new file +4
-0+* flooded thus leading to a "famine" situation +*/ + +sleep (2 );No sleeps inside plugins. That blocks the entire daemon and we can't have that. How does this help you anyway? GAtChat is a queue, so only 1 command is outstanding at a time.
Yep that's why the "Dirty Hack" comment, I'll try another trick, there is an URC that we can trigger on.
Quoted 10 lines
Quoted 10 lines
plugins/sim800.c new file +9
-0+ofono_sms_create (modem,OFONO_VENDOR_SIMCOM ,"atmodem" , + data->dlcs[SMS_DLC ]); + + + gprs =ofono_gprs_create (modem,0 ,"atmodem" , data->dlcs[GPRS_DLC ]); +if (gprs ==NULL ) +return ; + + gc = ofono_gprs_context_create(modem, OFONO_VENDOR_SIMCOM,
Quoted 8 lines
plugins/sim800.c line 387
Quoted 5 lines
plugins/sim800.c new file +5
-0+ "atmodem", data->dlcs[GPRS_DLC]); +if (gc) +ofono_gprs_add_context (gprs, gc); +} +Regards,
-Denis
Regards
Clement
On Wed, Sep 19, 2018 at 08:03:27PM +0300, Pičugins Arsenijs wrote:
Hi,
I guess I submit it in a hurry and forgot to add the firmware version.
BTW, your problem may be related to this. Are you sure your CMUX command is not returning an error ? Thus preventing ofono from enabling the modem ? I had this problem and Simcom sent me an updated firmware that supports the CMUX command.
Quoted 1 line
<div>Hello!</div><div> </div><div>> You might want to describe how this is different from sim900 that it<br />> warrants a fully separate driver?</div><div> </div><div>I've tried to apply this patch yesterday evening (since I too am</div><div>interested in SIM800 integration) and tried to apply it, patch 2</div><div>doesn't apply on current master for some reason. Here's a diff</div><div>between current SIM900 and this SIM800:</div><div><a href="https://matrix.org/_matrix/media/v1/download/matrix.org/KqDxbcuYLxrcceUfRorxYgus" data-external="true">https://matrix.org/_matrix/media/v1/download/matrix.org/KqDxbcuYLxrcceUfRorxYgus</a></div><div> </div><div>tl;dr: apart from</div><div> </div><div>- adding phonebook support (two lines, I don't understand it quite yet)</div><div>- the
sleep()hack</div><div>- a comment clarifying a problem with some unknown version of firmware</div><div>-DBG()log calls</div><div>- sim900 => sim800 renaming</div><div> </div><div>it's no different than current SIM900 driver. Unfortunately, that</div><div>doesn't solve the problems I'm personally experiencing (hang on</div><div>CFUN, for one).</div><div> </div><div>Cheers!<br />Arsenijs</div><div> </div><div>19.09.2018, 19:51, "Denis Kenzior" <denkenz(a)gmail.com>:</div><blockquote type="cite"><p>Hi,<br /><br />On 09/18/2018 03:36 PM, ClémentViel wrote:</p><blockquote> From: clem <<a data-external="true" href="mailto:[email protected]">vielclement(a)gmail.com</a>><br /> </blockquote><p><br />You might want to describe how this is different from sim900 that it<br />warrants a fully separate driver?<br /><br />If there are only minor differences, then this can be handled via UDEV<br />attributes or querying +CGMM, etc.<br /> </p><blockquote> ---<br /> Makefile.am | 4 +<br /> plugins/sim800.c | 424 +++++++++++++++++++++++++++++++++++++++++++++++++++++++<br /> 2 files changed, 428 insertions(+)<br /> create mode 100644 plugins/sim800.c<br /> </blockquote><p><br /><snip><br /> </p><blockquote> +<br /> +static voidsim800_post_sim(struct ofono_modem *modem)<br /> +{<br /> + structsim800_data*data = ofono_modem_get_data(modem);<br /> + structofono_gprs*gprs;<br /> + structofono_gprs_context*gc;<br /> +<br /> +DBG("%p", modem);<br /> +<br /> + /* Dirty Hack : give some time to sim800 for multiplexing<br /> + * to be effective and avoidVOICE_DLCto be<br /> + * flooded thus leading to a "famine" situation<br /> + */<br /> +<br /> + sleep(2);</blockquote><p><br />No sleeps inside plugins. That blocks the entire daemon and we can't<br />have that. How does this help you anyway? GAtChat is a queue, so only<br />1 command is outstanding at a time.<br /> </p><blockquote> +ofono_sms_create(modem, OFONO_VENDOR_SIMCOM, "atmodem",<br /> + data->dlcs[SMS_DLC]);<br /> +<br /> +<br /> + gprs =ofono_gprs_create(modem, 0, "atmodem", data->dlcs[GPRS_DLC]);<br /> + if (gprs == NULL)<br /> + return;<br /> +<br /> + gc =ofono_gprs_context_create(modem, OFONO_VENDOR_SIMCOM,<br /> + "atmodem", data->dlcs[GPRS_DLC]);<br /> + if (gc)<br /> +ofono_gprs_add_context(gprs, gc);<br /> +}<br /> +</blockquote><p><br />Regards,<br />-Denis<br />_______________________________________________<br />ofono mailing list<br /><a data-external="true" href="mailto:[email protected]">ofono(a)ofono.org</a><br /><a href="https://lists.ofono.org/mailman/listinfo/ofono">https://lists.ofono.org/mailman/listinfo/ofono</a></p></blockquote>
Re: [PATCH 2/3] sim800: add udev detection
In reply to Denis KenziorOn Wed, Sep 19, 2018 at 11:46:34AM -0500, Denis Kenzior wrote:
Hi,
Quoted 45 lines
Hi,
Quoted 42 lines · ClémentViel
From: clem <[email protected]>
--- plugins/udevng.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)plugins/udevng.c +29
-0@@ -710,6 +710,53 @@ static gboolean setup_telitqmi(struct modem_info *modem)return TRUE; } +static gboolean setup_sim800 (struct modem_info *modem) +{ +const char *mdm =NULL , *aux =NULL , *gps =NULL , *diag =NULL ; +GSList *list; + +DBG ("%s" , modem->syspath); + +for (list = modem->devices; list; list = list->next) { +struct device_info *info = list->data; + +DBG ("%s %s %s %s" , info->devnode, info->interface, + info->number, info->label); + +if (g_strcmp0 (info->label,"aux" ) ==0 ) { +DBG ("setting aux as info->devnode" ); + aux = info->devnode; +if (mdm !=NULL ) +break ; + }else if (g_strcmp0 (info->label,"modem" ) ==0 ) { + mdm = info->devnode; +if (aux !=NULL ) +break ; + }else if (g_strcmp0 (info->interface,"255/0/0" ) ==0 ) { +if (g_strcmp0 (info->number,"00" ) ==0 ) + mdm = info->devnode; +else if (g_strcmp0 (info->number,"01" ) ==0 ) + gps = info->devnode; +else if (g_strcmp0 (info->number,"02" ) ==0 ) + aux = info->devnode;
Quoted 9 lines
plugins/udevng.c static gboolean setup_telitqmi(struct modem_info *modem) · line 746
Quoted 5 lines
plugins/udevng.c +5
-0+else if (g_strcmp0 (info->number,"03" ) ==0 ) + mdm = info->devnode; + } + } +So I'm confused now. If sim800 is a serial device, why do you have all this here? Shouldn't this be handled by
setup_serial_modem?
Because the modem was seen through a serial/USB converter, my kernel sees it as a USB device. So I used this function. Should this be coded in a more generic way ?
Quoted 25 lines
Quoted 25 lines
plugins/udevng.c +14
-0+DBG ("modem=%s aux=%s gps=%s diag=%s" , mdm, aux, gps, diag); + +if (mdm ==NULL ) { +DBG ("modem did not set up" ); +return FALSE; + } + +ofono_modem_set_string (modem->modem,"Device" , mdm); +ofono_modem_set_string (modem->modem,"Modem" , mdm); + +return TRUE; +} +/* TODO: Not used as we have no simcom driver */ static gboolean setup_simcom (struct modem_info *modem) {@@ -1282,6 +1329,7 @@ static struct { { "telit", setup_telit, "device/interface" }, { "telitqmi", setup_telitqmi }, { "simcom", setup_simcom }, + { "sim800", setup_sim800 }, { "sim7100", setup_sim7100 }, { "zte", setup_zte }, { "icera", setup_icera },@@ -1654,6 +1702,7 @@ static struct {
Quoted 8 lines
plugins/udevng.c static struct { · line 1708
Quoted 8 lines
plugins/udevng.c +1
-0{ "alcatel", "option", "1bbb", "0017" }, { "novatel", "option", "1410" }, { "zte", "option", "19d2" }, + { "sim800", "option", "05c6", "9000" }, { "simcom", "option", "05c6", "9000" }, { "sim7100", "option", "1e0e", "9001" }, { "telit", "usbserial", "1bc7" },
I must use tabs instead of spaces....I have no excuses...
Quoted 3 lines
Regards,
-Denis
Regards
Clem
Re: [PATCH 2/3] sim800: add udev detection
Hi,
Quoted 8 lines
Quoted 4 lines
So I'm confused now. If sim800 is a serial device, why do you have all this here? Shouldn't this be handled by
setup_serial_modem?Because the modem was seen through a serial/USB converter, my kernel sees it as a USB device. So I used this function. Should this be coded in a more generic way ?
Yes, you should use the setup_serial_modem bits and the UDEV rule outlined in patch 3 should take care of the detection.
Regards,
-Denis
Re: [PATCH 2/3] sim800: add udev detection
On Wed, Sep 19, 2018 at 03:03:57PM -0500, Denis Kenzior wrote:
Hi,
Quoted 7 lines
Hi,
Quoted 5 lines
Quoted 4 lines
So I'm confused now. If sim800 is a serial device, why do you have all this here? Shouldn't this be handled by
setup_serial_modem?
Quoted 7 lines
Quoted 3 lines
Because the modem was seen through a serial/USB converter, my kernel sees it as a USB device. So I used this function. Should this be coded in a more generic way ?
Yes, you should use the
setup_serial_modembits and the UDEV rule outlined in patch 3 should take care of the detection.
All right, I'll change the detection and setup in next patch set.
Quoted 2 lines
Regards,
-Denis
Regards
Clem
Re: [PATCH 3/3] sim800: adding documentation to inform about the udev rule the user must add
In reply to ClémentVielQuoted 13 lines · ClémentViel
From: clem <[email protected]>
--- doc/sim800-modem.txt | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 doc/sim800-modem.txtdoc/sim800-modem.txt new file +0
-0
doc/sim800-modem.txt line 4
Quoted 4 lines
doc/sim800-modem.txt new file +4
-0@@ -0,0 +1,7 @@ +SIM800 modem usage +=================== + +To enable SIM900 module support you need to put the following
Is there typo and this should say SIM800?
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html