Found in "gnokii-working" directory, some November-patches version
[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.2  2002/04/03 00:08:20  short
21   Found in "gnokii-working" directory, some November-patches version
22
23   Revision 1.4  2001/03/21 23:36:08  chris
24   Added the statemachine
25   This will break gnokii --identify and --monitor except for 6210/7110
26
27   Revision 1.3  2001/03/19 23:44:57  pkot
28   DLR3 cable support
29
30   Revision 1.2  2001/03/13 01:23:19  pkot
31   Windows updates (Manfred Jonsson)
32
33   Revision 1.1  2001/02/21 19:57:12  chris
34   More fiddling with the directory layout
35
36   Revision 1.3  2001/02/06 21:15:36  chris
37   Preliminary irda support for 7110 etc.  Not well tested!
38
39   Revision 1.2  2001/01/17 02:54:55  chris
40   More 7110 work.  Use with care! (eg it is not possible to delete phonebook entries)
41   I can now edit my phonebook in xgnokii but it is 'work in progress'.
42
43   Revision 1.1  2001/01/14 22:47:01  chris
44   Preliminary 7110 support (dlr9 only) and the beginnings of a new structure
45
46
47 */
48
49 #ifndef __links_fbus_h
50 #define __links_fbus_h
51
52 #include <time.h>
53 #include "gsm-statemachine.h"
54
55 #ifdef WIN32
56 #include <sys/types.h>
57 #include <sys/timeb.h>
58 #endif
59
60 #define FBUS_MAX_FRAME_LENGTH 256
61 #define FBUS_MAX_MESSAGE_TYPES 128
62 #define FBUS_MAX_TRANSMIT_LENGTH 256
63 #define FBUS_MAX_CONTENT_LENGTH 120
64
65 /* Nokia mobile phone. */
66 #define FBUS_DEVICE_PHONE 0x00
67
68 /* Our PC. */
69 #define FBUS_DEVICE_PC 0x0c
70
71
72 /* This byte is at the beginning of all GSM Frames sent over FBUS to Nokia
73    phones.  This may have to become a phone dependant parameter... */
74 #define FBUS_FRAME_ID 0x1e
75
76 /* This byte is at the beginning of all GSM Frames sent over IR to Nokia phones. */
77 #define FBUS_IR_FRAME_ID 0x1c
78
79
80 /* Every (well, almost every) frame from the computer starts with this
81    sequence. */
82
83 #define FBUS_FRAME_HEADER 0x00, 0x01, 0x00
84
85
86 /* States for receive code. */
87
88 enum FBUS_RX_States {
89         FBUS_RX_Sync,
90         FBUS_RX_Discarding,
91         FBUS_RX_GetDestination,
92         FBUS_RX_GetSource,
93         FBUS_RX_GetType,
94         FBUS_RX_GetLength1,
95         FBUS_RX_GetLength2,
96         FBUS_RX_GetMessage
97 };
98
99
100 typedef struct{
101         int checksum[2];
102         int BufferCount;
103 #ifndef WIN32
104         struct timeval time_now;
105         struct timeval time_last;
106 #else
107         struct _timeb time_now;
108         struct _timeb time_last;
109 #endif
110         enum FBUS_RX_States state;
111         int MessageSource;
112         int MessageDestination;
113         int MessageType;
114         int FrameLength;
115         char MessageBuffer[FBUS_MAX_FRAME_LENGTH];
116 } FBUS_IncomingFrame;
117
118 typedef struct{
119         int MessageLength;
120         unsigned char *MessageBuffer;
121         char FramesToGo;
122         int Malloced;
123 } FBUS_IncomingMessage;
124
125 typedef struct {
126         u16 message_length;
127         u8 message_type;
128         u8 *buffer;
129 } FBUS_OutgoingMessage;
130
131
132 typedef struct{
133         FBUS_IncomingFrame i;
134         FBUS_IncomingMessage messages[FBUS_MAX_MESSAGE_TYPES];
135         u8 RequestSequenceNumber;
136 } FBUS_Link;
137
138 GSM_Error FBUS_Initialise(GSM_Link *newlink, GSM_Statemachine *state);
139
140
141
142 #ifdef __links_fbus_c  /* Prototype functions for fbus-generic.c only */
143
144 bool FBUS_OpenSerial(bool dlr3);
145 void FBUS_RX_StateMachine(unsigned char rx_byte);
146 int FBUS_TX_SendFrame(u8 message_length, u8 message_type, u8 *buffer);
147 GSM_Error FBUS_SendMessage(u16 messagesize, u8 messagetype, void *message);
148 int FBUS_TX_SendAck(u8 message_type, u8 message_seq);
149
150 #endif   /* #ifdef __links_fbus_c */
151
152 #endif   /* #ifndef __links_fbus_h */
153
154
155
156
157
158
159
160