Add AT commands handler in emulator
cover Add AT commands handler in emulator
Hi,
This series of patches implements a skeleton for handling AT commands. These handlers can be local to emulator or stored in a specific atom (e.g. gprs). Registration mechanism is subject to change.
Olivier Guiter (2):
gprs:Add code to handle AT+CGDCONT
emulator: Add +CGMI and +CGDCONT commands
include/emulator.h | 7 +++++- include/gprs.h | 2 + src/emulator.c | 28 +++++++++++++++++++--- src/gprs.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 95 insertions(+), 5 deletions(-)
PATCH 1/2 gprs:Add code to handle AT+CGDCONT
--- include/gprs.h | 2 + src/gprs.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 0 deletions(-)
include/gprs.h +2 -0
@@ -73,6 +73,8 @@ void ofono_gprs_remove(struct ofono_gprs *gprs);void ofono_gprs_set_data (struct ofono_gprs *gprs,void *data);void *ofono_gprs_get_data (struct ofono_gprs *gprs); +void ofono_gprs_add_emulator_handler (void *user); +void ofono_gprs_set_cid_range (struct ofono_gprs *gprs,unsigned int min,unsigned int max); void ofono_gprs_add_context(struct ofono_gprs *gprs,
src/gprs.c +63 -0
72 lines not on this page · raw message
Signature · 1 line
1.7.1
Re: [PATCH 1/2] gprs:Add code to handle AT+CGDCONT
Hi Olivier,
Quoted 5 lines · Olivier Guiter
--- include/gprs.h | 2 + src/gprs.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 0 deletions(-)
So I went in a slightly different direction with the emulator API. Can you please have a look?
Also, I'd really rather hold off trying to implement CGDCONT right now.
That piece is quite nasty and generally of lower priority. I'd like to
get the emulator a bit more hashed out first and implement the base BT DUN & BT HFP profiles.
Regards,
-Denis
Re: [PATCH 1/2] gprs:Add code to handle AT+CGDCONT
Hi Denis,
Quoted 6 lines
Quoted 5 lines
--- include/gprs.h | 2 + src/gprs.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 0 deletions(-)
Quoted 7 lines
So I went in a slightly different direction with the emulator API. Can you please have a look?
Also, I'd really rather hold off trying to implement CGDCONT right now.
That piece is quite nasty and generally of lower priority. I'd like to
get the emulator a bit more hashed out first and implement the base BT DUN & BT HFP profiles.
for the sake of testing, I would be fine with the real basic CGDCONT and just offering IP and CID 1. And then of course accepting any APN in that range and rejecting any other command.
Regards
Marcel
Re: [PATCH 1/2] gprs:Add code to handle AT+CGDCONT
Hi Denis and Marcel,
Quoted 9 lines
Hi Denis,
Quoted 7 lines
Quoted 4 lines
--- include/gprs.h | 2 + src/gprs.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 0 deletions(-)So I went in a slightly different direction with the emulator API. Can you please have a look?
Quoted 7 lines
Quoted 4 lines
Also, I'd really rather hold off trying to implement CGDCONT right now.
That piece is quite nasty and generally of lower priority. I'd like to
get the emulator a bit more hashed out first and implement the base BT DUN& BT HFP profiles.for the sake of testing, I would be fine with the real basic CGDCONT and just offering IP and CID 1. And then of course accepting any APN in that range and rejecting any other command.
The submitted code is just an "how-to", and need to be updated to implement the complete CGDCONT (up to now, the function displays the existings contexts, and the default range values.
The idea behind this code was to provide the complete chain to handle AT commands in atoms. I m not sure the current handler mechanism fit with Denis's view ;)
Regards,
Olivier
PATCH 2/2 emulator: Add +CGMI and +CGDCONT commands
In reply to Olivier Guiter--- include/emulator.h | 7 ++++++- src/emulator.c | 28 ++++++++++++++++++++++++---- 2 files changed, 30 insertions(+), 5 deletions(-)
include/emulator.h +6 -1
@@ -27,8 +27,13 @@ extern "C" {#endif #include <ofono/types.h> +#include <gatserver.h> -struct ofono_emulator ; +struct ofono_emulator { +struct ofono_atom *atom; +GAtServer *server; +struct ofono_atom *gprs_atom; +};enum ofono_emulator_type {OFONO_EMULATOR_TYPE_DUN ,
src/emulator.c +24 -4
@@ -28,10 +28,23 @@#include "ofono.h" #include "gatserver.h" -struct ofono_emulator { -struct ofono_atom *atom; -GAtServer *server; -}; +static void cgmi_cb (GAtServerRequestType type,GAtResult *cmd,gpointer user) +{ +struct ofono_emulator *em = user; +GAtServer *server = em->server; + +switch (type) { +case G_AT_SERVER_REQUEST_TYPE_COMMAND_ONLY : +g_at_server_send_info (server,"oFono" , TRUE); +g_at_server_send_final (server,G_AT_SERVER_RESULT_OK ); +break ; +case G_AT_SERVER_REQUEST_TYPE_SUPPORT : +g_at_server_send_final (server,G_AT_SERVER_RESULT_OK ); +break ; +default : +g_at_server_send_final (server,G_AT_SERVER_RESULT_ERROR ); + }; +}static void emulator_debug (const char *str,void *data) {
@@ -76,6 +89,12 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd)g_at_server_set_disconnect_function (em->server, emulator_disconnect, em); +/* Register local callbacks */ +g_at_server_register (em->server,"+CGMI" , cgmi_cb, em,NULL ); + +/* Register external (atoms) callbacks */ +ofono_gprs_add_emulator_handler (em); +__ofono_atom_register (em->atom, emulator_unregister); }
@@ -102,6 +121,7 @@ struct ofono_emulator *ofono_emulator_create(struct ofono_modem *modem, em->atom =__ofono_modem_add_atom (modem,OFONO_ATOM_TYPE_EMULATOR_DUN , emulator_remove, em); + em->gprs_atom =__ofono_modem_find_atom (modem,OFONO_ATOM_TYPE_GPRS );return em; }
Signature · 1 line
1.7.1