gnokii-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] libgnokii and core programs branch, master, updated. rel_0_6_29-55


From: Daniele Forsi
Subject: [SCM] libgnokii and core programs branch, master, updated. rel_0_6_29-551-gb4046e6
Date: Wed, 08 Jan 2014 10:46:47 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "libgnokii and core programs".

The branch, master has been updated
       via  b4046e6c512c64059ad35aa6087d3b1f71f4b15c (commit)
      from  9becb7a86447ade8dfd1f8a0079e8944110f3ac5 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/gnokii.git/commit/?id=b4046e6c512c64059ad35aa6087d3b1f71f4b15c


commit b4046e6c512c64059ad35aa6087d3b1f71f4b15c
Author: Daniele Forsi <address@hidden>
Date:   Wed Jan 1 16:00:14 2014 +0100

    Add GN_OP_Passthrough and implement it for nk6510 -- USE WITH CARE!!!
    
    Useful for debugging and for searching new frames without recompiling
    libgnokii.

diff --git a/ChangeLog b/ChangeLog
index 6675110..b0ba28f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -28,6 +28,7 @@
     o add id for Nokia 100; use model=series40; many commands don't
       work, see the Series 30 section in Docs/README-6510
                                                    (Bruno Estieule)
+    o add GN_OP_Passthrough                         (Daniele Forsi)
  * at driver updates
     o in the default case autodetect if PDU SMS starts with SMSC
                                                     (Daniele Forsi)
@@ -73,6 +74,7 @@
                                                     (Daniele Forsi)
     o write phone number read from TEL;TYPE=PREF,VOICE of a vCard
       when there is no other number in subentries   (Daniele Forsi)
+    o implement GN_OP_Passthrough operation         (Daniele Forsi)
  * xgnokii updates
     o fix bug that caused to forget subentries after the first one
       when editing the phonebook                    (Daniele Forsi)
diff --git a/common/phones/nk6510.c b/common/phones/nk6510.c
index d4d1a6e..fad38fe 100644
--- a/common/phones/nk6510.c
+++ b/common/phones/nk6510.c
@@ -273,6 +273,8 @@ static gn_error NK6510_GetToDo(gn_data *data, struct 
gn_statemachine *state);
 static gn_error NK6510_DeleteAllToDoLocations(gn_data *data, struct 
gn_statemachine *state);
 static gn_error NK6510_WriteToDo(gn_data *data, struct gn_statemachine *state);
 
+static gn_error NK6510_Passthrough(gn_data *data, struct gn_statemachine 
*state);
+
 static gn_error NK6510_IncomingIdentify(int messagetype, unsigned char 
*buffer, int length, gn_data *data, struct gn_statemachine *state);
 static gn_error NK6510_IncomingPhonebook(int messagetype, unsigned char 
*buffer, int length, gn_data *data, struct gn_statemachine *state);
 static gn_error NK6510_IncomingNetwork(int messagetype, unsigned char *buffer, 
int length, gn_data *data, struct gn_statemachine *state);
@@ -296,6 +298,8 @@ static gn_error NK6510_IncomingFile(int messagetype, 
unsigned char *message, int
 
 static gn_error NK6510_IncomingSecurity(int messagetype, unsigned char 
*message, int length, gn_data *data, struct gn_statemachine *state);
 
+static gn_error NK6510_IncomingPassthrough(int messagetype, unsigned char 
*message, int length, gn_data *data, struct gn_statemachine *state);
+
 static int sms_encode(gn_data *data, struct gn_statemachine *state, unsigned 
char *req);
 static int get_memory_type(gn_memory_type memory_type);
 static gn_memory_type get_gn_memory_type_sms(int memory_type);
@@ -516,6 +520,8 @@ static gn_error NK6510_Functions(gn_operation op, gn_data 
*data, struct gn_state
                return NK6510_GetMMS(data, state);
        case GN_OP_DeleteMMS:
                return NK6510_DeleteMMS(data, state);
+       case GN_OP_Passthrough:
+               return NK6510_Passthrough(data, state);
        default:
                return GN_ERR_NOTIMPLEMENTED;
        }
@@ -6470,6 +6476,54 @@ static gn_error NK6510_PlayTone(gn_data *data, struct 
gn_statemachine *state)
        SEND_MESSAGE_BLOCK(NK6510_MSG_SOUND, 34);
 }
 
