Send commitlog mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.openmoko.org/mailman/listinfo/commitlog
or, via email, send a message with subject or body 'help' to
        [EMAIL PROTECTED]

You can reach the person managing the list at
        [EMAIL PROTECTED]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of commitlog digest..."
Today's Topics:

   1. r2714 - in
      trunk/src/target/OM-2007.2/applications/openmoko-dialer2: . src
      ([EMAIL PROTECTED])
   2. r2715 - in
      trunk/src/target/OM-2007.2/applications/openmoko-dialer2: . src
      ([EMAIL PROTECTED])
   3. r2716 - in
      trunk/src/target/OM-2007.2/applications/openmoko-dialer2: . src
      ([EMAIL PROTECTED])
   4. r2717 -
      trunk/src/target/OM-2007.2/panel-plugins/openmoko-panel-gsm/src
      ([EMAIL PROTECTED])
   5. r2718 - in trunk/src/target/OM-2007.2/libraries/libmokogsmd2:
      . libmokogsmd ([EMAIL PROTECTED])
   6. r2719 - trunk/src/host/dfu-util/src ([EMAIL PROTECTED])
   7. r2720 - in trunk/src/target/gsm: include/gsmd include/libgsmd
      src/gsmd src/libgsmd src/util ([EMAIL PROTECTED])
--- Begin Message ---
Author: njp
Date: 2007-08-16 13:06:01 +0200 (Thu, 16 Aug 2007)
New Revision: 2714

Modified:
   trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog
   trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-dialer.c
Log:
2007-08-16  Neil J. Patel  <[EMAIL PROTECTED]>

        * src/moko-dialer.c: (on_network_registered), (on_pin_requested):
        Be smarter when searching for a network, don't keep pinging gsmd.

Modified: trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog  
2007-08-16 05:48:59 UTC (rev 2713)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog  
2007-08-16 11:06:01 UTC (rev 2714)
@@ -1,3 +1,8 @@
+2007-08-16  Neil J. Patel  <[EMAIL PROTECTED]>
+
+       * src/moko-dialer.c: (on_network_registered), (on_pin_requested):
+       Be smarter when searching for a network, don't keep pinging gsmd.
+
 2007-08-15  Neil J. Patel  <[EMAIL PROTECTED]>
 
        * src/moko-dialer.c: (on_network_registered):

Modified: 
trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-dialer.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-dialer.c  
2007-08-16 05:48:59 UTC (rev 2713)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-dialer.c  
2007-08-16 11:06:01 UTC (rev 2714)
@@ -425,16 +425,20 @@
     case MOKO_GSMD_CONNECTION_NETREG_NONE:
     case MOKO_GSMD_CONNECTION_NETREG_SEARCHING:
       /* Do nothing */
+      g_print ("NetReg: Seraching for network\n");
+      g_source_remove (priv->reg_timeout);
+      priv->registered = TRUE;
       break;
     case MOKO_GSMD_CONNECTION_NETREG_DENIED:
       /* This may be a pin issue*/
-      g_print ("Registration denied, the SIM pin may need to be entered\n");
+      g_print ("NetReg: Registration denied, the SIM pin may be needed\n");
       moko_keypad_set_pin_mode (MOKO_KEYPAD (priv->keypad), TRUE);
       g_source_remove (priv->reg_timeout);
       break;
     case MOKO_GSMD_CONNECTION_NETREG_HOME:
     case MOKO_GSMD_CONNECTION_NETREG_ROAMING:
-      g_print ("Network registered\n");
+      g_print ("NetReg: Network registered\n");
+      g_print("\tLocationAreaCode = %x\n\tCellID = %x", lac, cell);
       g_source_remove (priv->reg_timeout);
       priv->registered = TRUE;
       break;
@@ -533,6 +537,7 @@
   g_return_if_fail (MOKO_IS_DIALER (dialer));
   priv = dialer->priv;
   
+  g_source_remove (priv->reg_timeout);
   moko_keypad_set_pin_mode (MOKO_KEYPAD (priv->keypad), TRUE);
   g_print ("Pin Requested\n");
 




--- End Message ---
--- Begin Message ---
Author: njp
Date: 2007-08-16 13:14:11 +0200 (Thu, 16 Aug 2007)
New Revision: 2715

Modified:
   trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog
   trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-dialer.c
   trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-keypad.c
