This commit was generated by cvs2svn to compensate for changes in r136,
[gnokii.git] / common / newmodules / n3110.c
diff --git a/common/newmodules/n3110.c b/common/newmodules/n3110.c
new file mode 100644 (file)
index 0000000..e250180
--- /dev/null
@@ -0,0 +1,191 @@
+/*\r
+\r
+  G N O K I I\r
+\r
+  A Linux/Unix toolset and driver for Nokia mobile phones.\r
+\r
+  Released under the terms of the GNU GPL, see file COPYING for more details.\r
+\r
+  This file provides an API for accessing functions on the N3110 and similar\r
+  phones.\r
+\r
+*/\r
+\r
+/* "Turn on" prototypes in n-3110.h */\r
+\r
+#define __n_3110_c \r
+\r
+/* System header files */\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+\r
+#ifdef WIN32
+  #include "misc_win32.h"
+#endif
+/* Various header file */\r
+#ifndef VC6\r
+  #include "config.h"\r
+#endif\r
+\r
+#include "misc.h"\r
+#include "gsm-api.h"\r
+#include "gsm-common.h"\r
+#include "files/cfgreader.h"\r
+#include "newmodules/n3110.h"\r
+#include "newmodules/n6110.h"\r
+#include "gsm-networks.h"\r
+\r
+/* Here we initialise model specific functions. */\r
+\r
+GSM_Functions N3110_Functions = {\r
+  N3110_Initialise,\r
+  N3110_DispatchMessage,\r
+  NULL_Terminate,\r
+  NULL_KeepAlive,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,  \r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r
+  NOTSUPPORTED,\r  NOTSUPPORTED,
+  NOTSUPPORTED,
+  NOTSUPPORTED,
+  NOTSUPPORTED,
+  NOTSUPPORTED,
+  NOTSUPPORTED,
+  NOTSUPPORTED,
+  NOTSUPPORTED,
+  NOTSUPPORTED,
+  NOTSUPPORTED
+};\r
+\r
+
+
+/* for all these Phones we support N3110 */\r
+\r
+GSM_Information N3110_Information = {\r
+  "", /* Supported models in FBUS */\r
+  "",/* Supported models in MBUS */\r
+  "",/* Supported models in FBUS over infrared */\r
+  "",/* Supported models in FBUS over DLR3 */\r
+  "",
+  "", /* Supported models in FBUS over Irda sockets */
+  "",
+  "3110|3810|8110|8110i|8148|8148i", /* FBUS version 1 */
+  4,                     /* Max RF Level */\r
+  0,                     /* Min RF Level */\r
+  GRF_Arbitrary,         /* RF level units */\r
+  4,                     /* Max Battery Level */\r
+  0,                     /* Min Battery Level */\r
+  GBU_Arbitrary,         /* Battery level units */\r
+  GDT_None,              /* No date/time support */\r
+  GDT_None,             /* No alarm support */\r
+  0                      /* Max alarms = 0 */\r
+};\r
+\r
+/* Initialise variables and state machine. */\r
+GSM_Error N3110_Initialise(char *port_device, char *initlength,\r
+                          GSM_ConnectionType connection,\r
+                          void (*rlp_callback)(RLP_F96Frame *frame))\r
+{\r
+  u8 init[20]={0x02, 0x01, 0x07, 0xa2, 0x88, 0x81, 0x21, 0x55, 0x63, 0xa8,
+               0x00, 0x00, 0x07, 0xa3, 0xb8, 0x81, 0x20, 0x15, 0x63, 0x80};
+
+  unsigned char init_char = N6110_SYNC_BYTE;
+
+  int count;
+  int InitLength;
+
+  GSM_Error error;
+  \r  if (Protocol->Initialise(port_device,initlength,connection,rlp_callback)!=GE_NONE)\r
+  {\r
+    return GE_NOTSUPPORTED;\r
+  }\r
+
+  InitLength = atoi(initlength);
+
+  if ((strcmp(initlength, "default") == 0) || (InitLength == 0)) {
+    InitLength = 250;  /* This is the usual value, lower may work. */
+  }
+
+#ifdef DEBUG
+  fprintf(stdout,_("Writing init chars...."));
+#endif
+
+  /* Initialise link with phone or what have you */
+  /* Send init string to phone, this is a bunch of 0x55 characters. Timing is
+     empirical. */
+  for (count = 0; count < InitLength; count ++) {
+    usleep(1000);
+    Protocol->WritePhone(1,&init_char);
+  }
+
+#ifdef DEBUG
+  fprintf(stdout,_("Done\n"));  
+#endif
+
+  error=NULL_SendMessageSequence (200, &CurrentGetIMEIError, 20, 0x15, init);\r
+  if (error!=GE_NONE) return error;\r
+\r
+  CurrentLinkOK = true;                           \r
+\r
+  return (GE_NONE);\r
+}\r
+\r
+
+void N3110_DispatchMessage(u16 MessageLength, u8 *MessageBuffer, u8 MessageType)
+{
+}