'orig2001_11_27_22_58'.
Sprout from ats 2001-11-27 22:01:28 UTC short ':pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Tue Nov 27 22:58 CET 2001'
Cherrypick from orig 2001-11-27 22:01:16 UTC short ':pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Tue Nov 27 22:58 CET 2001':
common/links/fbus-3110.c
common/phones/ateric.c
common/phones/atnok.c
common/phones/atsie.c
include/links/fbus-3110.h
include/phones/ateric.h
include/phones/atgen.h
include/phones/atnok.h
include/phones/atsie.h
Cherrypick from mygnokii 2001-11-27 22:01:30 UTC short ':pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Tue Nov 27 22:58 CET 2001':
utils/sendsms
--- /dev/null
+/*
+
+ $Id$
+
+ G N O K I I
+
+ A Linux/Unix toolset and driver for Nokia mobile phones.
+
+ Copyright (C) 2000 Hugh Blemings & Pavel JanÃk ml.
+
+ Released under the terms of the GNU GPL, see file COPYING for more details.
+
+ This file provides an API for accessing functions via fbus.
+ See README for more details on supported mobile phones.
+
+ The various routines are called FBUS_(whatever).
+
+ $Log$
+ Revision 1.1.1.2 2001/11/27 22:01:16 short
+ :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Tue Nov 27 22:58 CET 2001
+
+ Revision 1.3 2001/11/27 12:19:01 pkot
+ Cleanup, indentation, ANSI complaint preprocesor symbols (Jan Kratochvil, me)
+
+ Revision 1.2 2001/11/09 14:25:04 pkot
+ DEBUG cleanups
+
+ Revision 1.1 2001/11/09 12:55:07 pkot
+ Forgot about fbus support for 3110. FIXME: is it really needed?
+
+
+*/
+
+/* System header files */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+/* Various header file */
+
+#include "config.h"
+#include "misc.h"
+#include "gsm-common.h"
+#include "gsm-ringtones.h"
+#include "gsm-networks.h"
+#include "gsm-statemachine.h"
+#include "links/utils.h"
+
+#ifndef WIN32
+# include "device.h"
+#else
+# include "win32/winserial.h"
+# define device_write(a, b) WriteCommBlock(a, b)
+# define device_read(a, b) ReadCommBlock(a, b)
+# define sleep(x) Sleep((x) * 1000)
+# define usleep(x) Sleep(((x) < 1000) ? 1 : ((x) / 1000))
+#endif
+
+#define __links_fbus_3110_c
+#include "links/fbus-3110.h"
+
+/* FIXME - pass device_* the link stuff?? */
+/* FIXME - win32 stuff! */
+
+
+/* Some globals */
+
+static GSM_Link *glink;
+static GSM_Statemachine *statemachine;
+static FB3110_Link flink; /* FBUS specific stuff, internal to this file */
+
+
+/*--------------------------------------------*/
+
+bool FB3110_OpenSerial(void)
+{
+ /* Open device. */
+#ifdef WIN32
+ if (OpenConnection(glink->PortDevice, FB3110_RX_StateMachine, NULL)) {
+#else
+ if (!device_open(glink->PortDevice, false, false, false, GCT_Serial)) {
+#endif
+ perror(_("Couldn't open FBUS device"));
+ return false;
+ }
+ device_changespeed(115200);
+
+ return (true);
+}
+
+
+/* RX_State machine for receive handling. Called once for each character
+ received from the phone. */
+
+void FB3110_RX_StateMachine(unsigned char rx_byte)
+{
+ FB3110_IncomingFrame *i = &flink.i;
+ int count;
+
+ switch (i->State) {
+
+ /* Phone is currently off. Wait for 0x55 before
+ restarting */
+ case FB3110_RX_Discarding:
+ if (rx_byte != 0x55)
+ break;
+
+ /* Seen 0x55, restart at 0x04 */
+ i->State = FB3110_RX_Sync;
+
+ dprintf("restarting.\n");
+
+ /* FALLTHROUGH */
+
+ /* Messages from the phone start with an 0x04 during
+ "normal" operation, 0x03 when in data/fax mode. We
+ use this to "synchronise" with the incoming data
+ stream. */
+ case FB3110_RX_Sync:
+ if (rx_byte == 0x04 || rx_byte == 0x03) {
+ i->FrameType = rx_byte;
+ i->Checksum = rx_byte;
+ i->State = FB3110_RX_GetLength;
+ }
+ break;
+
+ /* Next byte is the length of the message including
+ the message type byte but not including the checksum. */
+ case FB3110_RX_GetLength:
+ i->FrameLength = rx_byte;
+ i->BufferCount = 0;
+ i->Checksum ^= rx_byte;
+ i->State = FB3110_RX_GetMessage;
+ break;
+
+ /* Get each byte of the message. We deliberately
+ get one too many bytes so we get the checksum
+ here as well. */
+ case FB3110_RX_GetMessage:
+ i->Buffer[i->BufferCount] = rx_byte;
+ i->BufferCount++;
+
+ if (i->BufferCount > FB3110_MAX_FRAME_LENGTH) {
+ dprintf("FBUS: Message buffer overun - resetting\n");
+ i->State = FB3110_RX_Sync;
+ break;
+ }
+
+ /* If this is the last byte, it's the checksum. */
+ if (i->BufferCount > i->FrameLength) {
+
+ /* Is the checksum correct? */
+ if (rx_byte == i->Checksum) {
+
+ if (i->FrameType == 0x03) {
+ /* FIXME: modify Buffer[0] to code FAX frame types */
+ }
+
+ dprintf("--> %02x:%02x:", i->FrameType, i->FrameLength);
+ for (count = 0; count < i->BufferCount; count++)
+ dprintf("%02hhx:", i->Buffer[count]);
+ dprintf("\n");
+ /* Transfer message to state machine */
+ SM_IncomingFunction(statemachine, i->Buffer[0], i->Buffer, i->FrameLength);
+
+ /* Send an ack */
+ FB3110_TX_SendAck(i->Buffer, i->FrameLength);
+
+ } else {
+ /* Checksum didn't match so ignore. */
+ dprintf("Bad checksum!\n");
+ }
+ i->State = FB3110_RX_Sync;
+ }
+ i->Checksum ^= rx_byte;
+ break;
+ }
+}
+
+
+/* This is the main loop function which must be called regularly */
+/* timeout can be used to make it 'busy' or not */
+
+GSM_Error FB3110_Loop(struct timeval *timeout)
+{
+#ifndef WIN32
+ unsigned char buffer[255];
+ int count, res;
+
+ res = device_select(timeout);
+ if (res > 0) {
+ res = device_read(buffer, 255);
+ for (count = 0; count < res; count++)
+ FB3110_RX_StateMachine(buffer[count]);
+ } else
+ return GE_TIMEOUT;
+
+ /* This traps errors from device_read */
+ if (res > 0)
+ return GE_NONE;
+ else
+ return GE_INTERNALERROR;
+#else
+ return GE_NONE;
+#endif
+}
+
+
+
+/* Prepares the message header and sends it, prepends the
+ message start byte (0x01) and other values according
+ the value specified when called. Calculates checksum
+ and then sends the lot down the pipe... */
+
+GSM_Error FB3110_TX_SendFrame(u8 message_length, u8 message_type, u8 sequence_byte, u8 * buffer)
+{
+
+ u8 out_buffer[FB3110_MAX_TRANSMIT_LENGTH];
+ int count, current = 0;
+ unsigned char checksum;
+
+ /* Check message isn't too long, once the necessary
+ header and trailer bytes are included. */
+ if ((message_length + 5) > FB3110_MAX_TRANSMIT_LENGTH) {
+ fprintf(stderr, _("FB3110_TX_SendFrame - message too long!\n"));
+ return (GE_INTERNALERROR);
+ }
+
+ /* Now construct the message header. */
+ out_buffer[current++] = FB3110_FRAME_ID; /* Start of frame */
+ out_buffer[current++] = message_length + 2; /* Length */
+ out_buffer[current++] = message_type; /* Type */
+ out_buffer[current++] = sequence_byte; /* Sequence number */
+
+ /* Copy in data if any. */
+ if (message_length != 0) {
+ memcpy(out_buffer + current, buffer, message_length);
+ current += message_length;
+ }
+
+ /* Now calculate checksum over entire message
+ and append to message. */
+ checksum = 0;
+ for (count = 0; count < current; count++)
+ checksum ^= out_buffer[count];
+ out_buffer[current++] = checksum;
+
+ dprintf("<-- ");
+ for (count = 0; count < current; count++)
+ dprintf("%02hhx:", out_buffer[count]);
+ dprintf("\n");
+
+ /* Send it out... */
+ if (device_write(out_buffer, current) != current)
+ return (GE_INTERNALERROR);
+
+ return (GE_NONE);
+}
+
+
+/* Main function to send an fbus message */
+
+GSM_Error FB3110_SendMessage(u16 messagesize, u8 messagetype, void *message)
+{
+ u8 seqnum;
+
+ FB3110_UpdateSequenceNumber();
+ seqnum = flink.RequestSequenceNumber;
+
+ return FB3110_TX_SendFrame(messagesize, messagetype, seqnum, message);
+}
+
+
+/* Sends the "standard" acknowledge message back to the phone in
+ response to a message it sent automatically or in response to
+ a command sent to it. The ack. algorithm isn't 100% understood
+ at this time. */
+
+void FB3110_TX_SendAck(u8 *message, int length)
+{
+ u8 t = message[0];
+
+ switch (t) {
+ case 0x0a:
+ /* We send 0x0a messages to make a call so don't ack. */
+ case 0x0c:
+ /* We send 0x0c message to answer to incoming call
+ so don't ack */
+ case 0x0f:
+ /* We send 0x0f message to hang up so don't ack */
+ case 0x15:
+ /* 0x15 messages are sent by the phone in response to the
+ init sequence sent so we don't acknowledge them! */
+ case 0x20:
+ /* We send 0x20 message to phone to send DTFM, so don't ack */
+ case 0x23:
+ /* We send 0x23 messages to phone as a header for outgoing SMS
+ messages. So we don't acknowledge it. */
+ case 0x24:
+ /* We send 0x24 messages to phone as a header for storing SMS
+ messages in memory. So we don't acknowledge it. :) */
+ case 0x25:
+ /* We send 0x25 messages to phone to request an SMS message
+ be dumped. Thus we don't acknowledge it. */
+ case 0x26:
+ /* We send 0x26 messages to phone to delete an SMS message
+ so it's not acknowledged. */
+ case 0x3f:
+ /* We send an 0x3f message to the phone to request a different
+ type of status dump - this one seemingly concerned with
+ SMS message center details. Phone responds with an ack to
+ our 0x3f request then sends an 0x41 message that has the
+ actual data in it. */
+ case 0x4a:
+ /* 0x4a message is a response to our 0x4a request, assumed to
+ be a keepalive message of sorts. No response required. */
+ case 0x4c:
+ /* We send 0x4c to request IMEI, Revision and Model info. */
+ break;
+ case 0x27:
+ /* 0x27 messages are a little different in that both ends of
+ the link send them. So, first we have to check if this
+ is an acknowledgement or a message to be acknowledged */
+ if (length == 0x02) break;
+ default:
+ /* Standard acknowledge seems to be to return an empty message
+ with the sequence number set to equal the sequence number
+ sent minus 0x08. */
+ if (FB3110_TX_SendFrame(0, t, (message[1] & 0x1f) - 0x08, NULL) != GE_NONE)
+ dprintf("Failed to acknowledge message type %02x.\n", t);
+ else
+ dprintf("Acknowledged message type %02x.\n", t);
+ }
+}
+
+
+/* Initialise variables and start the link */
+/* newlink is actually part of state - but the link code should not anything about state */
+/* state is only passed around to allow for muliple state machines (one day...) */
+
+GSM_Error FB3110_Initialise(GSM_Link *newlink, GSM_Statemachine *state)
+{
+ unsigned char init_char = 0x55;
+ unsigned char count;
+ static int try = 0;
+
+ try++;
+ if (try > 2) return GE_DEVICEOPENFAILED;
+ /* 'Copy in' the global structures */
+ glink = newlink;
+ statemachine = state;
+
+ /* Fill in the link functions */
+ glink->Loop = &FB3110_Loop;
+ glink->SendMessage = &FB3110_SendMessage;
+
+ /* Check for a valid init length */
+ if (glink->InitLength == 0)
+ glink->InitLength = 100;
+
+ /* Start up the link */
+
+ flink.RequestSequenceNumber = 0x10;
+
+ if (!FB3110_OpenSerial()) return GE_DEVICEOPENFAILED;
+
+ /* Send init string to phone, this is a bunch of 0x55 characters.
+ Timing is empirical. I believe that we need/can do this for any
+ phone to get the UART synced */
+ for (count = 0; count < glink->InitLength; count++) {
+ usleep(1000);
+ device_write(&init_char, 1);
+ }
+
+ /* Init variables */
+ flink.i.State = FB3110_RX_Sync;
+
+ return GE_NONE;
+}
+
+
+/* Any command we originate must have a unique SequenceNumber.
+ Observation to date suggests that these values startx at 0x10
+ and cycle up to 0x17 before repeating again. Perhaps more
+ accurately, the numbers cycle 0,1,2,3..7 with bit 4 of the byte
+ premanently set. */
+
+void FB3110_UpdateSequenceNumber(void)
+{
+ flink.RequestSequenceNumber++;
+
+ if (flink.RequestSequenceNumber > 0x17 || flink.RequestSequenceNumber < 0x10) {
+ flink.RequestSequenceNumber = 0x10;
+ }
+}
--- /dev/null
+/*
+
+ $Id$
+
+ G N O K I I
+
+ A Linux/Unix toolset and driver for mobile phones.
+
+ Copyright 2001 Manfred Jonsson <manfred.jonsson@gmx.de>
+
+ Released under the terms of the GNU GPL, see file COPYING for more details.
+
+ This file provides functions specific to at commands on ericsson
+ phones. See README for more details on supported mobile phones.
+
+ $Log$
+ Revision 1.1.1.1 2001/11/25 21:59:14 short
+ :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001
+
+ Revision 1.1 2001/11/19 13:03:18 pkot
+ nk3110.c cleanup
+
+*/
+
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#include "misc.h"
+#include "gsm-common.h"
+#include "gsm-statemachine.h"
+#include "phones/generic.h"
+#include "phones/atgen.h"
+#include "phones/ateric.h"
+#include "links/atbus.h"
+#include "links/cbus.h"
+
+
+static GSM_Error GetMemoryStatus(GSM_Data *data, GSM_Statemachine *state)
+{
+ char req[128];
+ GSM_Error ret;
+
+ ret = AT_SetMemoryType(data->MemoryStatus->MemoryType, state);
+ if (ret != GE_NONE)
+ return ret;
+ sprintf(req, "AT+CPBR=?\r\n");
+ if (SM_SendMessage(state, 11, GOP_GetMemoryStatus, req) != GE_NONE)
+ return GE_NOTREADY;
+ ret = SM_Block(state, data, GOP_GetMemoryStatus);
+ return ret;
+}
+
+
+static GSM_Error ReplyMemoryStatus(int messagetype, unsigned char *buffer, int length, GSM_Data *data)
+{
+ AT_LineBuffer buf;
+ char *pos;
+
+ buf.line1 = buffer;
+ buf.length= length;
+ splitlines(&buf);
+ if (buf.line1 == NULL)
+ return GE_INVALIDMEMORYTYPE;
+ if (data->MemoryStatus) {
+ if (strstr(buf.line2,"+CPBR")) {
+ pos = strchr(buf.line2, '-');
+ if (pos) {
+ data->MemoryStatus->Used = atoi(++pos);
+ data->MemoryStatus->Free = 0;
+ } else {
+ return GE_NOTSUPPORTED;
+ }
+ }
+ }
+ return GE_NONE;
+}
+
+
+void AT_InitEricsson(GSM_Statemachine *state, char *foundmodel, char *setupmodel) {
+ AT_InsertRecvFunction(GOP_GetMemoryStatus, ReplyMemoryStatus);
+ AT_InsertSendFunction(GOP_GetMemoryStatus, GetMemoryStatus);
+}
--- /dev/null
+/*
+
+ $Id$
+
+ G N O K I I
+
+ A Linux/Unix toolset and driver for mobile phones.
+
+ Copyright 2001 Manfred Jonsson <manfred.jonsson@gmx.de>
+
+ Released under the terms of the GNU GPL, see file COPYING for more details.
+
+ This file provides functions specific to at commands on nokia
+ phones. See README for more details on supported mobile phones.
+
+ $Log$
+ Revision 1.1.1.1 2001/11/25 21:59:14 short
+ :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001
+
+ Revision 1.1 2001/11/19 13:03:18 pkot
+ nk3110.c cleanup
+
+*/
+
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#include "misc.h"
+#include "gsm-common.h"
+#include "gsm-statemachine.h"
+#include "phones/generic.h"
+#include "phones/atgen.h"
+#include "phones/atnok.h"
+#include "links/atbus.h"
+#include "links/cbus.h"
+
+
+AT_SendFunctionType writephonebook;
+
+
+static GSM_Error WritePhonebook(GSM_Data *data, GSM_Statemachine *state)
+{
+ if (writephonebook == NULL)
+ return GE_UNKNOWN;
+ if (data->MemoryStatus->MemoryType == GMT_ME)
+ return GE_NOTSUPPORTED;
+ return (*writephonebook)(data, state);
+}
+
+
+void AT_InitNokia(GSM_Statemachine *state, char *foundmodel, char *setupmodel) {
+ /* block writing of phone memory on nokia phones other than */
+ /* 8210. if you write to the phonebook of a eg 7110 all extended */
+ /* information will be lost. */
+ if (strncasecmp("8210", foundmodel, 4))
+ writephonebook = AT_InsertSendFunction(GOP_WritePhonebook, WritePhonebook);
+}
--- /dev/null
+/*
+
+ $Id$
+
+ G N O K I I
+
+ A Linux/Unix toolset and driver for mobile phones.
+
+ Copyright 2001 Manfred Jonsson <manfred.jonsson@gmx.de>
+
+ Released under the terms of the GNU GPL, see file COPYING for more details.
+
+ This file provides functions specific to at commands on siemens
+ phones. See README for more details on supported mobile phones.
+
+ $Log$
+ Revision 1.1.1.1 2001/11/25 21:59:14 short
+ :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001
+
+ Revision 1.1 2001/11/19 13:03:18 pkot
+ nk3110.c cleanup
+
+*/
+
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#include "misc.h"
+#include "gsm-common.h"
+#include "gsm-statemachine.h"
+#include "phones/generic.h"
+#include "phones/atgen.h"
+#include "phones/atsie.h"
+#include "links/atbus.h"
+#include "links/cbus.h"
+
+
+AT_SendFunctionType writephonebook;
+
+
+static GSM_Error WritePhonebook(GSM_Data *data, GSM_Statemachine *state)
+{
+ GSM_PhonebookEntry newphone;
+ char *rptr, *wptr;
+
+ if (writephonebook == NULL)
+ return GE_UNKNOWN;
+ if (data->PhonebookEntry != NULL) {
+ memcpy(&newphone, data->PhonebookEntry, sizeof(GSM_PhonebookEntry));
+ rptr = data->PhonebookEntry->Name;
+ wptr = newphone.Name;
+ data->PhonebookEntry = &newphone;
+ }
+ return (*writephonebook)(data, state);
+}
+
+
+void AT_InitSiemens(GSM_Statemachine *state, char *foundmodel, char *setupmodel) {
+ /* names for s35 etc must be escaped */
+/*
+ if (foundmodel && !strncasecmp("35", foundmodel + 1, 2))
+ writephonebook = AT_InsertSendFunction(GOP_WritePhonebook, WritePhonebook);
+*/
+}
--- /dev/null
+/*
+
+ $Id$
+
+ G N O K I I
+
+ A Linux/Unix toolset and driver for Nokia mobile phones.
+
+ Copyright (C) 2000 Hugh Blemings & Pavel JanÃk ml.
+
+ Released under the terms of the GNU GPL, see file COPYING for more details.
+
+ This file provides an API for accessing functions via fbus.
+ See README for more details on supported mobile phones.
+
+ The various routines are called FB3110_(whatever).
+
+ $Log$
+ Revision 1.1.1.1 2001/11/25 21:59:22 short
+ :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001
+
+ Revision 1.1 2001/11/09 12:55:07 pkot
+ Forgot about fbus support for 3110. FIXME: is it really needed?
+
+
+*/
+
+#ifndef __links_fbus_3110_h
+#define __links_fbus_3110_h
+
+#include <time.h>
+#include "gsm-statemachine.h"
+
+#ifdef WIN32
+#include <sys/types.h>
+#include <sys/timeb.h>
+#endif
+
+#define FB3110_MAX_FRAME_LENGTH 256
+#define FB3110_MAX_MESSAGE_TYPES 128
+#define FB3110_MAX_TRANSMIT_LENGTH 256
+#define FB3110_MAX_CONTENT_LENGTH 120
+
+/* This byte is at the beginning of all GSM Frames sent over FBUS to Nokia
+ phones. This may have to become a phone dependant parameter... */
+#define FB3110_FRAME_ID 0x01
+
+
+/* States for receive code. */
+
+enum FB3110_RX_States {
+ FB3110_RX_Sync,
+ FB3110_RX_Discarding,
+ FB3110_RX_GetLength,
+ FB3110_RX_GetMessage
+};
+
+
+typedef struct{
+ int Checksum;
+ int BufferCount;
+ enum FB3110_RX_States State;
+ int FrameType;
+ int FrameLength;
+ char Buffer[FB3110_MAX_FRAME_LENGTH];
+} FB3110_IncomingFrame;
+
+typedef struct {
+ u16 message_length;
+ u8 message_type;
+ u8 *buffer;
+} FB3110_OutgoingMessage;
+
+
+typedef struct{
+ FB3110_IncomingFrame i;
+ u8 RequestSequenceNumber;
+} FB3110_Link;
+
+GSM_Error FB3110_Initialise(GSM_Link *newlink, GSM_Statemachine *state);
+
+
+
+#ifdef __links_fbus_3110_c /* Prototype functions for fbus-generic.c only */
+
+bool FB3110_OpenSerial(void);
+void FB3110_RX_StateMachine(unsigned char rx_byte);
+GSM_Error FB3110_TX_SendFrame(u8 message_length, u8 message_type, u8 sequence_byte, u8 *buffer);
+GSM_Error FB3110_SendMessage(u16 messagesize, u8 messagetype, void *message);
+void FB3110_TX_SendAck(u8 *message, int length);
+void FB3110_UpdateSequenceNumber(void);
+
+#endif /* #ifdef __links_fbus_3110_c */
+
+#endif /* #ifndef __links_fbus_3110_h */
--- /dev/null
+/*
+
+ $Id$
+
+ G N O K I I
+
+ A Linux/Unix toolset and driver for mobile phones.
+
+ Copyright 2001 Manfred Jonsson <manfred.jonsson@gmx.de>
+
+ Released under the terms of the GNU GPL, see file COPYING for more details.
+
+ This file provides functions specific to at commands on ericsson
+ phones. See README for more details on supported mobile phones.
+
+ $Log$
+ Revision 1.1.1.1 2001/11/25 21:59:22 short
+ :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001
+
+ Revision 1.1 2001/11/19 13:03:18 pkot
+ nk3110.c cleanup
+
+*/
+
+void AT_InitEricsson(GSM_Statemachine *state, char* foundmodel, char* setupmodel);
--- /dev/null
+/*
+
+ $Id$
+
+ G N O K I I
+
+ A Linux/Unix toolset and driver for mobile phones.
+
+ Copyright 2001 Manfred Jonsson <manfred.jonsson@gmx.de>
+
+ Released under the terms of the GNU GPL, see file COPYING for more details.
+
+ This file provides functions specific to generic at command compatible
+ phones. See README for more details on supported mobile phones.
+
+ $Log$
+ Revision 1.1.1.1 2001/11/25 21:59:22 short
+ :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001
+
+ Revision 1.1 2001/11/19 13:03:18 pkot
+ nk3110.c cleanup
+
+
+*/
+
+typedef GSM_Error (*GSM_RecvFunctionType)(int type, unsigned char *buffer, int length, GSM_Data *data);
+typedef GSM_Error (*AT_SendFunctionType)(GSM_Data *data, GSM_Statemachine *s);
+
+typedef struct {
+ char *line1;
+ char *line2;
+ char *line3;
+ int length;
+} AT_LineBuffer;
+
+GSM_RecvFunctionType AT_InsertRecvFunction(int type, GSM_RecvFunctionType func);
+AT_SendFunctionType AT_InsertSendFunction(int type, AT_SendFunctionType func);
+
+GSM_Error AT_SetMemoryType(GSM_MemoryType mt, GSM_Statemachine *state);
+
+void splitlines(AT_LineBuffer *buf);
+
+char *skipcrlf(char *str);
+char *findcrlf(char *str, int test, int maxlength);
+
--- /dev/null
+/*
+
+ $Id$
+
+ G N O K I I
+
+ A Linux/Unix toolset and driver for mobile phones.
+
+ Copyright 2001 Manfred Jonsson <manfred.jonsson@gmx.de>
+
+ Released under the terms of the GNU GPL, see file COPYING for more details.
+
+ This file provides functions specific to at commands on nokia
+ phones. See README for more details on supported mobile phones.
+
+ $Log$
+ Revision 1.1.1.1 2001/11/25 21:59:22 short
+ :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001
+
+ Revision 1.1 2001/11/19 13:03:18 pkot
+ nk3110.c cleanup
+
+*/
+
+void AT_InitNokia(GSM_Statemachine *state, char* foundmodel, char* setupmodel);
--- /dev/null
+/*
+
+ $Id$
+
+ G N O K I I
+
+ A Linux/Unix toolset and driver for mobile phones.
+
+ Copyright 2001 Manfred Jonsson <manfred.jonsson@gmx.de>
+
+ Released under the terms of the GNU GPL, see file COPYING for more details.
+
+ This file provides functions specific to at commands on siemens
+ phones. See README for more details on supported mobile phones.
+
+ $Log$
+ Revision 1.1.1.1 2001/11/25 21:59:22 short
+ :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001
+
+ Revision 1.1 2001/11/19 13:03:18 pkot
+ nk3110.c cleanup
+
+*/
+
+void AT_InitSiemens(GSM_Statemachine *state, char* foundmodel, char* setupmodel);
--- /dev/null
+#!/bin/bash
+###############################################################################
+#
+# SENDSMS -- Script to send sms by 'gnokii'
+# Author : Gabriele Zappi - Rimini <gzappi@inwind.it>
+# History:
+# feb 17, 2001 Script created (v1.0)
+###############################################################################
+# $Id$
+###############################################################################
+###############################################################################
+# PROGNAME=`basename $0`
+
+# var settings.
+
+PROGNAME=${0##*/}
+VERSION="1.02"
+GNOKII=gnokii
+PID=$$
+SMSDIR=~/tmp/sms
+TMP=~/tmp/SMStmp.$PID
+BACKTITLE="SENDSMS V$VERSION"
+AUTHOR="Gabriele Zappi - Rimini <gzappi@inwind.it>"
+
+help() {
+echo "$PROGNAME: $BACKTITLE - A gnokii interface for sending SMS."
+echo "Written by $AUTHOR"
+
+echo -e "\
+\n\
+Usage: $PROGNAME [OPTION]...\n\
+\n\
+Examples:\n\
+ $PROGNAME # simply run $PROGNAME in standard mode\n\
+ $PROGNAME --simulate # Simulates. doesn't really send sms (for debug)\n\
+ echo \"Hello Beauty ;-)\" | $PROGNAME --smsset\n\
+ # Preset \"Hello Beauty ;-)\" as SMS message.\n\
+ $PROGNAME --smsset < mymessage.txt\n\
+ # Preset contents of file mymessage.txt \n\
+ as SMS message.\n\
+ $PROGNAME --version # Display version, author and quits.\n\
+\n\
+NOTE:\n\
+If you require to pickup number from phone's memory (really from SIM card),\n\
+for the first time, it anyway reads phonebook from your cellular phone. \n\
+(It may take a while... please, be patient ;-) \n\
+\n\
+Available options:\n\
+ --debug, -D May bother with more debugging messages ;-)\n\
+ For debugging purpose.\n\
+ --simul[ate], -S Simulation mode. Doesn't really send SMS by phone. \n\
+ Only simulates. For debugging purpose.\n\
+ --forcememread, -F Forces $PROGNAME to read phonebook from SIM card,\n\
+ and to parse the generated file in order to update\n\
+ the numbers' list (useful only if required to pickup\n\
+ number from the phone's memory). see NOTE.\n\
+ --skipgnokiicheck, -K Skip the test of the presence of binary 'gnokii'.\n\
+ (It must be somewhere in your \$PATH). It allows you\n\
+ to try this script program, even if you don't have\n\
+ 'gnokii' already. ;)\n\
+ --smsset, --setsms Allows you to preset a SMS message from STDIN. (pipe\n\
+ or input redirection).\n\
+ This message will be proposed on the 'SMS message'\n\
+ field during the program input cycle.\n\
+ --help, -h, /h display this help and exit\n\
+ --version, -V output version information and exit"
+echo
+exit 0
+}
+
+acex()
+{
+ rm -rf $TMP >/dev/null 2>&1
+ clear
+ exit $1
+}
+
+parse_stdin() {
+ # Switch initialization
+ SW_DEBUG=no
+ SW_SIMUL=no
+ SW_FORCEMREAD=no
+ SW_SKIPGNOKITST=no
+ SW_PRESETSMS=no
+ PRESETSMS=""
+
+ while [ -n "$1" ]
+ do
+ case "$1" in
+ --help|-h|/h)
+ help
+ ;;
+ --version|-V)
+ echo
+ echo "$BACKTITLE - A gnokii interface for sending SMS."
+ echo "Written by $AUTHOR"
+ echo
+ exit 0
+ ;;
+ --simul*|-S)
+ SW_SIMUL=yes
+ ;;
+ --debug*|-D)
+ SW_DEBUG=yes
+ SW_SIMUL=yes
+ ;;
+ --forcememread|-F)
+ SW_FORCEMREAD=yes
+ ;;
+ --skipgnokiicheck|-K)
+ SW_SKIPGNOKITST=yes
+ ;;
+ --smsset|--msgset|--setsms)
+ SW_PRESETSMS=yes
+ # will read from stdin
+ echo "reading sms from stdin .."
+ PRESETSMS=`cat`
+ ;;
+ *)
+ echo "$PROGNAME: Invalid parameter: "
+ help
+ ;;
+ esac
+ shift
+ done
+}
+
+sure_to_quit() {
+ dialog --backtitle "$BACKTITLE" \
+ --yesno "Really sure to quit? " 6 50
+ if [ $? -eq 0 ]; then
+ acex 0
+ fi
+}
+
+SMS_phoneread() {
+dialog --backtitle "$BACKTITLE" --infobox "Reading phonebook by phone's SIM\n Please wait" 4 40
+$GNOKII --getmemory SM 1 130 > $SMSDIR/.SMlist.temp
+}
+
+SMS_choicefrommem() {
+ # read from phonebook.
+ if [ "$SW_FORCEMREAD" = "yes" ] ; then
+ readsim=1
+ elif [ -s $SMSDIR/.SMlist.sim ]; then
+ dialog --backtitle "INSERT NUMBER(s).." \
+ --yesno "A SIM phonebook file is already present. \
+ Do you want to read phone memory anyway?" 8 60
+ if [ $? -eq 0 ] ; then
+ readsim=1
+ else
+ readsim=0
+ fi
+ else
+ readsim=1
+ fi
+
+ ERROR=0
+ if [ $readsim -eq 1 ] ; then
+ SMS_phoneread
+ if [ $? -ne 0 ] ; then
+ dialog --backtitle "INSERT NUMBER(s).." \
+ --msgbox "ERROR during reading memory from your phone... \
+ Insert manually destination number." 8 60
+ ERROR=1
+ else
+ mv -f $SMSDIR/.SMlist.temp $SMSDIR/.SMlist.sim
+ fi
+ fi
+
+ if [ $ERROR -eq 0 ]; then
+ # Parsing sim file...
+ if [ ! -s $SMSDIR/.SMlist.chklst -o ! -s $SMSDIR/.SMlist.choice \
+ -o $readsim -eq 1 ] ; then
+ > $SMSDIR/.SMlist.menu
+ > $SMSDIR/.SMlist.chklst
+ > $SMSDIR/.SMlist.choice
+ totrows=`cat $SMSDIR/.SMlist.sim | wc -l`
+ rownow=0
+ (while read riga
+ do
+ rownow=`expr $rownow + 1`
+ perc=`expr $rownow \* 100 / $totrows`
+ pos=`echo $riga | cut -f4 -d";"`
+ name=`echo $riga | cut -f1 -d";"`
+ num=`echo $riga | cut -f2 -d";"`
+ if [ -n "$pos" -a -n "$num" ] ; then
+ echo -e "$pos \"$name - $num\"" >> $SMSDIR/.SMlist.menu
+ echo -e "$pos \"$name - $num\" off" >> $SMSDIR/.SMlist.chklst
+ echo "$pos;$num" >> $SMSDIR/.SMlist.choice
+ fi
+ echo $perc
+ done < $SMSDIR/.SMlist.sim) | dialog \
+ --gauge "Parsing phonebook file..." 12 70 0
+ fi
+
+ chkok=0
+ option=0
+ while [ $chkok -eq 0 ]
+ do
+ eval dialog --backtitle \"SENDSM CKECKLIST\" \
+ --checklist \"Check your MEMORY number\(s\).\
+ \\nPress ESC key \for options..... \" \
+ 16 60 9 \
+ `cat $SMSDIR/.SMlist.chklst` 2> $TMP/rspTEMP02
+ option=$?
+ if [ $option -eq 255 ] ; then
+ dialog --backtitle "SENDSM CKECKLIST" --menu \
+ "Options sub-menus for Phonebook choise list:" \
+ 10 50 4 \
+ "1" "Sort by Memory Pos" \
+ "2" "Sort by Names" \
+ "9" "Quit $PROGNAME" 2> $TMP/rspTEMP04
+ if [ $? -eq 0 ]; then
+ sorttype=`cat $TMP/rspTEMP04`
+ case $sorttype in
+ 1) sort -n $SMSDIR/.SMlist.chklst > $TMP/.SMlist.tmp
+ mv -f $TMP/.SMlist.tmp $SMSDIR/.SMlist.chklst
+ ;;
+ 2) sort +1 $SMSDIR/.SMlist.chklst > $TMP/.SMlist.tmp
+ mv -f $TMP/.SMlist.tmp $SMSDIR/.SMlist.chklst
+ ;;
+ 9) sure_to_quit
+ ;;
+ esac
+ fi
+ else
+ chkok=1
+ fi
+ done
+
+ if [ $? -eq 0 ] ; then
+ for val in `cat $TMP/rspTEMP02`
+ do
+ tok1=`eval echo $val`
+ tok2=`grep "^$tok1;" $SMSDIR/.SMlist.choice`
+ tok3=`echo $tok2 | cut -f2 -d";"`
+ if [ -z "$NUMBERS" ] ; then
+ NUMBERS="$tok3"
+ else
+ NUMBERS="$NUMBERS $tok3"
+ fi
+ done
+ fi
+ fi
+}
+
+###########################################################################
+###########################################################################
+# MAIN PROCEDURE #
+###########################################################################
+###########################################################################
+
+parse_stdin $*
+
+# This is the 'help' test...
+# if [ "$1" = "--help" -o "$1" = "/h" ] ; then
+# help
+# fi
+
+if ! type -all "dialog" >/dev/null 2>&1 ; then
+echo
+echo "${PROGNAME}: error:"
+echo "Can't find 'dialog', i can't run without 'dialog' on your system."
+echo "You can get a compiled elf version of 'dialog' from here."
+echo "http://www.tux.org/pub/people/kent-robotti/index.html"
+echo "ftp://ftp.tux.org/pub/people/kent-robotti 'dialog-0.9a-15.elf.tar.gz'"
+echo
+exit 1
+fi
+
+if [ $SW_SKIPGNOKITST = no ] ; then
+ if ! type -all "$GNOKII" >/dev/null 2>&1 ; then
+ echo
+ echo "${PROGNAME}: error:"
+ echo "Can't find 'gnokii'. This script needs 'gnokii' in order to work."
+ echo "You can get a version of 'gnokii' from following links:"
+ echo "GNOKII: http://multivac.fatburen.org/gnokii/ , http://www.gnokii.org/"
+ echo
+ echo " Pavel Janik (who is to thank for a vast part of the 6110 development) "
+ echo "also keeps an ftp archive of some recent things."
+ echo " "
+ echo "Source code and pre-compiled binaries for gnokii are available from "
+ echo "a number of sites"
+ echo
+ echo "ftp.gnokii.org located in California, USA"
+ echo "linuxcare.com.au located in Canberra, Australia"
+ echo "multivac.fatburen.org located in Stockholm, Sweden "
+ echo
+ echo "Pre release versions are kept here, maintained by Pawel Kot"
+ echo "urtica.linuxnews.pl located in Warsaw, Poland"
+ echo
+ echo "MYGNOKII (can handle other newer Nokia models...)"
+ echo "--------"
+ echo "Marcin Wiacek -> mailto:marcin-wiacek@topnet.pl"
+ echo "http://marcin-wiacek.topnet.pl (http://www.fkn.pl/marcinw) -> netmonitor,"
+ echo "firmware, mygnokii (GSM & Nokia)"
+ echo "http://grumble.zereau.com/gnokii/ &"
+ echo "http://www.mds.mdh.se/~cel95eig/mygnokii/ -> mygnokii mirrors"
+ echo
+ exit 1
+ fi
+fi
+
+if [ ! -d ~/tmp ]; then
+mkdir ~/tmp
+chmod 755 ~/tmp
+fi
+
+if [ ! -d $SMSDIR ]; then
+mkdir -p $SMSDIR
+chmod 755 $SMSDIR
+fi
+
+if [ -d $TMP ]; then
+ rm -rf $TMP
+fi
+mkdir -p $TMP
+chmod 700 $TMP
+
+
+echo "$BACKTITLE" > $TMP/txtTEMP01
+echo >> $TMP/txtTEMP01
+echo "Written by Gabriele Zappi <gzappi@inwind.it> " >> $TMP/txtTEMP01
+echo >> $TMP/txtTEMP01
+echo "This script is a front-end to type SMS messages directly" >> $TMP/txtTEMP01
+echo "from your computer and send them using gnokii through" >> $TMP/txtTEMP01
+echo "your cellular phone connected to your computer." >> $TMP/txtTEMP01
+echo >> $TMP/txtTEMP01
+echo "Press [Enter] to continue with SENDSMS." >> $TMP/txtTEMP01
+
+dialog --backtitle "$BACKTITLE" --textbox "$TMP/txtTEMP01" 14 70
+TURN=0
+
+while true
+do
+ echo "Please, enter in the box below, your SMS message." > $TMP/txtTEMP$$
+ echo "Remember that it cannot be longer than 160 chars." >> $TMP/txtTEMP$$
+ echo " " >> $TMP/txtTEMP$$
+ echo "Press [ESC] or [CANCEL] to quit the program. " >> $TMP/txtTEMP$$
+
+ len=999
+ if [ $TURN -eq 0 ]; then
+ if [ "$SW_PRESETSMS" = "yes" ]; then
+ echo "$PRESETSMS" > $TMP/rspTEMP01
+ else
+ > $TMP/rspTEMP01
+ fi
+ fi
+ while test "$len" -le 0 -o "$len" -gt 160
+ do
+ dialog --backtitle "INSERT SMS ....." \
+ --inputbox "`cat $TMP/txtTEMP$$`" 10 70 "`cat $TMP/rspTEMP01`" \
+ 2> $TMP/rspTEMP01
+ if [ $? -ne 0 ] ; then
+ sure_to_quit
+ fi
+ len=`cat $TMP/rspTEMP01 | wc -c `
+
+ if [ $len -le 0 -o $len -gt 160 ] ; then
+ echo "Invalid SMS: It must be < 160 chars and > 0 long.." > $TMP/txtTEMP02
+ dialog --textbox "$TMP/txtTEMP02" 6 70
+ fi
+ done
+
+ NUMBERS=""
+ okcycle=0
+ while [ "$NUMBERS" = "" -o "$okcycle" -eq 0 ]
+ do
+ dialog --backtitle "INSERT NUMBER(s).." \
+ --yesno "would you like to pick up number(s) \
+ from your phone memory" 8 60
+
+
+ if [ $? -eq 0 ] ; then # Yes, gimme num from phonebook.
+ SMS_choicefrommem
+ fi
+
+ # Manual telephone number completion or insertion.
+ echo "Please, insert/modify in the box below, the NUMBER(S)" > $TMP/txtTEMP$$
+ echo "where you want to send the message to. " >> $TMP/txtTEMP$$
+ echo "(Multiple numbers must be separated by a space.) " >> $TMP/txtTEMP$$
+ echo "Press [ESC] or [CANCEL] to quit the program. " >> $TMP/txtTEMP$$
+ echo " " >> $TMP/txtTEMP$$
+ echo "OUTGOING MESSAGE: " >> $TMP/txtTEMP$$
+ echo -n " "
+ cat $TMP/rspTEMP01 | cut -c1-60 >> $TMP/txtTEMP$$
+ cat $TMP/rspTEMP01 | cut -c61-120 >> $TMP/txtTEMP$$
+ cat $TMP/rspTEMP01 | cut -c121-160 >> $TMP/txtTEMP$$
+
+ okcycle=1
+ dialog --backtitle "INSERT NUMBER(s).." \
+ --inputbox "`cat $TMP/txtTEMP$$`" \
+ 16 70 "$NUMBERS" 2> $TMP/rspTEMP03
+
+ if [ $? -ne 0 ] ; then
+ sure_to_quit
+ okcycle=0
+ else
+ NUMBERS=`cat $TMP/rspTEMP03`
+ if [ "$NUMBERS" = "" ] ; then
+ dialog --backtitle "INSERT NUMBER(s).." \
+ --infobox "Number cannot be empty.\n Try again.." 4 28
+ sleep 2
+ okcycle=0
+ fi
+ fi
+ done
+
+ # Last confirmation before sending messages....
+
+ okcycle=0
+ while [ $okcycle -eq 0 ]
+ do
+ echo "Ok. If you confirm the operation, the the SMS" > $TMP/txtTEMP$$
+ echo "is going to be sent to the selected number(s)." >> $TMP/txtTEMP$$
+ echo >> $TMP/txtTEMP$$
+ echo "Press [ESC] to quit the program. " >> $TMP/txtTEMP$$
+ echo "Press [CANCEL] to return to SMS input. " >> $TMP/txtTEMP$$
+ dialog --backtitle "$BACKTITLE" \
+ --yesno "`cat $TMP/txtTEMP$$`" 9 60
+ case $? in
+ 0)
+ okcycle=1;;
+ 1)
+ TURN=`expr $TURN + 1`
+ continue 2;;
+ 255)
+ sure_to_quit ;;
+ esac
+ done
+ TURN=`expr $TURN + 1`
+
+ for num in $NUMBERS
+ do
+ # echo "Sending sms to number $num ... "
+ dialog --backtitle "$BACKTITLE" --infobox "Sending sms to number $num ...\n Please wait" 4 45
+ if [ "$SW_SIMUL" = "yes" ] ; then
+ sleep 2
+ else
+ $GNOKII --sendsms $num < $TMP/rspTEMP01 > /dev/null 2>&1
+ fi
+ if [ $? -eq 0 ] ; then
+ dialog --backtitle "$BACKTITLE" \
+ --infobox "Message correctly sent to number $num !" 3 55
+ else
+ dialog --backtitle "$BACKTITLE" \
+ --infobox "Sent Failed to num $num! Sorry!" 3 55
+ fi
+ sleep 2
+ done
+
+done
+
+
+acex 0
+# zap - fin qui
+