gnokii-commit
[Top][All Lists]
Advanced

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

[SCM] Additional programs and language bindings branch, master, updated.


From: Daniele Forsi
Subject: [SCM] Additional programs and language bindings branch, master, updated. 6b0574577b2d0c3923069ba13b43e5e90cd1e8f2
Date: Fri, 12 Feb 2010 16:29:20 +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 "Additional programs and language bindings".

The branch, master has been updated
       via  6b0574577b2d0c3923069ba13b43e5e90cd1e8f2 (commit)
      from  3c8a2d8671e57ea45a4d95073a46f73b7e0718c6 (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/gnokii-extras.git/commit/?id=6b0574577b2d0c3923069ba13b43e5e90cd1e8f2


commit 6b0574577b2d0c3923069ba13b43e5e90cd1e8f2
Author: Daniele Forsi <address@hidden>
Date:   Fri Feb 12 17:28:40 2010 +0100

    Add missing snippet "cellid"

diff --git a/snippets/ChangeLog b/snippets/ChangeLog
index ead5906..7194ecb 100644
--- a/snippets/ChangeLog
+++ b/snippets/ChangeLog
@@ -1,3 +1,7 @@
+20010/02/12
+ * monitor/
+    o add missing cellid.c and cellid.readme                 (Daniele Forsi)
+
 2009/12/24
  * mms/
     o add mms_convert to convert between MMS formats         (Daniele Forsi)
diff --git a/snippets/monitor/Makefile b/snippets/monitor/Makefile
index 45c7e5c..2e7c0e9 100644
--- a/snippets/monitor/Makefile
+++ b/snippets/monitor/Makefile
@@ -1,6 +1,6 @@
 # $Id$
 
-PROGS = rf_level waitcall
+PROGS = cellid rf_level waitcall
 
 TOPDIR = ..
 include ${TOPDIR}/Makefile.global
diff --git a/snippets/monitor/cellid.c b/snippets/monitor/cellid.c
new file mode 100644
index 0000000..9f59c10
--- /dev/null
+++ b/snippets/monitor/cellid.c
@@ -0,0 +1,117 @@
+/*
+
+  $Id: cellid.c,v 1.3 2007/02/23 22:23:17 dforsi Exp $
+
+  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 by Daniele Forsi
+
+  Prints cellid-LAC-MNC-MCC.
+
+  compile with
+  gcc -Wall -o cellid cellid.c `pkg-config --libs gnokii`
+
+  usage:
+  cellid
+
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <signal.h>
+#include <string.h>
+
+#include <gnokii.h>
+
+/* prepare for i18n */
+#define _(x) x
+
+struct gn_statemachine *state = NULL;
+
+void busterminate(void) {
+       gn_lib_phone_close(state);
+       gn_lib_phoneprofile_free(&state);
+       gn_lib_library_free();
+}
+
+void businit(void) {
+       gn_error        error;
+       
+       atexit(busterminate);
+       
+       error = gn_lib_phoneprofile_load(NULL, &state);
+       if (GN_ERR_NONE == error) {
+               error = gn_lib_phone_open(state);
+       }
+       
+       if (GN_ERR_NONE != error) {
+               fprintf(stderr, "%s\n", gn_error_print(error));
+               exit(-1);
+       }
+}
+
+void signal_handler(int signal) {
+       exit(-2);
+}
+
+int main(int argc, char *argv[]) {
+       gn_data         data;
+       gn_error        error;
+       gn_network_info networkinfo;
+
+       if (argc != 1) {
+               fprintf(stderr, _("Usage: %s\nPurpose: print identification 
data of the current GSM cell\n"), argv[0]);
+               fprintf(stderr, _("Format is CellID-LAC-MNC-MCC as decimal 
values\n"));
+               exit(-1);
+       }
+
+       businit();
+
+       signal(SIGINT, signal_handler);
+
+       gn_data_clear(&data);
+       memset(&networkinfo, 0, sizeof(networkinfo));
+       data.network_info = &networkinfo;
+
+       error = gn_sm_functions(GN_OP_GetNetworkInfo, &data, state);
+       if (error == GN_ERR_NONE) {
+               unsigned int cid = 0, lac = 0, mnc = 0, mcc = 0;
+
+               /* Ugly, ugly, ... */
+               if (networkinfo.cell_id[2] == 0 && networkinfo.cell_id[3] == 0)
+                       cid = (networkinfo.cell_id[0] << 8) + 
networkinfo.cell_id[1];
+               else
+                       cid = (networkinfo.cell_id[0] << 24) + 
(networkinfo.cell_id[1] << 16) + (networkinfo.cell_id[2] << 8) + 
networkinfo.cell_id[3]; 
+
+               lac = (networkinfo.LAC[0] << 8) + networkinfo.LAC[1];
+
+               if (strlen(networkinfo.network_code) > 3) {
+                       mcc = atoi(&networkinfo.network_code[0]);
+                       mnc = atoi(&networkinfo.network_code[4]);
+               }
+
+               printf("%d-%d-%d-%d\n", cid, lac, mnc, mcc);
+               printf("CellID: %d LAC: %d MNC: %d MCC: %d\n", cid, lac, mnc, 
mcc);
+       }
+
+       exit(error);
+}
diff --git a/snippets/monitor/cellid.readme b/snippets/monitor/cellid.readme
new file mode 100644
index 0000000..1e473b7
--- /dev/null
+++ b/snippets/monitor/cellid.readme
@@ -0,0 +1,8 @@
+Print information about current cell.
+
+Meaning of abbreviations:
+
+CellID: Cell Identifier
+LAC: Local Area Code
+MNC: Mobile Network Code
+MCC: Mobile Country Code

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

Summary of changes:
 snippets/ChangeLog                        |    4 ++
 snippets/monitor/Makefile                 |    2 +-
 snippets/monitor/{rf_level.c => cellid.c} |   45 ++++++++++++++++++----------
 snippets/monitor/cellid.readme            |    8 +++++
 4 files changed, 42 insertions(+), 17 deletions(-)
 copy snippets/monitor/{rf_level.c => cellid.c} (58%)
 create mode 100644 snippets/monitor/cellid.readme


hooks/post-receive
-- 
Additional programs and language bindings




reply via email to

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