Log:
2007-08-16  Neil J. Patel  <[EMAIL PROTECTED]>

        * src/moko-dialer.c: (on_network_registered):
        Fix a typo.

        * src/moko-keypad.c: (on_panel_user_input):
        Make '#' the same as 'OK' when inputting a PIN (Bug #708)

Modified: trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog  
2007-08-16 11:06:01 UTC (rev 2714)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog  
2007-08-16 11:14:11 UTC (rev 2715)
@@ -1,5 +1,13 @@
 2007-08-16  Neil J. Patel  <[EMAIL PROTECTED]>
 
+       * src/moko-dialer.c: (on_network_registered):
+       Fix a typo.
+
+       * src/moko-keypad.c: (on_panel_user_input):
+       Make '#' the same as 'OK' when inputting a PIN (Bug #708)
+
+2007-08-16  Neil J. Patel  <[EMAIL PROTECTED]>
+
        * src/moko-dialer.c: (on_network_registered), (on_pin_requested):
        Be smarter when searching for a network, don't keep pinging gsmd.
 

Modified: 
trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-dialer.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-dialer.c  
2007-08-16 11:06:01 UTC (rev 2714)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-dialer.c  
2007-08-16 11:14:11 UTC (rev 2715)
@@ -425,7 +425,7 @@
     case MOKO_GSMD_CONNECTION_NETREG_NONE:
     case MOKO_GSMD_CONNECTION_NETREG_SEARCHING:
       /* Do nothing */
-      g_print ("NetReg: Seraching for network\n");
+      g_print ("NetReg: Searching for network\n");
       g_source_remove (priv->reg_timeout);
       priv->registered = TRUE;
       break;

Modified: 
trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-keypad.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-keypad.c  
2007-08-16 11:06:01 UTC (rev 2714)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-keypad.c  
2007-08-16 11:14:11 UTC (rev 2715)
@@ -183,6 +183,13 @@
   g_return_if_fail (MOKO_IS_KEYPAD (keypad));
   priv = keypad->priv;
 
+  /* Phones use '#' for PIN 'entered' signal */
+  if (priv->pin_mode && digit == '#')
+  { 
+    on_dial_clicked (NULL, keypad);
+    return;
+  }   
+
   /* Create a string to insert into the textview */
   buf[0] = digit;
   buf[1] = '\0';




--- End Message ---
--- Begin Message ---
Author: njp
Date: 2007-08-16 13:21:57 +0200 (Thu, 16 Aug 2007)
New Revision: 2716

Modified:
   trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog
   trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-dialer.c
   trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-keypad.c
Log:
2007-08-16  Neil J. Patel  <[EMAIL PROTECTED]>

        * src/moko-dialer.c: (on_keypad_pin_entry),
        (on_network_registered):
        Remove some unused printf's, keep copy of PIN while interfacing with
        libgsmd.

        * src/moko-keypad.c: (on_dial_clicked):
        Clear the PIN once 'OK' is pressed.

Modified: trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog  
2007-08-16 11:14:11 UTC (rev 2715)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog  
2007-08-16 11:21:57 UTC (rev 2716)
@@ -1,5 +1,15 @@
 2007-08-16  Neil J. Patel  <[EMAIL PROTECTED]>
 
+       * src/moko-dialer.c: (on_keypad_pin_entry),
+       (on_network_registered):
+       Remove some unused printf's, keep copy of PIN while interfacing with
+       libgsmd.
+
+       * src/moko-keypad.c: (on_dial_clicked):
+       Clear the PIN once 'OK' is pressed.
+
+2007-08-16  Neil J. Patel  <[EMAIL PROTECTED]>
+
        * src/moko-dialer.c: (on_network_registered):
        Fix a typo.
 

Modified: 
trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-dialer.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-dialer.c  
2007-08-16 11:14:11 UTC (rev 2715)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-dialer.c  
2007-08-16 11:21:57 UTC (rev 2716)
@@ -280,25 +280,28 @@
 
 static void
 on_keypad_pin_entry (MokoKeypad  *keypad,
-                     const gchar *pin,
+                     const gchar *in_pin,
                      MokoDialer  *dialer)
 {
   MokoDialerPrivate *priv;
+  gchar *pin;
   
   g_return_if_fail (MOKO_IS_DIALER (dialer));
   priv = dialer->priv;
 
+  pin = g_strdup (in_pin);
+
+  g_print ("Sending pin %s\n", pin);
   moko_gsmd_connection_send_pin (priv->connection, pin);
 
   moko_keypad_set_pin_mode (MOKO_KEYPAD (priv->keypad), FALSE);
-
-  g_print ("Sending pin %s\n", pin);
-  
+    
   priv->reg_request = TRUE;
   priv->registered = FALSE;
   priv->reg_timeout = g_timeout_add (GSM_REGISTER_TIMEOUT, 
                                      (GSourceFunc)register_network_cb, 
                                      dialer);
+  g_free (pin);
 }
 
 
@@ -418,8 +421,6 @@
   g_return_if_fail (MOKO_IS_DIALER (dialer));
   priv = dialer->priv;
 
-  g_print ("Register type %d\n", type);
-
   switch (type)
   {
     case MOKO_GSMD_CONNECTION_NETREG_NONE:

Modified: 
trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-keypad.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-keypad.c  
2007-08-16 11:14:11 UTC (rev 2715)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-keypad.c  
2007-08-16 11:21:57 UTC (rev 2716)
@@ -135,6 +135,8 @@
    g_signal_emit (G_OBJECT (keypad), keypad_signals[PIN_ENTRY], 0, number);
  else
    g_signal_emit (G_OBJECT (keypad), keypad_signals[DIAL_NUMBER], 0, number);
+ 
+ moko_dialer_textview_empty (MOKO_DIALER_TEXTVIEW (priv->textview));
 }
 
 static gboolean




--- End Message ---
--- Begin Message ---
Author: njp
Date: 2007-08-16 17:44:55 +0200 (Thu, 16 Aug 2007)
New Revision: 2717

Modified:
   
trunk/src/target/OM-2007.2/panel-plugins/openmoko-panel-gsm/src/openmoko-panel-gsm.c
Log:
* Fix all warnings.
* Make the image used dependant on signal percentage.
* Fix small mem leak.



Modified: 
trunk/src/target/OM-2007.2/panel-plugins/openmoko-panel-gsm/src/openmoko-panel-gsm.c
===================================================================
--- 
trunk/src/target/OM-2007.2/panel-plugins/openmoko-panel-gsm/src/openmoko-panel-gsm.c
        2007-08-16 11:21:57 UTC (rev 2716)
+++ 
trunk/src/target/OM-2007.2/panel-plugins/openmoko-panel-gsm/src/openmoko-panel-gsm.c
        2007-08-16 15:44:55 UTC (rev 2717)
@@ -22,61 +22,84 @@
 #include <gtk/gtk.h>
 #include <time.h>
 
+/* Just change this is gsmd changes */
+#define _MAX_SIGNAL 30.0
+
 typedef struct {
-    GtkImage* image;
+    GtkWidget* image;
     gboolean gprs_mode;
     MokoGsmdConnection* gsm;
 } GsmApplet;
 
-static void gsm_applet_free(GsmApplet *applet)
+static void 
+gsm_applet_free(GsmApplet *applet)
 {
     g_slice_free( GsmApplet, applet );
 }
 
-static void gsm_applet_update_signal_strength(MokoGsmdConnection* connection, 
int strength, GsmApplet* applet)
+static void 
+gsm_applet_update_signal_strength(MokoGsmdConnection* connection, 
+                                  int strength, 
+                                  GsmApplet* applet)
 {
-    g_debug( "gsm_applet_update_signal_strength: signal strength = %d", 
strength );
-    //TODO calibrate
-    int pixmap = 0;
-    if ( strength > 30 )
-        pixmap = 5;
-    else if ( strength > 20 )
-        pixmap = 4;
-    else if ( strength > 17 )
-        pixmap = 3;
-    else if ( strength > 13 )
-        pixmap = 2;
-    else if ( strength > 10 )
-        pixmap = 1;
+    gfloat percent;
+    gint pixmap = 0;
+    gchar *image = NULL;
 
-    const char* imagestring = g_strdup_printf( "%s/SignalStrength%s%02d.png", 
PKGDATADIR, applet->gprs_mode ? "25g_" : "_", pixmap );
-    gtk_image_set_from_file( GTK_IMAGE(applet->image), imagestring );
+    g_debug( "gsm_applet_update_signal_strength: signal strength = %d", 
+              strength );
+
+    percent = (strength / _MAX_SIGNAL) * 100;
+
+    if ( percent == 0 )
+      pixmap = 0;
+    else if ( percent < 20 )
+      pixmap = 1;
+    else if ( percent < 40 )
+      pixmap = 2;
+    else if ( percent < 60 )
+      pixmap = 3;
+    else if ( percent < 80 )
+      pixmap = 4;
+    else
+      pixmap = 5;
+
+    image = g_strdup_printf( "%s/SignalStrength%s%02d.png", 
+                             PKGDATADIR, 
+                             applet->gprs_mode ? "25g_" : "_", pixmap );
+    gtk_image_set_from_file( GTK_IMAGE(applet->image), image );
+
+    g_free (image);
 }
 
-static void gsm_applet_power_up_antenna(GtkWidget* menu, GsmApplet* applet)
+static void 
+gsm_applet_power_up_antenna(GtkWidget* menu, GsmApplet* applet)
 {
     //TODO notify user
     moko_gsmd_connection_set_antenna_power( applet->gsm, TRUE );
 }
 
-static void gsm_applet_autoregister_network(GtkWidget* menu, GsmApplet* applet)
+static void 
+gsm_applet_autoregister_network(GtkWidget* menu, GsmApplet* applet)
 {
     moko_gsmd_connection_network_register( applet->gsm );
 }
 
-static void gsm_applet_power_down_antenna(GtkWidget* menu, GsmApplet* applet)
+static void 
+gsm_applet_power_down_antenna(GtkWidget* menu, GsmApplet* applet)
 {
     //TODO notify user
     moko_gsmd_connection_set_antenna_power( applet->gsm, FALSE );
 }
 
-G_MODULE_EXPORT GtkWidget* mb_panel_applet_create(const char* id, 
GtkOrientation orientation)
+G_MODULE_EXPORT GtkWidget* 
+mb_panel_applet_create(const char* id, GtkOrientation orientation)
 {
     MokoPanelApplet* mokoapplet = MOKO_PANEL_APPLET(moko_panel_applet_new());
 
     GsmApplet* applet;
     applet = g_slice_new(GsmApplet);
-    applet->image = GTK_IMAGE(gtk_image_new_from_file( PKGDATADIR 
"/SignalStrength_NR.png" ) );
+    applet->image = gtk_image_new_from_file( PKGDATADIR 
"/SignalStrength_NR.png" );
     applet->gprs_mode = FALSE;
     gtk_widget_set_name( GTK_WIDGET(applet->image), "openmoko-gsm-applet" );
     g_object_weak_ref( G_OBJECT(applet->image), (GWeakNotify) gsm_applet_free, 
applet );
@@ -87,7 +110,7 @@
     g_signal_connect( G_OBJECT(applet->gsm), "signal-strength-changed", 
G_CALLBACK(gsm_applet_update_signal_strength), applet );
 
     // tap-with-hold menu (NOTE: temporary: left button atm.)
-    GtkMenu* menu = gtk_menu_new();
+    GtkMenu* menu = GTK_MENU (gtk_menu_new());
     GtkWidget* item1 = gtk_menu_item_new_with_label( "Power-Up GSM Antenna" );
     g_signal_connect( G_OBJECT(item1), "activate", 
G_CALLBACK(gsm_applet_power_up_antenna), applet );
     gtk_menu_shell_append( GTK_MENU_SHELL(menu), item1 );
@@ -99,6 +122,6 @@
     gtk_menu_shell_append( GTK_MENU_SHELL(menu), item3 );
     gtk_widget_show_all( GTK_WIDGET(menu) );
 
-    moko_panel_applet_set_popup( mokoapplet, menu, 
MOKO_PANEL_APPLET_CLICK_POPUP );
+    moko_panel_applet_set_popup( mokoapplet, GTK_WIDGET (menu), 
MOKO_PANEL_APPLET_CLICK_POPUP );
     return GTK_WIDGET(mokoapplet);
-};
+}




--- End Message ---
--- Begin Message ---
Author: njp
Date: 2007-08-16 18:05:42 +0200 (Thu, 16 Aug 2007)
New Revision: 2718

Modified:
   trunk/src/target/OM-2007.2/libraries/libmokogsmd2/ChangeLog
   
trunk/src/target/OM-2007.2/libraries/libmokogsmd2/libmokogsmd/moko-gsmd-connection.c
   
trunk/src/target/OM-2007.2/libraries/libmokogsmd2/libmokogsmd/moko-gsmd-connection.h
Log:
2007-08-16  Neil J. Patel  <[EMAIL PROTECTED]>

        * libmokogsmd/moko-gsmd-connection.c:
        (moko_gsmd_connection_set_antenna_power),
        (moko_gsmd_connection_send_pin),
        (moko_gsmd_connection_network_register),
        (moko_gsmd_connection_voice_accept),
        (moko_gsmd_connection_voice_hangup),
        (moko_gsmd_connection_voice_dial),
        (moko_gsmd_connection_voice_dtmf),
        (moko_gsmd_connection_trigger_signal_strength_event):
        Add g_return_if_fail's to all public api so we are safe if the 
functions are
        called without the corrent arguments, or if the *self is not valid.

        * libmokogsmd/moko-gsmd-connection.h:
        Add comments to separate the different type's of signals.

Modified: trunk/src/target/OM-2007.2/libraries/libmokogsmd2/ChangeLog
===================================================================
--- trunk/src/target/OM-2007.2/libraries/libmokogsmd2/ChangeLog 2007-08-16 
15:44:55 UTC (rev 2717)
+++ trunk/src/target/OM-2007.2/libraries/libmokogsmd2/ChangeLog 2007-08-16 
16:05:42 UTC (rev 2718)
@@ -1,3 +1,20 @@
+2007-08-16  Neil J. Patel  <[EMAIL PROTECTED]>
+
+       * libmokogsmd/moko-gsmd-connection.c:
+       (moko_gsmd_connection_set_antenna_power),
+       (moko_gsmd_connection_send_pin),
+       (moko_gsmd_connection_network_register),
+       (moko_gsmd_connection_voice_accept),
+       (moko_gsmd_connection_voice_hangup),
+       (moko_gsmd_connection_voice_dial),
+       (moko_gsmd_connection_voice_dtmf),
+       (moko_gsmd_connection_trigger_signal_strength_event):
+       Add g_return_if_fail's to all public api so we are safe if the 
functions are
+       called without the corrent arguments, or if the *self is not valid.
+
+       * libmokogsmd/moko-gsmd-connection.h:
+       Add comments to separate the different type's of signals.
+
 2007-08-15  Neil J. Patel  <[EMAIL PROTECTED]>
 
        * libmokogsmd/moko-gsmd-connection.c:

Modified: 
trunk/src/target/OM-2007.2/libraries/libmokogsmd2/libmokogsmd/moko-gsmd-connection.c
===================================================================
--- 
trunk/src/target/OM-2007.2/libraries/libmokogsmd2/libmokogsmd/moko-gsmd-connection.c
        2007-08-16 15:44:55 UTC (rev 2717)
+++ 
trunk/src/target/OM-2007.2/libraries/libmokogsmd2/libmokogsmd/moko-gsmd-connection.c
        2007-08-16 16:05:42 UTC (rev 2718)
@@ -447,19 +447,29 @@
 void 
 moko_gsmd_connection_set_antenna_power(MokoGsmdConnection* self, gboolean on)
 {
-    MokoGsmdConnectionPrivate* priv = GSMD_CONNECTION_GET_PRIVATE(self);
+    MokoGsmdConnectionPrivate* priv;
+    gint result;
+    
+    g_return_if_fail ( MOKO_IS_GSMD_CONNECTION ( self ) );
+    priv  = GSMD_CONNECTION_GET_PRIVATE( self );
+
     g_return_if_fail( priv->handle );
-    int result = lgsm_phone_power( priv->handle, on ? 1 : 0 );
+    
+    result = lgsm_phone_power( priv->handle, on ? 1 : 0 );
     g_debug( "lgsm_phone_power returned %d", result );
 }
 
 void 
 moko_gsmd_connection_send_pin(MokoGsmdConnection* self, const gchar* pin)
 {
-    MokoGsmdConnectionPrivate* priv = GSMD_CONNECTION_GET_PRIVATE(self);
-    g_return_if_fail( priv->handle );
+    MokoGsmdConnectionPrivate* priv;
+    
+    g_return_if_fail ( MOKO_IS_GSMD_CONNECTION ( self ) );
     g_return_if_fail( pin );
     g_return_if_fail( strlen( pin ) >= 4 );
+    priv  = GSMD_CONNECTION_GET_PRIVATE( self );
+
+    g_return_if_fail( priv->handle );
     /*
      * FIXME lgsm_pin_auth is not yet implemented, so we call lgsm_pin 
      * directly...
@@ -471,35 +481,57 @@
 void 
 moko_gsmd_connection_network_register(MokoGsmdConnection* self)
 {
-    MokoGsmdConnectionPrivate* priv = GSMD_CONNECTION_GET_PRIVATE(self);
+    MokoGsmdConnectionPrivate* priv;
+    
+    g_return_if_fail ( MOKO_IS_GSMD_CONNECTION ( self ) );
+    priv  = GSMD_CONNECTION_GET_PRIVATE( self );
+    
     g_return_if_fail( priv->handle );
+    
     lgsm_netreg_register( priv->handle, 0 );
 }
 
 void 
 moko_gsmd_connection_voice_accept(MokoGsmdConnection* self)
 {
-    MokoGsmdConnectionPrivate* priv = GSMD_CONNECTION_GET_PRIVATE(self);
+    MokoGsmdConnectionPrivate* priv;
+    
+    g_return_if_fail ( MOKO_IS_GSMD_CONNECTION ( self ) );
+    priv  = GSMD_CONNECTION_GET_PRIVATE( self );
+    
     g_return_if_fail( priv->handle );
+
     lgsm_voice_in_accept( priv->handle );
 }
 
 void 
 moko_gsmd_connection_voice_hangup(MokoGsmdConnection* self)
 {
-    MokoGsmdConnectionPrivate* priv = GSMD_CONNECTION_GET_PRIVATE(self);
+    MokoGsmdConnectionPrivate* priv;
+    
+    g_return_if_fail ( MOKO_IS_GSMD_CONNECTION ( self ) );
+    priv  = GSMD_CONNECTION_GET_PRIVATE( self );
+    
     g_return_if_fail( priv->handle );
+    
     lgsm_voice_hangup( priv->handle );
 }
 
 void 
 moko_gsmd_connection_voice_dial(MokoGsmdConnection* self, const gchar* number)
 {
-    MokoGsmdConnectionPrivate* priv = GSMD_CONNECTION_GET_PRIVATE(self);
-    g_return_if_fail( priv->handle );
+    MokoGsmdConnectionPrivate* priv;
+    struct lgsm_addr addr;   
+
+    g_return_if_fail ( MOKO_IS_GSMD_CONNECTION (self) );
     g_return_if_fail( number );
     g_return_if_fail( strlen( number ) > 2 );
-    struct lgsm_addr addr;
+
+    priv  = GSMD_CONNECTION_GET_PRIVATE( self );
+    
+    g_return_if_fail( priv->handle );
+    
+
     addr.type = 129; /* ??? */
     g_stpcpy( &addr.addr[0], number );
     lgsm_voice_out_init( priv->handle, &addr );
@@ -508,15 +540,27 @@
 void 
 moko_gsmd_connection_voice_dtmf(MokoGsmdConnection* self, const gchar number)
 {
-    MokoGsmdConnectionPrivate* priv = GSMD_CONNECTION_GET_PRIVATE(self);
+    MokoGsmdConnectionPrivate* priv;
+    
+    g_return_if_fail ( MOKO_IS_GSMD_CONNECTION (self) );
+    
+    priv  = GSMD_CONNECTION_GET_PRIVATE( self );
+    
     g_return_if_fail( priv->handle );
+    
     lgsm_voice_dtmf( priv->handle, number );
 }
 
 void 
 moko_gsmd_connection_trigger_signal_strength_event(MokoGsmdConnection* self)
 {
-    MokoGsmdConnectionPrivate* priv = GSMD_CONNECTION_GET_PRIVATE(self);
+    MokoGsmdConnectionPrivate* priv;
+    
+    g_return_if_fail ( MOKO_IS_GSMD_CONNECTION (self) );
+    
+    priv  = GSMD_CONNECTION_GET_PRIVATE( self );
+    
     g_return_if_fail( priv->handle );
+    
     lgsm_signal_quality( priv->handle );
 }

Modified: 
trunk/src/target/OM-2007.2/libraries/libmokogsmd2/libmokogsmd/moko-gsmd-connection.h
===================================================================
--- 
trunk/src/target/OM-2007.2/libraries/libmokogsmd2/libmokogsmd/moko-gsmd-connection.h
        2007-08-16 15:44:55 UTC (rev 2717)
+++ 
trunk/src/target/OM-2007.2/libraries/libmokogsmd2/libmokogsmd/moko-gsmd-connection.h
        2007-08-16 16:05:42 UTC (rev 2718)
@@ -56,6 +56,8 @@
     /* SMS signals */
 
     /* GPRS signals */
+    
+    /* Misc signals */
     void (*incoming_clip) (MokoGsmdConnection *self, const gchar *number);
     void (*network_registration) (MokoGsmdConnection *self,
                                   int type,




--- End Message ---
--- Begin Message ---
Author: laforge
Date: 2007-08-17 09:50:24 +0200 (Fri, 17 Aug 2007)
New Revision: 2719

Modified:
   trunk/src/host/dfu-util/src/sam7dfu.c
Log:
make dfu-util produce a working binary on Win32 platforms


Modified: trunk/src/host/dfu-util/src/sam7dfu.c
===================================================================
--- trunk/src/host/dfu-util/src/sam7dfu.c       2007-08-16 16:05:42 UTC (rev 
2718)
+++ trunk/src/host/dfu-util/src/sam7dfu.c       2007-08-17 07:50:24 UTC (rev 
2719)
@@ -15,6 +15,11 @@
 #include "dfu.h"
 #include "usb_dfu.h"
 
+/* ugly hack for Win32 */
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
 int sam7dfu_do_upload(struct usb_dev_handle *usb_handle, int interface, 
                      int xfer_size, const char *fname)
 {
@@ -76,7 +81,7 @@
        if (!buf)
                return -ENOMEM;
 
-       fd = open(fname, O_RDONLY);
+       fd = open(fname, O_RDONLY|O_BINARY);
        if (fd < 0) {
                perror(fname);
                ret = fd;




--- End Message ---
--- Begin Message ---
Author: laforge
Date: 2007-08-17 10:29:08 +0200 (Fri, 17 Aug 2007)
New Revision: 2720

Modified:
   trunk/src/target/gsm/include/gsmd/sms.h
   trunk/src/target/gsm/include/gsmd/usock.h
   trunk/src/target/gsm/include/libgsmd/misc.h
   trunk/src/target/gsm/include/libgsmd/sms.h
   trunk/src/target/gsm/src/gsmd/sms_cb.c
   trunk/src/target/gsm/src/gsmd/usock.c
   trunk/src/target/gsm/src/libgsmd/lgsm_internals.h
   trunk/src/target/gsm/src/libgsmd/libgsmd.c
   trunk/src/target/gsm/src/libgsmd/libgsmd_sms.c
   trunk/src/target/gsm/src/libgsmd/libgsmd_voicecall.c
   trunk/src/target/gsm/src/util/shell.c
Log:
From: Andrzej Zaborowski <[EMAIL PROTECTED]>
Date: Thu, 26 Jul 2007 00:32:38 +0200
Subject: [PATCH] SMSC and Preferred Storage operations.

This adds setting and retrieval of SMS storage stats (memory type, used
entries, all entries), and of the default service centre (SMSC) number for
outgoing messages.  The operation of setting a new SMSC number is untested
because my SIM doesn't seem to allow this (that or I did something wrong). New
"libgmsd-tool -m shell" commands for testing are also added.

Other changes in this patch:
 * The third, optional, parameter to +CMGL: is a string, not an integer as I
wrongly assumed earlier, this is now corrected.
 * Rename libgsmd API functions starting with lgsmd_.. to lgsm_.. for
consistency with all other identifiers.
 * Move lgsm_send_simple() to libgsmd.c and add a prototype in
lgsm_internals.h, this eliminates some compile-time warnings.



Modified: trunk/src/target/gsm/include/gsmd/sms.h
===================================================================
--- trunk/src/target/gsm/include/gsmd/sms.h     2007-08-17 07:50:24 UTC (rev 
2719)
+++ trunk/src/target/gsm/include/gsmd/sms.h     2007-08-17 08:29:08 UTC (rev 
2720)
@@ -11,6 +11,9 @@
 int sms_pdu_to_msg(struct gsmd_sms_list *dst, const u_int8_t *src,
                int pdulen, int len);
 
+extern const char *ts0705_memtype_name[];
+int parse_memtype(char *memtype);
+
 #endif /* __GSMD__ */
 
 #endif

Modified: trunk/src/target/gsm/include/gsmd/usock.h
===================================================================
--- trunk/src/target/gsm/include/gsmd/usock.h   2007-08-17 07:50:24 UTC (rev 
2719)
+++ trunk/src/target/gsm/include/gsmd/usock.h   2007-08-17 08:29:08 UTC (rev 
2720)
@@ -329,6 +329,29 @@
        int is_last;
 };
 
+/* Refer to GSM 07.05 subclause 3.1 */
+enum ts0705_mem_type {
+       GSM0705_MEMTYPE_NONE,
+       GSM0705_MEMTYPE_BROADCAST,
+       GSM0705_MEMTYPE_ME_MESSAGE,
+       GSM0705_MEMTYPE_MT,
+       GSM0705_MEMTYPE_SIM,
+       GSM0705_MEMTYPE_TA,
+       GSM0705_MEMTYPE_SR,
+};
+
+/* Refer to GSM 07.05 subclause 3.2.2 */
+struct __gsmd_sms_storage {
+       u_int8_t memtype;
+       u_int8_t pad[3];
+       u_int16_t used;
+       u_int16_t total;
+} __attribute__ ((packed));
+
+struct gsmd_sms_storage {
+       struct __gsmd_sms_storage mem[3];
+} __attribute__ ((packed));
+
 /* Refer to GSM 07.07 subclause 8.12 */
 struct gsmd_phonebook_readrg {
        u_int8_t index1;

Modified: trunk/src/target/gsm/include/libgsmd/misc.h
===================================================================
--- trunk/src/target/gsm/include/libgsmd/misc.h 2007-08-17 07:50:24 UTC (rev 
2719)
+++ trunk/src/target/gsm/include/libgsmd/misc.h 2007-08-17 08:29:08 UTC (rev 
2720)
@@ -65,11 +65,6 @@
 /* CLIP, CLIR, COLP, Call Forwarding, Call Waiting, Call Deflecting */
 /* TBD */
 
-
-/* SMS related functions */
-/* TBD */
-
-
 /* GPRS related functions */
 /* TBD */
 

Modified: trunk/src/target/gsm/include/libgsmd/sms.h
===================================================================
--- trunk/src/target/gsm/include/libgsmd/sms.h  2007-08-17 07:50:24 UTC (rev 
2719)
+++ trunk/src/target/gsm/include/libgsmd/sms.h  2007-08-17 08:29:08 UTC (rev 
2720)
@@ -61,16 +61,30 @@
 extern int lgsm_sms_read(struct lgsm_handle *lh, int index);
 
 /* Delete Message */
-extern int lgsmd_sms_delete(struct lgsm_handle *lh, 
+extern int lgsm_sms_delete(struct lgsm_handle *lh,
                const struct lgsm_sms_delete *sms_del);
 
 /* Send Message */
-extern int lgsmd_sms_send(struct lgsm_handle *lh, const struct lgsm_sms *sms);
+extern int lgsm_sms_send(struct lgsm_handle *lh, const struct lgsm_sms *sms);
 
 /* Write Message to Memory */
-extern int lgsmd_sms_write(struct lgsm_handle *lh, 
+extern int lgsm_sms_write(struct lgsm_handle *lh,
                const struct lgsm_sms_write *sms_write);
 
+/* Retrieve SMS storage information */
+extern int lgsm_sms_get_storage(struct lgsm_handle *lh);
+
+/* Set preferred SMS storage */
+extern int lgsm_sms_set_storage(struct lgsm_handle *lh,
+               enum ts0705_mem_type mem1, enum ts0705_mem_type mem2,
+               enum ts0705_mem_type mem3);
+
+/* Retrieve current default service centre address */
+extern int lgsm_sms_get_smsc(struct lgsm_handle *lh);
+
+/* Set new default service centre address */
+extern int lgsm_sms_set_smsc(struct lgsm_handle *lh, const char *number);
+
 /* Packing of 7-bit characters, refer to GSM 03.38 subclause 6.1.2.1.1 */
 extern int packing_7bit_character(const char *src, struct lgsm_sms *dest);
 

Modified: trunk/src/target/gsm/src/gsmd/sms_cb.c
===================================================================
--- trunk/src/target/gsm/src/gsmd/sms_cb.c      2007-08-17 07:50:24 UTC (rev 
2719)
+++ trunk/src/target/gsm/src/gsmd/sms_cb.c      2007-08-17 08:29:08 UTC (rev 
2720)
@@ -38,17 +38,7 @@
 #include <gsmd/usock.h>
 #include <gsmd/unsolicited.h>
 
-enum ts0705_mem_type {
-       GSM0705_MEMTYPE_NONE,
-       GSM0705_MEMTYPE_BROADCAST,
-       GSM0705_MEMTYPE_ME_MESSAGE,
-       GSM0705_MEMTYPE_MT,
-       GSM0705_MEMTYPE_SIM,
-       GSM0705_MEMTYPE_TA,
-       GSM0705_MEMTYPE_SR,
-};
-
-static const char *ts0705_memtype_name[] = {
+const char *ts0705_memtype_name[] = {
        [GSM0705_MEMTYPE_NONE]          = "NONE",
        [GSM0705_MEMTYPE_BROADCAST]     = "BM",
        [GSM0705_MEMTYPE_ME_MESSAGE]    = "ME",
@@ -58,7 +48,7 @@
        [GSM0705_MEMTYPE_SR]            = "SR",
 };
 
-static inline int parse_memtype(char *memtype)
+inline int parse_memtype(char *memtype)
 {
        int i;
 
@@ -70,76 +60,6 @@
        return GSM0705_MEMTYPE_NONE;
 }
 
-/* TODO: move to headers */
-struct __gsmd_sms_storage {
-       u_int8_t memtype;
-       u_int8_t pad[3];
-       u_int16_t used;
-       u_int16_t total;
-} __attribute__ ((packed));
-
-struct gsmd_sms_storage {
-       struct __gsmd_sms_storage mem[3];
-} __attribute__ ((packed));
-
-static int usock_cpms_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
-{
-       struct gsmd_user *gu = ctx;
-       struct gsmd_ucmd *ucmd = ucmd_alloc(sizeof(struct gsmd_sms_storage));
-       struct gsmd_sms_storage *gss = (typeof(gss)) ucmd->buf;
-       char buf[3][3];
-
-       DEBUGP("entering(cmd=%p, gu=%p)\n", cmd, gu);
-
-       if (!ucmd)
-               return -ENOMEM;
-
-       ucmd->hdr.version = GSMD_PROTO_VERSION;
-       ucmd->hdr.msg_type = GSMD_MSG_SMS;
-       ucmd->hdr.msg_subtype = GSMD_SMS_GET_MSG_STORAGE;
-       ucmd->hdr.len = sizeof(struct gsmd_sms_storage);
-       ucmd->hdr.id = cmd->id;
-
-       if (sscanf(resp, "+CPMS: \"%2[A-Z]\",%hi,%hi,"
-                               "\"%2[A-Z]\",%hi,%hi,\"%2[A-Z]\",%hi,%hi",
-                               buf[0], &gss->mem[0].used, &gss->mem[0].total,
-                               buf[1], &gss->mem[1].used, &gss->mem[1].total,
-                               buf[2], &gss->mem[2].used, &gss->mem[2].total)
-                       < 9) {
-               talloc_free(ucmd);
-               return -EINVAL;
-       }
-
-       gss->mem[0].memtype = parse_memtype(buf[0]);
-       gss->mem[1].memtype = parse_memtype(buf[1]);
-       gss->mem[2].memtype = parse_memtype(buf[2]);
-
-       usock_cmd_enqueue(ucmd, gu);
-
-       return 0;
-}
-
-/* main unix socket SMS receiver */
-static int usock_rcv_sms(struct gsmd_user *gu, struct gsmd_msg_hdr *gph,
-                        int len)
-{
-       struct gsmd_atcmd *cmd;
-
-       switch (gph->msg_subtype) {
-       case GSMD_SMS_GET_SERVICE_CENTRE:
-               return;
-       case GSMD_SMS_SET_SERVICE_CENTRE:
-               return;
-       case GSMD_SMS_SET_MSG_STORAGE:
-               return;
-       case GSMD_SMS_GET_MSG_STORAGE:
-               cmd = atcmd_fill("AT+CPMS?", 8 + 1, usock_cpms_cb, gu, 0);
-               break;
-       }
-
-       return atcmd_submit(gu->gsmd, cmd);
-}
-
 /* main unix socket Cell Broadcast receiver */
 static int usock_rcv_cb(struct gsmd_user *gu, struct gsmd_msg_hdr *gph,
                        int len)

Modified: trunk/src/target/gsm/src/gsmd/usock.c
===================================================================
--- trunk/src/target/gsm/src/gsmd/usock.c       2007-08-17 07:50:24 UTC (rev 
2719)
+++ trunk/src/target/gsm/src/gsmd/usock.c       2007-08-17 08:29:08 UTC (rev 
2720)
@@ -39,6 +39,7 @@
 #include <gsmd/usock.h>
 #include <gsmd/talloc.h>
 #include <gsmd/ts0707.h>
+#include <gsmd/sms.h>
 
 static void *__ucmd_ctx, *__gu_ctx;
 
@@ -525,7 +526,7 @@
        if (
                        sscanf(resp, "+CMGL: %i,%i,,%i\n%n",
                                &idx, &stat, &len, &cr) < 3 &&
-                       sscanf(resp, "+CMGL: %i,%i,%*i,%i\n%n",
+                       sscanf(resp, "+CMGL: %i,%i,\"%*[^\"]\",%i\n%n",
                                &idx, &stat, &len, &cr) < 3)
                return -EINVAL;
        if (len > 164)
@@ -669,6 +670,65 @@
        return 0;
 }
 
+static int usock_cpms_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
+{
+       struct gsmd_user *gu = ctx;
+       struct gsmd_ucmd *ucmd = ucmd_alloc(sizeof(struct gsmd_sms_storage));
+       struct gsmd_sms_storage *gss = (typeof(gss)) ucmd->buf;
+       char buf[3][3];
+
+       DEBUGP("entering(cmd=%p, gu=%p)\n", cmd, gu);
+
+       if (!ucmd)
+               return -ENOMEM;
+
+       ucmd->hdr.version = GSMD_PROTO_VERSION;
+       ucmd->hdr.msg_type = GSMD_MSG_SMS;
+       ucmd->hdr.msg_subtype = GSMD_SMS_GET_MSG_STORAGE;
+       ucmd->hdr.len = sizeof(struct gsmd_sms_storage);
+       ucmd->hdr.id = cmd->id;
+
+       if (sscanf(resp, "+CPMS: \"%2[A-Z]\",%hi,%hi,"
+                               "\"%2[A-Z]\",%hi,%hi,\"%2[A-Z]\",%hi,%hi",
+                               buf[0], &gss->mem[0].used, &gss->mem[0].total,
+                               buf[1], &gss->mem[1].used, &gss->mem[1].total,
+                               buf[2], &gss->mem[2].used, &gss->mem[2].total)
+                       < 9) {
+               talloc_free(ucmd);
+               return -EINVAL;
+       }
+
+       gss->mem[0].memtype = parse_memtype(buf[0]);
+       gss->mem[1].memtype = parse_memtype(buf[1]);
+       gss->mem[2].memtype = parse_memtype(buf[2]);
+
+       usock_cmd_enqueue(ucmd, gu);
+
+       return 0;
+}
+
+static int usock_get_smsc_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
+{
+       struct gsmd_user *gu = ctx;
+       struct gsmd_ucmd *ucmd;
+       struct gsmd_addr *ga;
+
+       ucmd = gsmd_ucmd_fill(sizeof(struct gsmd_addr), GSMD_MSG_SMS,
+                       GSMD_SMS_GET_SERVICE_CENTRE, cmd->id);
+       if (!ucmd)
+               return -ENOMEM;
+
+       ga = (struct gsmd_addr *) ucmd->buf;
+       if (sscanf(resp, "+CSCA: \"%31[^\"]\",%hhi",
+                               ga->number, &ga->type) < 2) {
+               talloc_free(ucmd);
+               return -EINVAL;
+       }
+
+       usock_cmd_enqueue(ucmd, gu);
+       return 0;
+}
+
 static const char *gsmd_cmgl_stat[] = {
        "REC UNREAD", "REC READ", "STO UNSENT", "STO SENT", "ALL",
 };
@@ -681,6 +741,8 @@
        struct gsmd_sms_delete *gsd;
        struct gsmd_sms_submit *gss;
        struct gsmd_sms_write *gsw;
+       struct gsmd_addr *ga;
+       enum ts0705_mem_type *storage;
        int *stat, *index;
        int atcmd_len;
        char buf[1024];
@@ -693,7 +755,6 @@
                if (*stat < 0 || *stat > 4)
                        return -EINVAL;
 
-               /* FIXME: should we set <mem1> to "SM"/"ME" before that? */
                if (gu->gsmd->flags & GSMD_FLAG_SMS_FMT_TEXT)
                        atcmd_len = sprintf(buf, "AT+CMGL=\"%s\"",
                                        gsmd_cmgl_stat[*stat]);
@@ -702,8 +763,6 @@
 
                cmd = atcmd_fill(buf, atcmd_len + 1,
                                &sms_list_cb, gu, gph->id);
-               if (!cmd)
-                       return -ENOMEM;
                break;
 
        case GSMD_SMS_READ:
@@ -711,13 +770,10 @@
                        return -EINVAL;
                index = (int *) ((void *)gph + sizeof(*gph));
 
-               /* FIXME: should we set <mem1> to "SM"/"ME" before that? */
                atcmd_len = sprintf(buf, "AT+CMGR=%i", *index);
 
                cmd = atcmd_fill(buf, atcmd_len + 1,
                                 &sms_read_cb, gu, gph->id);
-               if (!cmd)
-                       return -ENOMEM;
                break;
 
        case GSMD_SMS_SEND:
@@ -740,8 +796,6 @@
                buf[atcmd_len ++] = 0;
 
                cmd = atcmd_fill(buf, atcmd_len, &sms_send_cb, gu, gph->id);
-               if (!cmd)
-                       return -ENOMEM;
                break;
 
        case GSMD_SMS_WRITE:
@@ -751,7 +805,6 @@
                if (gsw->stat > 4)
                        return -EINVAL;
 
-               /* FIXME: should we set <mem2> to "SM"/"ME" before that? */
                if (gu->gsmd->flags & GSMD_FLAG_SMS_FMT_TEXT) {
                        atcmd_len = sprintf(buf, "AT+CMGW=\"%s\"\n%.*s",
                                        gsw->sms.addr.number,
@@ -768,8 +821,6 @@
                buf[atcmd_len ++] = 0;
 
                cmd = atcmd_fill(buf, atcmd_len, &sms_write_cb, gu, gph->id);
-               if (!cmd)
-                       return -ENOMEM;
                break;
 
        case GSMD_SMS_DELETE:
@@ -781,19 +832,49 @@
                                gsd->index, gsd->delflg);
 
                cmd = atcmd_fill(buf, atcmd_len + 1,
-                                &sms_delete_cb, gu, gph->id);
-               if (!cmd)
-                       return -ENOMEM;
+                               &sms_delete_cb, gu, gph->id);
+               break;
+
+       case GSMD_SMS_GET_MSG_STORAGE:
+               cmd = atcmd_fill("AT+CPMS?", 8 + 1, usock_cpms_cb, gu, 0);
+               break;
+
+       case GSMD_SMS_SET_MSG_STORAGE:
+               if (len < sizeof(*gph) + 3 * sizeof(enum ts0705_mem_type))
+                       return -EINVAL;
+               storage = (enum ts0705_mem_type *)
+                       ((void *) gph + sizeof(*gph));
+               atcmd_len = sprintf(buf, "AT+CPMS=\"%s\",\"%s\",\"%s\"",
+                               ts0705_memtype_name[storage[0]],
+                               ts0705_memtype_name[storage[1]],
+                               ts0705_memtype_name[storage[2]]);
+               cmd = atcmd_fill(buf, atcmd_len + 1,
+                               &null_cmd_cb, gu, gph->id);
                break;  
+
+       case GSMD_SMS_GET_SERVICE_CENTRE:
+               cmd = atcmd_fill("AT+CSCA?", 8 + 1, &usock_get_smsc_cb, gu, 0);
+               break;
+
+       case GSMD_SMS_SET_SERVICE_CENTRE:
+               if (len < sizeof(*gph) + sizeof(struct gsmd_addr))
+                       return -EINVAL;
+               ga = (struct gsmd_addr *) ((void *) gph + sizeof(*gph));
+               atcmd_len = sprintf(buf, "AT+CSCA=\"%s\",%i",
+                               ga->number, ga->type);
+               cmd = atcmd_fill(buf, atcmd_len + 1,
+                               &null_cmd_cb, gu, gph->id);
+               break;
+
        default:
                return -EINVAL;
        }
 
+       if (!cmd)
+               return -ENOMEM;
+
        gsmd_log(GSMD_DEBUG, "%s\n", cmd ? cmd->buf : 0);
-       if (cmd)
-               return atcmd_submit(gu->gsmd, cmd);
-       else
-               return 0;
+       return atcmd_submit(gu->gsmd, cmd);
 }
 
 #if 0

Modified: trunk/src/target/gsm/src/libgsmd/lgsm_internals.h
===================================================================
--- trunk/src/target/gsm/src/libgsmd/lgsm_internals.h   2007-08-17 07:50:24 UTC 
(rev 2719)
+++ trunk/src/target/gsm/src/libgsmd/lgsm_internals.h   2007-08-17 08:29:08 UTC 
(rev 2720)
@@ -11,6 +11,7 @@
 };
 
 int lgsm_send(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh);
+int lgsm_send_simple(struct lgsm_handle *lh, int type, int sub_type);
 struct gsmd_msg_hdr *lgsm_gmh_fill(int type, int subtype, int payload_len);
 #define lgsm_gmh_free(x)       free(x)
 

Modified: trunk/src/target/gsm/src/libgsmd/libgsmd.c
===================================================================
--- trunk/src/target/gsm/src/libgsmd/libgsmd.c  2007-08-17 07:50:24 UTC (rev 
2719)
+++ trunk/src/target/gsm/src/libgsmd/libgsmd.c  2007-08-17 08:29:08 UTC (rev 
2720)
@@ -207,3 +207,20 @@
        return gmh;
 }
 
+int lgsm_send_simple(struct lgsm_handle *lh, int type, int sub_type)
+{
+       struct gsmd_msg_hdr *gmh;
+       int rc;
+
+       gmh = lgsm_gmh_fill(type, sub_type, 0);
+       if (!gmh)
+               return -ENOMEM;
+       rc = lgsm_send(lh, gmh);
+       if (rc < gmh->len + sizeof(*gmh)) {
+               lgsm_gmh_free(gmh);
+               return -EIO;
+       }
+       lgsm_gmh_free(gmh);
+
+       return 0;
+}

Modified: trunk/src/target/gsm/src/libgsmd/libgsmd_sms.c
===================================================================
--- trunk/src/target/gsm/src/libgsmd/libgsmd_sms.c      2007-08-17 07:50:24 UTC 
(rev 2719)
+++ trunk/src/target/gsm/src/libgsmd/libgsmd_sms.c      2007-08-17 08:29:08 UTC 
(rev 2720)
@@ -57,7 +57,7 @@
        return 0;
 }
 
-int lgsmd_sms_delete(struct lgsm_handle *lh, 
+int lgsm_sms_delete(struct lgsm_handle *lh,
                const struct lgsm_sms_delete *sms_del)
 {
        struct gsmd_msg_hdr *gmh;
@@ -83,7 +83,7 @@
        return 0;
 }
 
-int lgsmd_number2addr(struct gsmd_addr *dst, const char *src)
+int lgsm_number2addr(struct gsmd_addr *dst, const char *src, int skipplus)
 {
        char *ch;
 
@@ -94,7 +94,7 @@
                        GSMD_TOA_NPI_ISDN |
                        GSMD_TOA_TON_INTERNATIONAL |
                        GSMD_TOA_RESERVED;
-               strcpy(dst->number, src + 1);
+               strcpy(dst->number, src + skipplus);
        } else {
                dst->type =
                        GSMD_TOA_NPI_ISDN |
@@ -109,7 +109,7 @@
        return 0;
 }
 
-int lgsmd_sms_send(struct lgsm_handle *lh,
+int lgsm_sms_send(struct lgsm_handle *lh,
                const struct lgsm_sms *sms)
 {
        /* FIXME: only support PDU mode */
@@ -123,7 +123,7 @@
                return -ENOMEM;
        gss = (struct gsmd_sms_submit *) gmh->data;
 
-       if (lgsmd_number2addr(&gss->addr, sms->addr))
+       if (lgsm_number2addr(&gss->addr, sms->addr, 1))
                return -EINVAL;
 
        gss->payload.has_header = 0;
@@ -142,7 +142,7 @@
        return 0;
 }
 
-int lgsmd_sms_write(struct lgsm_handle *lh,
+int lgsm_sms_write(struct lgsm_handle *lh,
                const struct lgsm_sms_write *sms_write)
 {
        /* FIXME: only support PDU mode */
@@ -158,7 +158,7 @@
 
        gsw->stat = sms_write->stat;
 
-       if (lgsmd_number2addr(&gsw->sms.addr, sms_write->sms.addr))
+       if (lgsm_number2addr(&gsw->sms.addr, sms_write->sms.addr, 1))
                return -EINVAL;
 
        gsw->sms.payload.has_header = 0;
@@ -178,6 +178,60 @@
        return 0;
 }
 
+int lgsm_sms_get_storage(struct lgsm_handle *lh)
+{
+       return lgsm_send_simple(lh, GSMD_MSG_SMS, GSMD_SMS_GET_MSG_STORAGE);
+}
+
+int lgsm_sms_set_storage(struct lgsm_handle *lh, enum ts0705_mem_type mem1,
+               enum ts0705_mem_type mem2, enum ts0705_mem_type mem3)
+{
+       struct gsmd_msg_hdr *gmh =
+               lgsm_gmh_fill(GSMD_MSG_SMS, GSMD_SMS_SET_MSG_STORAGE,
+                               3 * sizeof(enum ts0705_mem_type));
+       if (!gmh)
+               return -ENOMEM;
+
+       ((enum ts0705_mem_type *) gmh->data)[0] = mem1;
+       ((enum ts0705_mem_type *) gmh->data)[1] = mem2;
+       ((enum ts0705_mem_type *) gmh->data)[2] = mem3;
+
+       if (lgsm_send(lh, gmh) < gmh->len + sizeof(*gmh)) {
+               lgsm_gmh_free(gmh);
+               return -EIO;
+       }
+
+       lgsm_gmh_free(gmh);
+       return 0;
+}
+
+int lgsm_sms_get_smsc(struct lgsm_handle *lh)
+{
+       return lgsm_send_simple(lh, GSMD_MSG_SMS, GSMD_SMS_GET_SERVICE_CENTRE);
+}
+
+int lgsm_sms_set_smsc(struct lgsm_handle *lh, const char *number)
+{
+       struct gsmd_msg_hdr *gmh =
+               lgsm_gmh_fill(GSMD_MSG_SMS, GSMD_SMS_SET_SERVICE_CENTRE,
+                               sizeof(struct gsmd_addr));
+       if (!gmh)
+               return -ENOMEM;
+
+       if (lgsm_number2addr((struct gsmd_addr *) gmh->data, number, 0)) {
+               lgsm_gmh_free(gmh);
+               return -EINVAL;
+       }
+
+       if (lgsm_send(lh, gmh) < gmh->len + sizeof(*gmh)) {
+               lgsm_gmh_free(gmh);
+               return -EIO;
+       }
+
+       lgsm_gmh_free(gmh);
+       return 0;
+}
+
 int packing_7bit_character(const char *src, struct lgsm_sms *dest)
 {
        int i,j = 0;

Modified: trunk/src/target/gsm/src/libgsmd/libgsmd_voicecall.c
===================================================================
--- trunk/src/target/gsm/src/libgsmd/libgsmd_voicecall.c        2007-08-17 
07:50:24 UTC (rev 2719)
+++ trunk/src/target/gsm/src/libgsmd/libgsmd_voicecall.c        2007-08-17 
08:29:08 UTC (rev 2720)
@@ -28,24 +28,6 @@
 
 #include "lgsm_internals.h"
 
-int lgsm_send_simple(struct lgsm_handle *lh, int type, int sub_type)
-{
-       struct gsmd_msg_hdr *gmh;
-       int rc;
-
-       gmh = lgsm_gmh_fill(type, sub_type, 0);
-       if (!gmh)
-               return -ENOMEM;
-       rc = lgsm_send(lh, gmh);
-       if (rc < gmh->len + sizeof(*gmh)) {
-               lgsm_gmh_free(gmh);
-               return -EIO;
-       }
-       lgsm_gmh_free(gmh);
-
-       return 0;
-}
-
 int lgsm_voice_out_init(struct lgsm_handle *lh,
                        const struct lgsm_addr *number)
 {

Modified: trunk/src/target/gsm/src/util/shell.c
===================================================================
--- trunk/src/target/gsm/src/util/shell.c       2007-08-17 07:50:24 UTC (rev 
2719)
+++ trunk/src/target/gsm/src/util/shell.c       2007-08-17 08:29:08 UTC (rev 
2720)
@@ -81,15 +81,22 @@
        char payload[GSMD_SMS_DATA_MAXLEN];
        int *result;
        struct gsmd_sms_list *sms;
-       static const char *type[] = { "Unread", "Received", "Unsent", "Sent" };
+       struct gsmd_addr *addr;
+       struct gsmd_sms_storage *mem;
+       static const char *msgtype[] = {
+               "Unread", "Received", "Unsent", "Sent"
+       };
+       static const char *memtype[] = {
+               "Unknown", "Broadcast", "Me message", "MT", "SIM", "TA", "SR"
+       };
 
        switch (gmh->msg_subtype) {
        case GSMD_SMS_LIST:
        case GSMD_SMS_READ:
                sms = (struct gsmd_sms_list *) ((void *) gmh + sizeof(*gmh));
                printf("%s message %i from/to %s%s, at %i%i-%i%i-%i%i "
-                               "%i%i:%i%i:%i%i, GMT%c%i\n", type[sms->stat],
-                               sms->index,
+                               "%i%i:%i%i:%i%i, GMT%c%i\n",
+                               msgtype[sms->stat], sms->index,
                                ((sms->addr.type & __GSMD_TOA_TON_MASK) ==
                                 GSMD_TOA_TON_INTERNATIONAL) ? "+" : "",
                                sms->addr.number,
@@ -166,6 +173,30 @@
                        break;
                }
                break;
+       case GSMD_SMS_GET_MSG_STORAGE:
+               mem = (struct gsmd_sms_storage *)
+                       ((void *) gmh + sizeof(*gmh));
+               printf("mem1: %s (%i)       Occupied: %i / %i\n",
+                               memtype[mem->mem[0].memtype],
+                               mem->mem[0].memtype,
+                               mem->mem[0].used,
+                               mem->mem[0].total);
+               printf("mem2: %s (%i)       Occupied: %i / %i\n",
+                               memtype[mem->mem[1].memtype],
+                               mem->mem[1].memtype,
+                               mem->mem[1].used,
+                               mem->mem[1].total);
+               printf("mem3: %s (%i)       Occupied: %i / %i\n",
+                               memtype[mem->mem[2].memtype],
+                               mem->mem[2].memtype,
+                               mem->mem[2].used,
+                               mem->mem[2].total);
+               break;
+       case GSMD_SMS_GET_SERVICE_CENTRE:
+               addr = (struct gsmd_addr *) ((void *) gmh + sizeof(*gmh));
+               printf("Number of the default Service Centre is %s\n",
+                               addr->number);
+               break;
        default:
                return -EINVAL;
        }
@@ -244,6 +275,10 @@
                "\tsr\tSMS Read (sr=index)\n"
                "\tss\tSMS Send (ss=number,text)\n"
                "\tsw\tSMS Write (sw=stat,number,text)\n"
+               "\tsm\tSMS Storage stats\n"
+               "\tsM\tSMS Set preferred storage (sM=mem1,mem2,mem3)\n"
+               "\tsc\tSMS Show Service Centre\n"
+               "\tsC\tSMS Set Service Centre (sC=number)\n"
                "\tq\tQuit\n"
                );
 }
@@ -357,7 +392,7 @@
                        } else if ( !strncmp(buf, "pd", 2)) {
                                printf("Delete Phonebook Entry\n");             
                
                                ptr = strchr(buf, '=');
-                               lgsmd_pb_del_entry(lgsmh, atoi(ptr+1));         
                
+                               lgsmd_pb_del_entry(lgsmh, atoi(ptr+1));
                        } else if ( !strncmp(buf, "prr", 3)) {  
                                printf("Read Phonebook Entries\n");
                                struct lgsm_phonebook_readrg pb_readrg;
@@ -371,7 +406,7 @@
                        } else if ( !strncmp(buf, "pr", 2)) {   
                                printf("Read Phonebook Entry\n");
                                ptr = strchr(buf, '=');                         
-                               lgsm_pb_read_entry(lgsmh, atoi(ptr+1)); 
+                               lgsm_pb_read_entry(lgsmh, atoi(ptr+1));
                        } else if ( !strncmp(buf, "pf", 2)) {
                                printf("Find Phonebook Entry\n");
                                struct lgsm_phonebook_find pb_find;
@@ -402,7 +437,7 @@
                                lgsmd_pb_write_entry(lgsmh, &pb);
                        } else if ( !strncmp(buf, "ps", 2)) {   
                                printf("Get Phonebook Support\n");
-                               lgsm_pb_get_support(lgsmh);                     
        
+                               lgsm_pb_get_support(lgsmh);
                        } else if ( !strncmp(buf, "sd", 2)) {           
                                printf("Delete SMS\n");                 
                                struct lgsm_sms_delete sms_del;
@@ -412,7 +447,7 @@
                                ptr = strchr(buf, ',');
                                sms_del.delflg = atoi(ptr+1);   
                        
-                               lgsmd_sms_delete(lgsmh, &sms_del);              
                
+                               lgsm_sms_delete(lgsmh, &sms_del);
                        } else if ( !strncmp(buf, "sl", 2)) {           
                                printf("List SMS\n");   
                                ptr = strchr(buf, '='); 
@@ -433,7 +468,7 @@
                                sms.addr[fcomma-ptr-1] = '\0';
                                packing_7bit_character(fcomma+1, &sms);
 
-                               lgsmd_sms_send(lgsmh, &sms);
+                               lgsm_sms_send(lgsmh, &sms);
                        } else if ( !strncmp(buf, "sw", 2)) {   
                                printf("Write SMS\n");                          
                                struct lgsm_sms_write sms_write;
@@ -448,7 +483,30 @@
                                packing_7bit_character(
                                                lcomma+1, &sms_write.sms);
 
-                               lgsmd_sms_write(lgsmh, &sms_write);
+                               lgsm_sms_write(lgsmh, &sms_write);
+                       } else if (!strncmp(buf, "sm", 2)) {
+                               printf("Get SMS storage preferences\n");
+                               lgsm_sms_get_storage(lgsmh);
+                       } else if (!strncmp(buf, "sM", 2)) {
+                               int mem[3];
+
+                               printf("Set SMS storage preferences\n");
+                               if (sscanf(buf, "sM=%i,%i,%i", mem, mem + 1,
+                                                       mem + 2) < 3)
+                                       printf("No.\n");
+                               else
+                                       lgsm_sms_set_storage(lgsmh, mem[0],
+                                                       mem[1], mem[2]);
+                       } else if (!strncmp(buf, "sc", 2)) {
+                               printf("Get the default SMSC\n");
+                               lgsm_sms_get_smsc(lgsmh);
+                       } else if (!strncmp(buf, "sC", 2)) {
+                               printf("Set the default SMSC\n");
+                               ptr = strchr(buf, '=');
+                               if (!ptr || strlen(ptr) < 6)
+                                       printf("No.\n");
+                               else
+                                       lgsm_sms_set_smsc(lgsmh, ptr + 1);
                        } else {
                                printf("Unknown command `%s'\n", buf);
                        }




--- End Message ---
_______________________________________________
commitlog mailing list
[email protected]
http://lists.openmoko.org/mailman/listinfo/commitlog

Reply via email to