*/
-#include "config.h"
-
/* "Turn on" prototypes in fbus.h */
#define __fbus_c
#include "protocol/fbus.h"
#include "protocol/at.h"
#include "newmodules/newat.h"
-#ifndef UCLINUX
#include "newmodules/n6110.h"
-#endif /* UCLINUX */
#include "misc.h"
-static GSM_Error FBUS_Initialise(char *port_device, char *initlength,
- GSM_ConnectionType connection,
- void (*rlp_callback)(RLP_F96Frame *frame));
-
-static int FBUS_SendMessage(u16 message_length, u8 message_type, u8 *buffer);
-static int FBUS_SendFrame(u16 message_length, u8 message_type, u8 *buffer);
-static void FBUS_Terminate(void);
-static void FBUS_RX_StateMachine(unsigned char rx_byte);
-
GSM_Protocol FBUS_Functions = {
FBUS_Initialise,
FBUS_SendMessage,
};
/* Local variables */
-static enum FBUS_RX_States RX_State;
+enum FBUS_RX_States RX_State;
-static u8 MessageDestination, MessageSource;
+u8 MessageDestination, MessageSource;
-static u16 BufferCount;
+u16 BufferCount, MultiBufferCount;
-static u16 MessageLength, MultiMessageLength;
+u16 MessageLength, MultiMessageLength;
-static bool RX_Multiple = false;
+bool RX_Multiple = false;
-static u8 MessageType,MultiMessageType;
+u8 MessageType,MultiMessageType;
-static u8 MessageBuffer[FBUS_MAX_RECEIVE_LENGTH * 6],MultiMessageBuffer[FBUS_MAX_RECEIVE_LENGTH * 6];
+u8 MessageBuffer[FBUS_MAX_RECEIVE_LENGTH * 6],MultiMessageBuffer[FBUS_MAX_RECEIVE_LENGTH * 6];
-static u8 RequestSequenceNumber = 0x00;
+u8 RequestSequenceNumber = 0x00;
#ifdef DEBUG
-static char *N61_PrintDevice(int Device)
+char *N61_PrintDevice(int Device)
{
switch (Device) {
/* N61_RX_DisplayMessage is called when a message we don't know about is
received so that the user can see what is going back and forth, and perhaps
shed some more light/explain another message type! */
-static void N61_RX_DisplayMessage()
+void N61_RX_DisplayMessage()
{
#ifdef DEBUG
fprintf(stdout, _("Msg Dest: %s\n"), N61_PrintDevice(MessageDestination));
NULL_TX_DisplayMessage(current, out_buffer);
#endif /* DEBUG */
-#if 0
-usleep(200000);
-#endif
-
/* Send it out... */
if (!NULL_WritePhone(current,out_buffer))
return (false);
return (true);
}
-static int FBUS_SendAck(u8 message_type, u8 message_seq) {
+int FBUS_SendAck(u8 message_type, u8 message_seq) {
unsigned char request[6];
int i=0;
-// if (CurrentConnectionType==GCT_DLR3) {
-// AT_RX_StateMachine(rx_byte);
-// } else {
-
-#ifdef XDEBUG_LaceDisabled
- if (isprint(rx_byte))
- fprintf(stdout, "[%02x%c]", rx_byte, rx_byte);
- else
- fprintf(stdout, "[%02x ]", rx_byte);
- fflush(stdout);
-#endif
-
#ifdef DEBUG
/* For model sniff only display received bytes */
if (strcmp(GSM_Info->FBUSModels, "sniff"))
case FBUS_RX_Sync:
if ((CurrentConnectionType==GCT_FBUS && rx_byte == FBUS_FRAME_ID) ||
- 0/*((CurrentConnectionType==GCT_Infrared ||
- CurrentConnectionType==GCT_Tekram) && rx_byte == FBUS_IR_FRAME_ID)*/) {
+ ((CurrentConnectionType==GCT_Infrared ||
+ CurrentConnectionType==GCT_Tekram) && rx_byte == FBUS_IR_FRAME_ID)) {
BufferCount = 0;
}
#endif
-
-// }
}
/* Called by initialisation code to open comm port in asynchronous mode. */
-static bool FBUS_OpenSerial(void)
+bool FBUS_OpenSerial(void)
{
/* Uncomment, if want to test first method for DLR3 */
-// unsigned char req[3] = {"AT\r"};
-// unsigned char req2[5] = {"AT&F\r"};
-// unsigned char req3[13] = {"AT*NOKIAFBUS\r"};
-
-// GSM_Error error;
-
-// GSM_Information *GSMINFOCOPY;
-// GSM_Functions *GSMCOPY;
+ unsigned char req[3] = {"AT\r"};
+ unsigned char req2[5] = {"AT&F\r"};
+ unsigned char req3[13] = {"AT*NOKIAFBUS\r"};
switch (CurrentConnectionType) {
case GCT_FBUS:
device_setdtrrts(1, 0);
break;
-#ifndef UCLINUX
case GCT_DLR3:
#ifdef DEBUG
/* There are 2 ways to init DLR in FBUS: Here is first described by
Reuben Harris [reuben.harris@snowvalley.com] and used in Logo Manager,
- 1. Firstly set the connection baud to 19200, DTR off, RTS off,
- Parity on, one stop bit,
- 2. Send "AT\r\n". The response should be "AT\r\n\r\nOK\r\n".
- 3. Send "AT&F\r\n". The response should be "AT&F\r\n\r\nOK\r\n".
- 4. Send "AT*NOKIAFBUS\r\n". The response should be
- "AT*NOKIAFBUS\r\n\r\nOK\r\n".
- 5. Set speed to 115200
-
- This is one should be used by us, because seems to be compatible with more
- phones. But we make something wrong and often phones don't want to start transmision */
+ 1. Firstly set the connection baud to 19200, DTR off, RTS off,
+ Parity on, one stop bit,
+ 2. Send "AT\r\n". The response should be "AT\r\n\r\nOK\r\n".
+ 3. Send "AT&F\r\n". The response should be "AT&F\r\n\r\nOK\r\n".
+ 4. Send "AT*NOKIAFBUS\r\n". The response should be
+ "AT*NOKIAFBUS\r\n\r\nOK\r\n".
+ 5. Set speed to 115200
+ This seems to be compatible with more phones*/
- /* Uncomment and test if want */
-// device_changespeed(19200);
+ device_changespeed(19200);
/*leave RTS low, DTR low for duration of session.*/
-// device_setdtrrts(0, 0);
-
- /* Making copy of pointers */
-// GSMCOPY = GSM;
-// GSMINFOCOPY =GSM_Info;
-
- /* Set pointers to relevant addresses - new "AT" module here is required */
-// GSM = &Nat_Functions;
-// GSM_Info = &Nat_Information;
-
- /* Note: We change Protocol inside function pointed by it.
- That's why in FBUS_RX_StateMachine we must check it (changing
- Protocol is not enough), This is for correct work and be sure... */
-// Protocol = &AT_Functions;
-
-// error=N6110_SendMessageSequence (50, &CurrentGetHWError, 3, 0x00, req);
-// if (error!=GE_NONE) return false;
-
-// error=N6110_SendMessageSequence (50, &CurrentGetHWError, 5, 0x00, req2);
-// if (error!=GE_NONE) return false;
-
-// error=N6110_SendMessageSequence (50, &CurrentGetHWError, 13, 0x00, req3);
-// if (error!=GE_NONE) return false;
-
- /* Returning to old protocol */
-// Protocol = &FBUS_Functions;
-
- /* Returning to old module */
-// GSM = GSMCOPY;
-// GSM_Info = GSMINFOCOPY;
-
-// device_changespeed(115200);
-
- /* Second method for DLR3:
- Used by some 7110 soft, but not compatible with some other
- phones supporting DLR3 - 7160, NCP2.0
- Used in this moment in mygnokii
- */
+ device_setdtrrts(0, 0);
+
+ Protocol->WritePhone (3,req );usleep(300);
+ Protocol->WritePhone (5,req2);usleep(300);
+ Protocol->WritePhone(13,req3);usleep(300);
device_changespeed(115200);
- /*leave RTS low, DTR low for duration of session.*/
- device_setdtrrts(0, 0);
-
- usleep(100000);
+// /* Second method for DLR3:
+// Used by some 7110 soft, but not compatible with some other
+// phones supporting DLR3 - 7160, NCP2.0*/
+// device_changespeed(115200);
+// /*leave RTS low, DTR low for duration of session.*/
+// device_setdtrrts(0, 0);
+// usleep(100000);
CurrentConnectionType=GCT_FBUS;
/* It's more complicated and not done here */
break;
-#endif /* UCLINUX */
default:
#ifdef DEBUG
fprintf(stdout,_("Wrong connection type for fbus module. Inform marcin-wiacek@topnet.pl about it\n"));
}
/* Initialise variables and state machine. */
-static GSM_Error FBUS_Initialise(char *port_device, char *initlength,
+GSM_Error FBUS_Initialise(char *port_device, char *initlength,
GSM_ConnectionType connection,
void (*rlp_callback)(RLP_F96Frame *frame))
{