+/***************/
+/* PASSTHROUGH */
+/***************/
+
+static gn_error NK6510_IncomingPassthrough(int messagetype, unsigned char 
*message, int length, gn_data *data, struct gn_statemachine *state)
+{
+       dprintf("Incoming Passthrough\n");
+       if (!data || !data->read_buffer)
+               return GN_ERR_INTERNALERROR;
+
+       data->read_buffer->type = messagetype;
+       /*
+         Always return actual frame length even if the caller provided a 
smaller buffer
+         so that the caller can retry with a bigger buffer.
+        */
+       data->read_buffer->length = length;
+       if (!data->read_buffer->buffer) {
+               data->read_buffer->buffer = malloc(length);
+               if (!data->read_buffer->buffer)
+                       return GN_ERR_MEMORYFULL;
+       }
+       memcpy(data->read_buffer->buffer, message, 
GNOKII_MIN(data->read_buffer->length, length));
+
+       return GN_ERR_NONE;
+}
+
+static gn_error NK6510_Passthrough(gn_data *data, struct gn_statemachine 
*state)
+{
+       gn_error error;
+       gn_incoming_function_type *incoming_functions;
+       gn_incoming_function_type passthrough_functions[] = {
+               {data->write_buffer->type, NK6510_IncomingPassthrough},
+               {0, NULL}
+       };
+
+       incoming_functions = state->driver.incoming_functions;
+       state->driver.incoming_functions = passthrough_functions;
+
+       if (sm_message_send(data->write_buffer->length, 
data->write_buffer->type, data->write_buffer->buffer, state))
+               error = GN_ERR_NOTREADY;
+       else
+               error = sm_block(data->write_buffer->type, data, state);
+
+       state->driver.incoming_functions = incoming_functions;
+
+       return error;
+}
+
 /********************************/
 /* NOT FRAME SPECIFIC FUNCTIONS */
 /********************************/
diff --git a/gnokii/gnokii.c b/gnokii/gnokii.c
index 3ebab22..34ab212 100644
--- a/gnokii/gnokii.c
+++ b/gnokii/gnokii.c
@@ -443,9 +443,31 @@ static int checkargs(int opt, struct gnokii_arg_len 
gals[], int argc, int has_ar
 #ifdef DEBUG
 static int foogle(int argc, char *argv[])
 {
-       /* Fill in what you would like to test here... */
-       /* remember to call businit(); if you need to communicate with your 
phone */
-       return GN_ERR_NONE;
+       gn_error error;
+
+       /* For demonstration purposes we're going to send an "Identify" frame */
+       unsigned char req[] = {00, 01, 00, 07, 01, 00}; /* Identify nk6510 */
+       gn_raw_buffer write_buffer = {0x1b, sizeof(req), req};
+       gn_raw_buffer read_buffer = {0, 0, NULL}; /* if buffer==NULL libgnokii 
will allocate memory */
+
+       if (businit() != 0)
+               return GN_ERR_FAILED;
+
+       data->write_buffer = &write_buffer;
+       data->read_buffer = &read_buffer;
+       error = gn_sm_functions(GN_OP_Passthrough, data, state);
+       if (error == GN_ERR_NONE) {
+               dprintf("Foogle received a frame of type 0x%02x and length 
%d\n",
+                       data->read_buffer->type, data->read_buffer->length);
+               /* Add here the code to parse the frame */
+       } else {
+               fprintf(stderr, _("Error: %s\n"), gn_error_print(error));
+       }
+
+       free(data->read_buffer->buffer);
+       data->read_buffer->buffer = NULL;
+
+       return error;
 }
 #endif
 
diff --git a/include/gnokii/common.h b/include/gnokii/common.h
index 75eaeb0..69e4b30 100644
--- a/include/gnokii/common.h
+++ b/include/gnokii/common.h
@@ -893,4 +893,11 @@ typedef enum {
        GN_AUTH_TYPE_BINARY
 } gn_auth_type;
 
+/* This is used with GN_OP_Passthrough */
+typedef struct {
+       int type;
+       int length;
+       unsigned char *buffer;
+} gn_raw_buffer;
+
 #endif /* _gnokii_common_h */
diff --git a/include/gnokii/data.h b/include/gnokii/data.h
index 91f0eda..9822c0b 100644
--- a/include/gnokii/data.h
+++ b/include/gnokii/data.h
@@ -108,6 +108,7 @@ typedef struct {
         * touch this one.
         */
        gn_mms *mms;
+       gn_raw_buffer *write_buffer, *read_buffer;
 } gn_data;
 
 /*
@@ -297,6 +298,7 @@ typedef enum {
        GN_OP_GetMMS,
        GN_OP_DeleteMMS,
        GN_OP_Ping,
+       GN_OP_Passthrough,
        GN_OP_Max,      /* don't append anything after this entry */
 } gn_operation;
 

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog               |    2 +
 common/phones/nk6510.c  |   54 +++++++++++++++++++++++++++++++++++++++++++++++
 gnokii/gnokii.c         |   28 +++++++++++++++++++++--
 include/gnokii/common.h |    7 ++++++
 include/gnokii/data.h   |    2 +
 5 files changed, 90 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
libgnokii and core programs



reply via email to

[Prev in Thread] Current Thread [Next in Thread]