:pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001
[gnokii.git] / include / links / fbus.h
1 /*
2
3   $Id$
4
5   G N O K I I
6
7   A Linux/Unix toolset and driver for Nokia mobile phones.
8
9   Copyright (C) 2000 Hugh Blemings & Pavel Janík ml.
10   Copyright (C) 2000 Chris Kemp
11
12   Released under the terms of the GNU GPL, see file COPYING for more details.
13
14   This file provides an API for accessing functions via fbus. 
15   See README for more details on supported mobile phones.
16
17   The various routines are called FBUS_(whatever).
18
19   $Log$
20   Revision 1.1.1.1  2001/11/25 21:59:22  short
21   :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001
22
23   Revision 1.5  2001/11/15 12:04:06  pkot
24   Faster initialization for 6100 series (don't check for dlr3 cable)
25
26   Revision 1.4  2001/03/21 23:36:08  chris
27   Added the statemachine
28   This will break gnokii --identify and --monitor except for 6210/7110
29
30   Revision 1.3  2001/03/19 23:44:57  pkot
31   DLR3 cable support
32
33   Revision 1.2  2001/03/13 01:23:19  pkot
34   Windows updates (Manfred Jonsson)
35
36   Revision 1.1  2001/02/21 19:57:12  chris
37   More fiddling with the directory layout
38
39   Revision 1.3  2001/02/06 21:15:36  chris
40   Preliminary irda support for 7110 etc.  Not well tested!
41
42   Revision 1.2  2001/01/17 02:54:55  chris
43   More 7110 work.  Use with care! (eg it is not possible to delete phonebook entries)
44   I can now edit my phonebook in xgnokii but it is 'work in progress'.
45
46   Revision 1.1  2001/01/14 22:47:01  chris
47   Preliminary 7110 support (dlr9 only) and the beginnings of a new structure
48
49
50 */
51
52 #ifndef __links_fbus_h
53 #define __links_fbus_h
54
55 #include <time.h>
56 #include "gsm-statemachine.h"
57
58 #ifdef WIN32
59 #include <sys/types.h>
60 #include <sys/timeb.h>
61 #endif
62
63 #define FBUS_MAX_FRAME_LENGTH 256
64 #define FBUS_MAX_MESSAGE_TYPES 128
65 #define FBUS_MAX_TRANSMIT_LENGTH 256
66 #define FBUS_MAX_CONTENT_LENGTH 120
67
68 /* Nokia mobile phone. */
69 #define FBUS_DEVICE_PHONE 0x00
70
71 /* Our PC. */
72 #define FBUS_DEVICE_PC 0x0c
73
74
75 /* This byte is at the beginning of all GSM Frames sent over FBUS to Nokia
76    phones.  This may have to become a phone dependant parameter... */
77 #define FBUS_FRAME_ID 0x1e
78
79 /* This byte is at the beginning of all GSM Frames sent over IR to Nokia phones. */
80 #define FBUS_IR_FRAME_ID 0x1c
81
82
83 /* Every (well, almost every) frame from the computer starts with this
84    sequence. */
85
86 #define FBUS_FRAME_HEADER 0x00, 0x01, 0x00
87
88
89 /* States for receive code. */
90
91 enum FBUS_RX_States {
92         FBUS_RX_Sync,
93         FBUS_RX_Discarding,
94         FBUS_RX_GetDestination,
95         FBUS_RX_GetSource,
96         FBUS_RX_GetType,
97         FBUS_RX_GetLength1,
98         FBUS_RX_GetLength2,
99         FBUS_RX_GetMessage
100 };
101
102
103 typedef struct{
104         int checksum[2];
105         int BufferCount;
106 #ifndef WIN32
107         struct timeval time_now;
108         struct timeval time_last;
109 #else
110         struct _timeb time_now;
111         struct _timeb time_last;
112 #endif
113         enum FBUS_RX_States state;
114         int MessageSource;
115         int MessageDestination;
116         int MessageType;
117         int FrameLength;
118         char MessageBuffer[FBUS_MAX_FRAME_LENGTH];
119 } FBUS_IncomingFrame;
120
121 typedef struct{
122         int MessageLength;
123         unsigned char *MessageBuffer;
124         char FramesToGo;
125         int Malloced;
126 } FBUS_IncomingMessage;
127
128 typedef struct {
129         u16 message_length;
130         u8 message_type;
131         u8 *buffer;
132 } FBUS_OutgoingMessage;
133
134
135 typedef struct{
136         FBUS_IncomingFrame i;
137         FBUS_IncomingMessage messages[FBUS_MAX_MESSAGE_TYPES];
138         u8 RequestSequenceNumber;
139 } FBUS_Link;
140
141 GSM_Error FBUS_Initialise(GSM_Link *newlink, GSM_Statemachine *state, int type);
142
143
144 #ifdef __links_fbus_c  /* Prototype functions for fbus-generic.c only */
145
146 bool FBUS_OpenSerial(bool dlr3);
147 void FBUS_RX_StateMachine(unsigned char rx_byte);
148 int FBUS_TX_SendFrame(u8 message_length, u8 message_type, u8 *buffer);
149 GSM_Error FBUS_SendMessage(u16 messagesize, u8 messagetype, void *message);
150 int FBUS_TX_SendAck(u8 message_type, u8 message_seq);
151
152 #endif   /* #ifdef __links_fbus_c */
153
154 #endif   /* #ifndef __links_fbus_h */
155
156
157
158
159
160
161
162