Index: common/misc.c =================================================================== RCS file: /sources/gnokii/gnokii/common/misc.c,v retrieving revision 1.135 diff -u -p -r1.135 misc.c --- common/misc.c 10 Nov 2007 19:00:58 -0000 1.135 +++ common/misc.c 19 Nov 2007 11:24:36 -0000 @@ -606,6 +606,17 @@ void gnokii_strfreev(char **str_array) } /* + * whether string has the prefix + */ + +#define MIN(x, y) (x < y ? x : y) + +int gnokii_str_has_caseprefix(const char *str, const char *prefix) +{ + return (strncasecmp(str, prefix, MIN(strlen(str), strlen(prefix))) == 0); +} + +/* * check if the timestamp in dt has valid date and time */ GNOKII_API int gn_timestamp_isvalid(const gn_timestamp dt) Index: common/phones/Makefile =================================================================== RCS file: /sources/gnokii/gnokii/common/phones/Makefile,v retrieving revision 1.26 diff -u -p -r1.26 Makefile --- common/phones/Makefile 30 Oct 2007 17:07:00 -0000 1.26 +++ common/phones/Makefile 19 Nov 2007 11:24:36 -0000 @@ -29,6 +29,7 @@ OBJS = generic.lo \ atgen.lo \ atbosch.lo \ ateric.lo \ + atmot.lo \ atnok.lo \ atsie.lo \ atsoer.lo \ Index: common/phones/atgen.c =================================================================== RCS file: /sources/gnokii/gnokii/common/phones/atgen.c,v retrieving revision 1.164 diff -u -p -r1.164 atgen.c --- common/phones/atgen.c 19 Nov 2007 10:58:03 -0000 1.164 +++ common/phones/atgen.c 19 Nov 2007 11:24:38 -0000 @@ -46,6 +46,7 @@ #include "phones/atgen.h" #include "phones/atbosch.h" #include "phones/ateric.h" +#include "phones/atmot.h" #include "phones/atnok.h" #include "phones/atsie.h" #include "phones/atsoer.h" @@ -2482,19 +2483,21 @@ static gn_error Initialise(gn_data *setu if (ret) goto out; - if (!strncasecmp(manufacturer, "bosch", 5)) + if (gnokii_str_has_caseprefix(manufacturer, "bosch")) at_bosch_init(model, setupdata->model, state); - else if (!strncasecmp(manufacturer, "ericsson", 8)) + else if (gnokii_str_has_caseprefix(manufacturer, "ericsson")) at_ericsson_init(model, setupdata->model, state); - else if (!strncasecmp(manufacturer, "nokia", 5)) + else if (gnokii_str_has_caseprefix(manufacturer, "nokia")) at_nokia_init(model, setupdata->model, state); - else if (!strncasecmp(manufacturer, "siemens", 7)) + else if (gnokii_str_has_caseprefix(manufacturer, "siemens")) at_siemens_init(model, setupdata->model, state); - else if (!strncasecmp(manufacturer, "sony ericsson", 14)) + else if (gnokii_str_has_caseprefix(manufacturer, "sony ericsson")) at_sonyericsson_init(model, setupdata->model, state); - else if (!strncasecmp(manufacturer, "samsung", 7)) + else if (gnokii_str_has_caseprefix(manufacturer, "samsung")) at_samsung_init(model, setupdata->model, state); - + else if (gnokii_str_has_caseprefix(manufacturer, "Motorola")) + at_motorola_init(model, setupdata->model, state); + StoreDefaultCharset(state); dprintf("Initialisation completed\n"); Index: common/phones/atsoer.c =================================================================== RCS file: /sources/gnokii/gnokii/common/phones/atsoer.c,v retrieving revision 1.9 diff -u -p -r1.9 atsoer.c --- common/phones/atsoer.c 19 Nov 2007 10:58:03 -0000 1.9 +++ common/phones/atsoer.c 19 Nov 2007 11:24:38 -0000 @@ -62,8 +62,9 @@ static gn_error se_at_memory_type_set(gn return GN_ERR_NOTREADY; gn_data_clear(&data); ret = sm_block_no_retry(GN_OP_Init, &data, state); - if (ret == GN_ERR_NONE) - drvinst->memorytype = mt; + if (ret) + return ret; + drvinst->memorytype = mt; gn_data_clear(&data); ret = state->driver.functions(GN_OP_AT_GetMemoryRange, &data, state); Index: include/misc.h =================================================================== RCS file: /sources/gnokii/gnokii/include/misc.h,v retrieving revision 1.55 diff -u -p -r1.55 misc.h --- include/misc.h 7 Nov 2007 22:17:16 -0000 1.55 +++ include/misc.h 19 Nov 2007 11:24:38 -0000 @@ -123,5 +123,6 @@ char **gnokii_strsplit(const char *string, const char *delimiter, int tokens); void gnokii_strfreev(char **str_array); +int gnokii_str_has_caseprefix(const char *str, const char *prefix); #endif /* _gnokii_misc_h */ --- /dev/null 2007-11-09 12:48:38.126001353 +0000 +++ common/phones/atmot.c 2007-11-19 11:24:25.000000000 +0000 @@ -0,0 +1,84 @@ +/* + + $Id$ + + G N O K I I + + A Linux/Unix toolset and driver for the mobile phones. + + This file is part of gnokii. + + Gnokii is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + Gnokii 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 gnokii; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Copyright (C) 2006 Bastien Nocera + + This file provides functions specific to at commands on motorola + phones. See README for more details on supported mobile phones. + +*/ + +#include +#include +#include + +#include "config.h" +#include "compat.h" +#include "misc.h" +#include "gnokii.h" +#include "phones/generic.h" +#include "phones/atgen.h" +#include "phones/atmot.h" + +static at_recv_function_type identify; + +static gn_error ReplyIdentify(int messagetype, unsigned char *buffer, int length, gn_data *data, struct gn_statemachine *state) +{ + at_line_buffer buf; + gn_error error; + char *model; + + if (strlen (buffer) < 2 || strncmp(buffer + 1, "AT+CGMM", 7) != 0) { + return (*identify) (messagetype, buffer, length, data, state); + } + + if ((error = at_error_get(buffer, state)) != GN_ERR_NONE) return error; + + buf.line1 = buffer + 1; + buf.length = length; + splitlines(&buf); + + /* The line usually looks like: + * +CGMM: "GSM900","GSM1800","GSM1900","GSM850","MODEL=V547" + */ + model = strstr (buf.line2, "MODEL="); + if (!model) { + strcpy (data->model, strip_quotes(buf.line2 + 1 + strlen ("+CGMM: "))); + } else { + strcpy (data->model, strip_quotes(model + strlen ("MODEL="))); + model = strchr (data->model, '"'); + if (model) + *model = '\0'; + } + + return GN_ERR_NONE; +} + +void at_motorola_init(char* foundmodel, char* setupmodel, struct gn_statemachine *state) +{ + /* Motorolas support mode 3 and 1, but mode 1 is pretty useless */ + AT_DRVINST(drvinst)->cnmi_mode = 3; + + identify = at_insert_recv_function(GN_OP_Identify, ReplyIdentify, state); +} --- /dev/null 2007-11-09 12:48:38.126001353 +0000 +++ include/phones/atmot.h 2007-11-19 11:12:10.000000000 +0000 @@ -0,0 +1,39 @@ +/* + + $Id$ + + G N O K I I + + A Linux/Unix toolset and driver for the mobile phones. + + This file is part of gnokii. + + Gnokii is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + Gnokii 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 gnokii; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Copyright (C) 2006 Bastien Nocera + + This file provides functions specific to AT commands on Siemens phones. + See README for more details on supported mobile phones. + +*/ + +#ifndef _gnokii_atmot_h_ +#define _gnokii_atmot_h_ + +#include "gnokii.h" + +void at_motorola_init(char* foundmodel, char* setupmodel, struct gn_statemachine *state); + +#endif