Hi! 

I'll get started to test patch that sended by Anthony in previous email. 
Patch have some errors, but I'm fix it.

renat@zaripov:~/work/ofono$ patch -p 1 < ../simcom.patch 
patching file Makefile.am
Hunk #1 succeeded at 407 (offset 36 lines).
patching file drivers/atmodem/sms.c
patching file drivers/atmodem/sim.c
Hunk #1 FAILED at 1023.
1 out of 1 hunk FAILED -- saving rejects to file drivers/atmodem/sim.c.rej
patching file drivers/atmodem/network-registration.c
Hunk #1 succeeded at 1740 (offset 329 lines).
Hunk #2 succeeded at 1893 (offset 351 lines).
patching file plugins/simcom.c

Build done successfully, and udev pick simcom plugin for sim900:

root@zaripov:/home/renat/work/ofono/src# export OFONO_AT_DEBUG=1 && ./ofonod -nd "*"
ofonod[17539]: oFono version 1.12
ofonod[17539]: src/plugin.c:__ofono_plugin_init() 
ofonod[17539]: plugins/push-notification.c:push_notification_init() 
ofonod[17539]: plugins/smart-messaging.c:smart_messaging_init() 
ofonod[17539]: src/modem.c:ofono_modem_driver_register() driver: 0x8194e40, name: stktest
ofonod[17539]: src/modem.c:ofono_modem_create() name: stktest, type: stktest
ofonod[17539]: src/modem.c:ofono_modem_register() 0x9c99f40
ofonod[17539]: plugins/stktest.c:stktest_probe() 0x9c99f40
ofonod[17539]: src/modem.c:emit_modem_added() 0x9c99f40
ofonod[17539]: src/modem.c:call_modemwatches() 0x9c99f40 added:1
ofonod[17539]: plugins/smart-messaging.c:modem_watch() modem: 0x9c99f40, added: 1
ofonod[17539]: plugins/push-notification.c:modem_watch() modem: 0x9c99f40, added: 1
ofonod[17539]: examples/emulator.c:example_emulator_init() 
ofonod[17539]: examples/emulator.c:modem_watch() modem: 0x9c99f40, added: 1
ofonod[17539]: src/gprs-provision.c:ofono_gprs_provision_driver_register() driver: 0x8194da0 name: Example GPRS context provisioning
ofonod[17539]: src/nettime.c:ofono_nettime_driver_register() driver: 0x8194d60 name: Example Network Time
ofonod[17539]: src/history.c:ofono_history_driver_register() driver: 0x8194d20 name: Example Call History
ofonod[17539]: src/cdma-provision.c:ofono_cdma_provision_driver_register() driver: 0x8194ce0 name: CDMA provisioning
ofonod[17539]: src/gprs-provision.c:ofono_gprs_provision_driver_register() driver: 0x8194ca0 name: Provisioning
ofonod[17539]: plugins/connman.c:connman_init() 
ofonod[17539]: src/private-network.c:ofono_private_network_driver_register() driver: 0x8194c60, name: ConnMan Private Network
ofonod[17539]: plugins/dun_gw.c:dun_gw_init() 
ofonod[17539]: plugins/dun_gw.c:modem_watch() modem: 0x9c99f40, added: 1
ofonod[17539]: plugins/hfp_ag.c:modem_watch() modem: 0x9c99f40, added: 1
ofonod[17539]: src/modem.c:ofono_modem_driver_register() driver: 0x8194ba0, name: hfp
ofonod[17539]: src/modem.c:ofono_modem_driver_register() driver: 0x8194b40, name: sap
ofonod[17539]: src/modem.c:ofono_modem_driver_register() driver: 0x8194ac0, name: telit
ofonod[17539]: src/modem.c:ofono_modem_driver_register() driver: 0x81949c0, name: sim900
ofonod[17539]: src/modem.c:ofono_modem_driver_register() driver: 0x8194960, name: samsung
ofonod[17539]: src/modem.c:ofono_modem_driver_register() driver: 0x8194900, name: speedupcdma
ofonod[17539]: src/modem.c:ofono_modem_driver_register() driver: 0x81948a0, name: speedup
ofonod[17539]: src/modem.c:ofono_modem_driver_register() driver: 0x8194840, name: alcatel
ofonod[17539]: src/modem.c:ofono_modem_driver_register() driver: 0x81947e0, name: icera
ofonod[17539]: src/modem.c:ofono_modem_driver_register() driver: 0x8194780, name: linktop
ofonod[17539]: src/modem.c:ofono_modem_driver_register() driver: 0x8194720, name: nokiacdma
ofonod[17539]: src/modem.c:ofono_modem_driver_register() driver: 0x81946c0, name: nokia
ofonod[17539]: src/modem.c:ofono_modem_driver_register() driver: 0x8194660, name: tc65
ofonod[17539]: src/modem.c:ofono_modem_driver_register() driver: 0x81945c0, name: ste
ofonod[17539]: src/modem.c:ofono_modem_driver_register() driver: 0x8194560, name: ifx
ofonod[17539]: src/modem.c:ofono_modem_driver_register() driver: 0x8194500, name: palmpre
ofonod[17539]: src/modem.c:ofono_modem_driver_register() driver: 0x81944a0, name: novatel
ofonod[17539]: src/modem.c:ofono_modem_driver_register() driver: 0x8194440, name: sierra
ofonod[17539]: src/modem.c:ofono_modem_driver_register() driver: 0x81943c0, name: huawei
ofonod[17539]: src/modem.c:ofono_modem_driver_register() driver: 0x8194360, name: zte
ofonod[17539]: src/modem.c:ofono_modem_driver_register() driver: 0x8194300, name: hso
ofonod[17539]: src/modem.c:ofono_modem_driver_register() driver: 0x81942a0, name: mbm
ofonod[17539]: src/modem.c:ofono_modem_driver_register() driver: 0x8194240, name: calypso
ofonod[17539]: src/modem.c:ofono_modem_driver_register() driver: 0x81941e0, name: wavecom
ofonod[17539]: src/modem.c:ofono_modem_driver_register() driver: 0x8194180, name: g1
ofonod[17539]: src/cdma-voicecall.c:ofono_cdma_voicecall_driver_register() driver: 0x8194100, name: cdmamodem
ofonod[17539]: src/modem.c:ofono_devinfo_driver_register() driver: 0x8194120, name: cdmamodem
ofonod[17539]: src/cdma-connman.c:ofono_cdma_connman_driver_register() driver: 0x8194144, name: cdmamodem
ofonod[17539]: src/modem.c:ofono_modem_driver_register() driver: 0x8194060, name: phonesim
ofonod[17539]: src/modem.c:ofono_modem_driver_register() driver: 0x81940a0, name: localhfp
ofonod[17539]: src/gprs.c:ofono_gprs_context_driver_register() driver: 0x8194034, name: phonesim
ofonod[17539]: src/ctm.c:ofono_ctm_driver_register() driver: 0x8194020, name: phonesim
ofonod[17539]: plugins/phonesim.c:parse_config() filename /etc/ofono/phonesim.conf
ofonod[17539]: Reading of /etc/ofono/phonesim.conf failed: No such file or directory
ofonod[17539]: src/ussd.c:ofono_ussd_driver_register() driver: 0x8193fe0, name: speedupmodem
ofonod[17539]: src/voicecall.c:ofono_voicecall_driver_register() driver: 0x8193ec0, name: hfpmodem
ofonod[17539]: src/modem.c:ofono_devinfo_driver_register() driver: 0x8193f7c, name: hfpmodem
ofonod[17539]: src/network.c:ofono_netreg_driver_register() driver: 0x8193f20, name: hfpmodem
ofonod[17539]: src/call-volume.c:ofono_call_volume_driver_register() driver: 0x8193f54, name: hfpmodem
ofonod[17539]: src/handsfree.c:ofono_handsfree_driver_register() driver: 0x8193f98, name: hfpmodem
ofonod[17539]: src/network.c:ofono_netreg_driver_register() driver: 0x8193e40, name: dunmodem
ofonod[17539]: src/gprs.c:ofono_gprs_driver_register() driver: 0x8193e6c, name: dunmodem
ofonod[17539]: src/voicecall.c:ofono_voicecall_driver_register() driver: 0x8193d60, name: stemodem
ofonod[17539]: src/gprs.c:ofono_gprs_context_driver_register() driver: 0x8193dec, name: stemodem
ofonod[17539]: src/radio-settings.c:ofono_radio_settings_driver_register() driver: 0x8193dc0, name: stemodem
ofonod[17539]: src/voicecall.c:ofono_voicecall_driver_register() driver: 0x8193c20, name: ifxmodem
ofonod[17539]: src/audio-settings.c:ofono_audio_settings_driver_register() driver: 0x8193c70, name: ifxmodem
ofonod[17539]: src/radio-settings.c:ofono_radio_settings_driver_register() driver: 0x8193ca0, name: ifxmodem
ofonod[17539]: src/gprs.c:ofono_gprs_context_driver_register() driver: 0x8193ccc, name: ifxmodem
ofonod[17539]: src/stk.c:ofono_stk_driver_register() driver: 0x8193cf4, name: ifxmodem
ofonod[17539]: src/ctm.c:ofono_ctm_driver_register() driver: 0x8193d1c, name: ifxmodem
ofonod[17539]: src/gprs.c:ofono_gprs_context_driver_register() driver: 0x8193ba0, name: hsomodem
ofonod[17539]: src/radio-settings.c:ofono_radio_settings_driver_register() driver: 0x8193bc0, name: hsomodem
ofonod[17539]: src/gprs.c:ofono_gprs_context_driver_register() driver: 0x8193b00, name: mbmmodem
ofonod[17539]: src/stk.c:ofono_stk_driver_register() driver: 0x8193b28, name: mbmmodem
ofonod[17539]: src/location-reporting.c:ofono_location_reporting_driver_register() driver: 0x8193b48, name: mbmmodem
ofonod[17539]: src/voicecall.c:ofono_voicecall_driver_register() driver: 0x8193a60, name: calypsomodem
ofonod[17539]: src/stk.c:ofono_stk_driver_register() driver: 0x8193aa8, name: calypsomodem
ofonod[17539]: src/ussd.c:ofono_ussd_driver_register() driver: 0x8193940, name: huaweimodem
ofonod[17539]: src/voicecall.c:ofono_voicecall_driver_register() driver: 0x8193960, name: huaweimodem
ofonod[17539]: src/audio-settings.c:ofono_audio_settings_driver_register() driver: 0x81939a8, name: huaweimodem
ofonod[17539]: src/radio-settings.c:ofono_radio_settings_driver_register() driver: 0x81939e0, name: huaweimodem
ofonod[17539]: src/gprs.c:ofono_gprs_context_driver_register() driver: 0x81939bc, name: huaweimodem
ofonod[17539]: src/cdma-netreg.c:ofono_cdma_netreg_driver_register() driver: 0x8193a0c, name: huaweimodem
ofonod[17539]: src/gprs.c:ofono_gprs_context_driver_register() driver: 0x81938a0, name: iceramodem
ofonod[17539]: src/radio-settings.c:ofono_radio_settings_driver_register() driver: 0x81938e0, name: iceramodem
ofonod[17539]: src/radio-settings.c:ofono_radio_settings_driver_register() driver: 0x8193840, name: ztemodem
ofonod[17539]: src/gprs.c:ofono_gprs_context_driver_register() driver: 0x8193800, name: swmodem
ofonod[17539]: src/radio-settings.c:ofono_radio_settings_driver_register() driver: 0x81937a0, name: nwmodem
ofonod[17539]: src/voicecall.c:ofono_voicecall_driver_register() driver: 0x8193600, name: atmodem
ofonod[17539]: src/modem.c:ofono_devinfo_driver_register() driver: 0x81936a0, name: atmodem
ofonod[17539]: src/call-barring.c:ofono_call_barring_driver_register() driver: 0x8193658, name: atmodem
ofonod[17539]: src/call-forwarding.c:ofono_call_forwarding_driver_register() driver: 0x81933a0, name: atmodem
ofonod[17539]: src/call-meter.c:ofono_call_meter_driver_register() driver: 0x81933e0, name: atmodem
ofonod[17539]: src/call-settings.c:ofono_call_settings_driver_register() driver: 0x81932a0, name: atmodem
ofonod[17539]: src/phonebook.c:ofono_phonebook_driver_register() driver: 0x8193678, name: atmodem
ofonod[17539]: src/ussd.c:ofono_ussd_driver_register() driver: 0x81935d4, name: atmodem
ofonod[17539]: src/sms.c:ofono_sms_driver_register() driver: 0x8193320, name: atmodem
ofonod[17539]: src/sim.c:ofono_sim_driver_register() driver: 0x81934a0, name: atmodem
ofonod[17539]: src/sim.c:ofono_sim_driver_register() driver: 0x8193500, name: atmodem-noef
ofonod[17539]: src/stk.c:ofono_stk_driver_register() driver: 0x81935b4, name: atmodem
ofonod[17539]: src/network.c:ofono_netreg_driver_register() driver: 0x8193440, name: atmodem
ofonod[17539]: src/cbs.c:ofono_cbs_driver_register() driver: 0x8193380, name: atmodem
ofonod[17539]: src/call-volume.c:ofono_call_volume_driver_register() driver: 0x81936c4, name: atmodem
ofonod[17539]: src/gprs.c:ofono_gprs_driver_register() driver: 0x81936f4, name: atmodem
ofonod[17539]: src/gprs.c:ofono_gprs_context_driver_register() driver: 0x8193718, name: atmodem
ofonod[17539]: src/sim-auth.c:ofono_sim_auth_driver_register() driver: 0x8193730, name: atmodem
ofonod[17539]: src/gnss.c:ofono_gnss_driver_register() driver: 0x8193748, name: atmodem
ofonod[17539]: src/modem.c:ofono_modem_driver_register() driver: 0x8193080, name: gobi
ofonod[17539]: src/modem.c:ofono_devinfo_driver_register() driver: 0x8192e40, name: qmimodem
ofonod[17539]: src/network.c:ofono_netreg_driver_register() driver: 0x8192ec0, name: qmimodem
ofonod[17539]: src/voicecall.c:ofono_voicecall_driver_register() driver: 0x8192e60, name: qmimodem
ofonod[17539]: src/sim.c:ofono_sim_driver_register() driver: 0x8192f00, name: qmimodem-legacy
ofonod[17539]: src/sim.c:ofono_sim_driver_register() driver: 0x8192f60, name: qmimodem
ofonod[17539]: src/sms.c:ofono_sms_driver_register() driver: 0x8192fc0, name: qmimodem
ofonod[17539]: src/ussd.c:ofono_ussd_driver_register() driver: 0x8192fe0, name: qmimodem
ofonod[17539]: src/gprs.c:ofono_gprs_driver_register() driver: 0x8192ff4, name: qmimodem
ofonod[17539]: src/gprs.c:ofono_gprs_context_driver_register() driver: 0x8193008, name: qmimodem
ofonod[17539]: src/radio-settings.c:ofono_radio_settings_driver_register() driver: 0x8193020, name: qmimodem
ofonod[17539]: src/location-reporting.c:ofono_location_reporting_driver_register() driver: 0x8193044, name: qmimodem
ofonod[17539]: src/modem.c:ofono_modem_driver_register() driver: 0x8192de0, name: u8500
ofonod[17539]: src/modem.c:ofono_devinfo_driver_register() driver: 0x8192dc0, name: u8500
ofonod[17539]: src/modem.c:ofono_modem_driver_register() driver: 0x8192d60, name: n900
ofonod[17539]: src/modem.c:ofono_modem_driver_register() driver: 0x8192d00, name: isiusb
ofonod[17539]: src/modem.c:ofono_devinfo_driver_register() driver: 0x81929f0, name: isimodem
ofonod[17539]: src/phonebook.c:ofono_phonebook_driver_register() driver: 0x81929e0, name: isimodem
ofonod[17539]: src/network.c:ofono_netreg_driver_register() driver: 0x8192a20, name: isimodem
ofonod[17539]: src/voicecall.c:ofono_voicecall_driver_register() driver: 0x8192a60, name: isimodem
ofonod[17539]: src/sms.c:ofono_sms_driver_register() driver: 0x8192ac0, name: isimodem
ofonod[17539]: src/cbs.c:ofono_cbs_driver_register() driver: 0x8192ae0, name: isimodem
ofonod[17539]: src/sim.c:ofono_sim_driver_register() driver: 0x8192b00, name: isimodem
ofonod[17539]: src/ussd.c:ofono_ussd_driver_register() driver: 0x8192b48, name: isimodem
ofonod[17539]: src/call-forwarding.c:ofono_call_forwarding_driver_register() driver: 0x8192b60, name: isimodem
ofonod[17539]: src/call-settings.c:ofono_call_settings_driver_register() driver: 0x8192b80, name: isimodem
ofonod[17539]: src/call-barring.c:ofono_call_barring_driver_register() driver: 0x8192bb0, name: isimodem
ofonod[17539]: src/call-meter.c:ofono_call_meter_driver_register() driver: 0x8192be0, name: isimodem
ofonod[17539]: src/radio-settings.c:ofono_radio_settings_driver_register() driver: 0x8192c20, name: isimodem
ofonod[17539]: src/gprs.c:ofono_gprs_driver_register() driver: 0x8192c44, name: isimodem
ofonod[17539]: src/gprs.c:ofono_gprs_context_driver_register() driver: 0x8192c58, name: isimodem
ofonod[17539]: src/audio-settings.c:ofono_audio_settings_driver_register() driver: 0x8192c70, name: isimodem
ofonod[17539]: src/sim.c:ofono_sim_driver_register() driver: 0x8192c80, name: wgmodem2.5
ofonod[17539]: plugins/udevng.c:udev_start() 
ofonod[17539]: plugins/udevng.c:enumerate_devices() 
ofonod[17539]: plugins/udevng.c:check_usb_device() hub [(null):(null)]
ofonod[17539]: plugins/udevng.c:check_usb_device() usb [8087:0020]
ofonod[17539]: plugins/udevng.c:check_usb_device() usb [1a40:0101]
ofonod[17539]: plugins/udevng.c:check_usb_device() usb [067b:2303]
ofonod[17539]: plugins/udevng.c:check_usb_device() pl2303 [(null):(null)]
ofonod[17539]: plugins/udevng.c:check_usb_device() pl2303 [067b:2303]
ofonod[17539]: plugins/udevng.c:check_usb_device() usb [067b:2303]
ofonod[17539]: plugins/udevng.c:check_usb_device() pl2303 [(null):(null)]
ofonod[17539]: plugins/udevng.c:check_usb_device() pl2303 [067b:2303]
ofonod[17539]: plugins/udevng.c:check_usb_device() hub [(null):(null)]
ofonod[17539]: plugins/udevng.c:check_usb_device() usb [0409:005a]
ofonod[17539]: plugins/udevng.c:check_usb_device() usb [058f:6254]
ofonod[17539]: plugins/udevng.c:check_usb_device() usb [058f:6366]
ofonod[17539]: plugins/udevng.c:check_usb_device() usb-storage [(null):(null)]
ofonod[17539]: plugins/udevng.c:check_usb_device() hub [(null):(null)]
ofonod[17539]: plugins/udevng.c:check_usb_device() hub [(null):(null)]
ofonod[17539]: plugins/udevng.c:check_usb_device() usb [046d:c05a]
ofonod[17539]: plugins/udevng.c:check_usb_device() usbhid [(null):(null)]
ofonod[17539]: plugins/udevng.c:check_usb_device() usb [045e:00db]
ofonod[17539]: plugins/udevng.c:check_usb_device() usbhid [(null):(null)]
ofonod[17539]: plugins/udevng.c:check_usb_device() usbhid [(null):(null)]
ofonod[17539]: plugins/udevng.c:check_usb_device() hub [(null):(null)]
ofonod[17539]: plugins/udevng.c:check_usb_device() hub [(null):(null)]
ofonod[17539]: plugins/udevng.c:check_usb_device() usb [8087:0020]
ofonod[17539]: plugins/udevng.c:check_usb_device() usb [0403:6010]
ofonod[17539]: plugins/udevng.c:check_usb_device() ftdi_sio [(null):(null)]
ofonod[17539]: plugins/udevng.c:check_usb_device() ftdi_sio [0403:6010]
ofonod[17539]: plugins/udevng.c:check_usb_device() ftdi_sio [(null):(null)]
ofonod[17539]: plugins/udevng.c:check_usb_device() ftdi_sio [0403:6010]
ofonod[17539]: plugins/udevng.c:check_usb_device() hub [(null):(null)]
ofonod[17539]: src/modem.c:ofono_modem_create() name: (null), type: simcom
ofonod[17539]: src/modem.c:set_modem_property() modem 0x9ca15b8 property Path
ofonod[17539]: plugins/udev.c:add_modem() /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.6/2-1.6:1.1/ttyUSB3/tty/ttyUSB3 (simcom)
ofonod[17539]: src/private-network.c:ofono_private_network_driver_register() driver: 0x8194e00, name: Example Private Network Driver
ofonod[17539]: plugins/bluetooth.c:manager_properties_cb() 
ofonod[17539]: plugins/bluetooth.c:parse_adapters() 

But any simcom device is not available via list-modems:

renat@zaripov:~/work/ofono$ test/list-modems 
[ /stktest ]
    Features = 
    Emergency = 0
    Powered = 0
    Lockdown = 0
    Interfaces = 
    Online = 0
    Type = test

Any ideas why that happened?

Best regards,
Renat Zaripov


2013/1/24 Anthony Viallard <viallard@syscom-instruments.com>
Add SIMCOM support.

I developped this with the SIM5216E chipset.

SMS and GPRS work. I don't add voice part because i don't use it so
can't test it.

Signed-off-by: Anthony Viallard <homer242 at gmail.com>
--- ofono-1.6.orig/Makefile.am  2012-04-20 21:06:29.000000000 +0200
+++ ofono-1.6/Makefile.am       2013-01-21 17:17:48.089627277 +0100
@@ -371,6 +371,9 @@ builtin_sources += plugins/samsung.c
 builtin_modules += sim900
 builtin_sources += plugins/sim900.c

+builtin_modules += simcom
+builtin_sources += plugins/simcom.c
+
 if BLUETOOTH
 builtin_modules += bluetooth
 builtin_sources += plugins/bluetooth.c plugins/bluetooth.h
--- ofono-1.6.orig/drivers/atmodem/sms.c        2012-04-20 21:06:29.000000000 +0200
+++ ofono-1.6/drivers/atmodem/sms.c     2013-01-21 16:48:44.460627485 +0100
@@ -805,6 +807,7 @@ static gboolean build_cnmi_string(char *
        case OFONO_VENDOR_NOVATEL:
        case OFONO_VENDOR_HUAWEI:
        case OFONO_VENDOR_ZTE:
+       case OFONO_VENDOR_SIMCOM:
                /* MSM devices advertise support for mode 2, but return an
                 * error if we attempt to actually use it. */
                mode = "1";
diff -pruN ofono-1.6.orig/drivers/atmodem/sim.c ofono-1.6/drivers/atmodem/sim.c
--- ofono-1.6.orig/drivers/atmodem/sim.c        2013-01-23 11:38:22.959609087 +0100
+++ ofono-1.6/drivers/atmodem/sim.c     2013-01-23 11:57:52.602608948 +0100
@@ -1023,10 +1023,16 @@ static void at_pin_send_cb(gboolean ok,
                                                        FALSE, cbd, g_free);
                return;
        case OFONO_VENDOR_ZTE:
+       case OFONO_VENDOR_SIMCOM:
                /*
                 * On ZTE modems, after pin is entered, SIM state is checked
                 * by polling CPIN as their modem doesn't provide unsolicited
                 * notification of SIM readiness.
+                *
+                * On SIMCOM modems, SIM is busy after pin is entered (we've
+                * got an "+CME ERROR: 14" at "AT+CPIN?" request) and ofono
+                * don't catch the "+CPIN: READY" message sent by the modem
+                * when SIM is ready. So, use extra CPIN to check the state.
                 */
                sd->sim_state_query = at_util_sim_state_query_new(sd->chat,
                                                2, 20, sim_state_cb, cbd,
diff -purN ofono-1.6/drivers/atmodem/network-registration.c ofono-patched/drivers/atmodem/network-registration.c
--- ofono-1.6/drivers/atmodem/network-registration.c    2013-01-18 15:04:03.598659165 +0100
+++ ofono-patched/drivers/atmodem/network-registration.c        2013-01-18 14:54:03.256659236 +0100
@@ -1411,6 +1411,14 @@ static void at_creg_set_cb(gboolean ok,
        }

        switch (nd->vendor) {
+       case OFONO_VENDOR_SIMCOM:
+               /* Register for CSQ changes */
+               g_at_chat_send(nd->chat, "AT+AUTOCSQ=1,1", none_prefix,
+                               NULL, NULL, NULL);
+
+               g_at_chat_register(nd->chat, "+CSQ:",
+                                  csq_notify, FALSE, netreg, NULL);
+               break;
        case OFONO_VENDOR_PHONESIM:
                g_at_chat_register(nd->chat, "+CSQ:",
                                        csq_notify, FALSE, netreg, NULL);
@@ -1534,7 +1537,6 @@ static void at_creg_set_cb(gboolean ok,
                break;
        case OFONO_VENDOR_NOKIA:
        case OFONO_VENDOR_SAMSUNG:
-       case OFONO_VENDOR_SIMCOM:
                /* Signal strength reporting via CIND is not supported */
                break;
        default:
--- /dev/null   2013-01-16 10:54:41.551089567 +0100
+++ ofono-1.6/plugins/simcom.c  2013-01-23 10:43:05.631609483 +0100
@@ -0,0 +1,308 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2011  Intel Corporation. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <errno.h>
+#include <stdlib.h>
+
+#include <glib.h>
+#include <gatchat.h>
+#include <gattty.h>
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+#include <ofono/plugin.h>
+#include <ofono/modem.h>
+#include <ofono/devinfo.h>
+#include <ofono/netreg.h>
+#include <ofono/sim.h>
+#include <ofono/cbs.h>
+#include <ofono/sms.h>
+#include <ofono/ussd.h>
+#include <ofono/gprs.h>
+#include <ofono/gprs-context.h>
+#include <ofono/radio-settings.h>
+#include <ofono/phonebook.h>
+#include <ofono/log.h>
+
+#include <drivers/atmodem/atutil.h>
+#include <drivers/atmodem/vendor.h>
+
+static const char *none_prefix[] = { NULL };
+
+struct simcom_data {
+       GAtChat *modem;
+       GAtChat *data;
+};
+
+/* Callback and helpers functions */
+static void simcom_debug(const char *str, void *user_data)
+{
+       const char *prefix = user_data;
+
+       ofono_info("%s%s", prefix, str);
+}
+
+static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
+{
+       struct ofono_modem *modem = user_data;
+       struct simcom_data *data = ofono_modem_get_data(modem);
+
+       DBG("");
+
+       if (!ok) {
+               g_at_chat_unref(data->modem);
+               data->modem = NULL;
+
+               g_at_chat_unref(data->data);
+               data->data = NULL;
+
+               ofono_modem_set_powered(modem, FALSE);
+               return;
+       }
+
+       ofono_modem_set_powered(modem, TRUE);
+}
+
+static void cfun_disable(gboolean ok, GAtResult *result, gpointer user_data)
+{
+       struct ofono_modem *modem = user_data;
+       struct simcom_data *data = ofono_modem_get_data(modem);
+
+       DBG("");
+
+       g_at_chat_unref(data->data);
+       data->data = NULL;
+
+       if (ok)
+               ofono_modem_set_powered(modem, FALSE);
+}
+
+static GAtChat *open_device(struct ofono_modem *modem,
+                           const char *key,
+                           char *debug)
+{
+       const char *device;
+       GIOChannel *channel;
+       GAtSyntax *syntax;
+       GAtChat *chat;
+       /* GHashTable *options; */
+
+       device = ofono_modem_get_string(modem, key);
+       if (device == NULL)
+               return NULL;
+
+       DBG("%s %s", key, device);
+
+       /* options = g_hash_table_new(g_str_hash, g_str_equal); */
+       /* if (options == NULL) */
+       /*      return NULL; */
+
+       /* g_hash_table_insert(options, "Baud", "115200"); */
+       /* g_hash_table_insert(options, "Parity", "none"); */
+       /* g_hash_table_insert(options, "StopBits", "1"); */
+       /* g_hash_table_insert(options, "DataBits", "8"); */
+       /* g_hash_table_insert(options, "XonXoff", "off"); */
+       /* g_hash_table_insert(options, "RtsCts", "on"); */
+       /* g_hash_table_insert(options, "Local", "on"); */
+       /* g_hash_table_insert(options, "Read", "on"); */
+
+       channel = g_at_tty_open(device, NULL);
+
+       /* g_hash_table_destroy(options); */
+
+       if (channel == NULL)
+               return NULL;
+
+       syntax = g_at_syntax_new_gsm_permissive();
+       chat = g_at_chat_new(channel, syntax);
+       g_at_syntax_unref(syntax);
+
+       g_io_channel_unref(channel);
+
+       if (chat == NULL)
+               return NULL;
+
+       if (getenv("OFONO_AT_DEBUG"))
+               g_at_chat_set_debug(chat, simcom_debug, debug);
+
+       return chat;
+}
+
+/* Modem interface function */
+static int simcom_probe(struct ofono_modem *modem)
+{
+       struct simcom_data *data;
+
+       DBG("%p", modem);
+
+       data = g_try_new0(struct simcom_data, 1);
+       if (data == NULL)
+               return -ENOMEM;
+
+       ofono_modem_set_data(modem, data);
+
+       return 0;
+}
+
+static void simcom_remove(struct ofono_modem *modem)
+{
+       struct simcom_data *data = ofono_modem_get_data(modem);
+
+       DBG("%p", modem);
+
+       ofono_modem_set_data(modem, NULL);
+
+       /* Cleanup after hot-unplug */
+       g_at_chat_unref(data->data);
+
+       g_free(data);
+}
+
+static int simcom_enable(struct ofono_modem *modem)
+{
+       struct simcom_data *data = ofono_modem_get_data(modem);
+
+       DBG("%p", modem);
+
+       data->modem = open_device(modem, "Modem", "Modem: ");
+       if (data->modem == NULL)
+               return -EINVAL;
+
+       data->data = open_device(modem, "Data", "Data: ");
+       if (data->data == NULL) {
+               g_at_chat_unref(data->modem);
+               data->modem = NULL;
+               return -EIO;
+       }
+
+       g_at_chat_set_slave(data->modem, data->data);
+
+       g_at_chat_blacklist_terminator(data->data,
+                                       G_AT_CHAT_TERMINATOR_NO_CARRIER);
+
+       /* init modem */
+       g_at_chat_send(data->modem, "ATE0 +CMEE=1", NULL, NULL, NULL, NULL);
+       g_at_chat_send(data->data, "ATE0 +CMEE=1", NULL, NULL, NULL, NULL);
+
+       g_at_chat_send(data->data, "AT+CFUN=1", none_prefix,
+                      cfun_enable, modem, NULL);
+
+       return -EINPROGRESS;
+}
+
+static int simcom_disable(struct ofono_modem *modem)
+{
+       struct simcom_data *data = ofono_modem_get_data(modem);
+
+       DBG("%p", modem);
+
+       g_at_chat_cancel_all(data->modem);
+       g_at_chat_unregister_all(data->modem);
+
+       g_at_chat_unref(data->modem);
+       data->modem = NULL;
+
+       g_at_chat_cancel_all(data->data);
+       g_at_chat_unregister_all(data->data);
+
+       g_at_chat_send(data->data, "AT+CFUN=4", none_prefix,
+                      cfun_disable, modem, NULL);
+
+       return -EINPROGRESS;
+}
+
+static void simcom_pre_sim(struct ofono_modem *modem)
+{
+       struct simcom_data *data = ofono_modem_get_data(modem);
+       struct ofono_sim *sim;
+
+       DBG("%p", modem);
+
+       ofono_devinfo_create(modem, 0, "atmodem", data->data);
+       sim = ofono_sim_create(modem, OFONO_VENDOR_SIMCOM, "atmodem",
+                               data->data);
+
+       if (sim)
+               ofono_sim_inserted_notify(sim, TRUE);
+}
+
+static void simcom_post_sim(struct ofono_modem *modem)
+{
+       struct simcom_data *data = ofono_modem_get_data(modem);
+       struct ofono_message_waiting *mw;
+       struct ofono_gprs *gprs;
+       struct ofono_gprs_context *gc;
+
+       DBG("%p", modem);
+
+       ofono_phonebook_create(modem, 0, "atmodem", data->data);
+
+       ofono_sms_create(modem, OFONO_VENDOR_SIMCOM, "atmodem",
+                               data->data);
+
+       /* gprs things */
+       gprs = ofono_gprs_create(modem, 0, "atmodem", data->data);
+       gc = ofono_gprs_context_create(modem, 0, "atmodem", data->modem);
+
+       if(gprs && gc)
+       {
+               ofono_gprs_add_context(gprs, gc);
+       }
+}
+
+static void simcom_post_online(struct ofono_modem *modem)
+{
+       struct simcom_data *data = ofono_modem_get_data(modem);
+
+       DBG("%p", modem);
+
+       ofono_netreg_create(modem, OFONO_VENDOR_SIMCOM, "atmodem", data->data);
+       ofono_cbs_create(modem, 0, "atmodem", data->data);
+       ofono_ussd_create(modem, 0, "atmodem", data->data);
+}
+
+static struct ofono_modem_driver simcom_driver = {
+       .name           = "simcom",
+       .probe          = simcom_probe,
+       .remove         = simcom_remove,
+       .enable         = simcom_enable,
+       .disable        = simcom_disable,
+       .pre_sim        = simcom_pre_sim,
+       .post_sim       = simcom_post_sim,
+       .post_online    = simcom_post_online,
+};
+
+static int simcom_init(void)
+{
+       return ofono_modem_driver_register(&simcom_driver);
+}
+
+static void simcom_exit(void)
+{
+       ofono_modem_driver_unregister(&simcom_driver);
+}
+
+OFONO_PLUGIN_DEFINE(simcom, "SIMCOM modem driver", VERSION,
+                   OFONO_PLUGIN_PRIORITY_DEFAULT,
+                   simcom_init, simcom_exit)
_______________________________________________
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono