17 #include "../../gsmstate.h" 19 #if defined(GSM_ENABLE_FBUS2) || defined(GSM_ENABLE_FBUS2IRDA) || defined(GSM_ENABLE_FBUS2DLR3) || defined(GSM_ENABLE_FBUS2BLUE) || defined(GSM_ENABLE_BLUEFBUS2) || defined(GSM_ENABLE_DKU5FBUS2) || defined(GSM_ENABLE_FBUS2PL2303) 25 #include "../../gsmcomon.h" 31 unsigned const char *MsgBuffer,
33 unsigned char MsgType)
36 unsigned char checksum=0;
37 int i=0, length=0, sent=0;
47 buffer[4] = MsgLength / 256;
48 buffer[5] = MsgLength % 256;
49 memcpy(buffer + 6, MsgBuffer, MsgLength);
50 length = MsgLength + 6;
54 buffer[length++] = 0x00;
58 for (i = 0; i < length; i+=2) {
59 checksum ^= buffer[i];
61 buffer[length++] = checksum;
64 for (i = 1; i < length; i+=2) {
65 checksum ^= buffer[i];
67 buffer[length++] = checksum;
79 unsigned const char *MsgBuffer,
83 int i=0, nom=0, togo=0, thislength=0;
93 for (i = 0; i < nom; i++) {
97 seqnum = seqnum + 0x40;
106 memcpy(buffer, MsgBuffer + (MsgLength - togo), thislength);
107 buffer[thislength] = nom - i;
108 buffer[thislength + 1] = seqnum;
109 togo = togo - thislength;
113 error = FBUS2_WriteFrame(s, buffer, thislength + 2, MsgType);
123 unsigned char MsgType,
124 unsigned char MsgSequence)
126 unsigned char buffer[2]={0};
129 buffer[1] = MsgSequence;
142 unsigned char frm_num, seq_num;
179 if ((seq_num & 0x40) == 0x40) {
187 if ((seq_num & 0x40) != 0x40 && d->
FramesToGo != frm_num) {
221 FBUS2_SendAck(s,d->
Msg.
Type,((
unsigned char)(seq_num & 0x0f)));
296 if (rx_char == 0x20) {
297 smprintf(s,
"0x20 reply detected...\n");
298 smprintf(s,
"Trying to reinit connection...\n");
314 #if defined(GSM_ENABLE_FBUS2DLR3) || defined(GSM_ENABLE_DKU5FBUS2) || defined(GSM_ENABLE_FBUS2BLUE) || defined(GSM_ENABLE_BLUEFBUS2) || defined(GSM_ENABLE_FBUS2PL2303) 320 static void FBUS2_WriteDLR3(
GSM_StateMachine *s,
const char *command,
int length,
int timeout)
322 unsigned char buff[300]={0};
329 for (w = 0; w < timeout; w++) {
332 if (wassomething && recvlen == 0) {
334 }
else if (recvlen > 0) {
349 static const char init_1[] =
"AT\r\n";
350 static const char init_2[] =
"AT&F\r\n";
351 static const char init_3[] =
"AT*NOKIAFBUS\r\n";
353 smprintf(s,
"Switching to FBUS using AT commands\n");
355 FBUS2_WriteDLR3(s, init_1, strlen(init_1), 100);
356 FBUS2_WriteDLR3(s, init_2, strlen(init_2), 100);
357 FBUS2_WriteDLR3(s, init_3, strlen(init_3), 100);
368 int count=0,write_data=0;
369 static const unsigned char init_char = 0x55;
370 static const unsigned char end_init_char = 0xc1;
372 for (count = 0; count < repeats; count ++) {
375 if (write_data != 1) {
387 if (write_data != 1) {
400 unsigned char buff[300]={0};
413 if (error !=
ERR_NONE)
return error;
416 #if defined(GSM_ENABLE_BLUEFBUS2) || defined(GSM_ENABLE_FBUS2BLUE) 419 error = FBUS2_ATSwitch(s);
420 if (error !=
ERR_NONE)
return error;
423 #if defined(GSM_ENABLE_FBUS2DLR3) || defined(GSM_ENABLE_DKU5FBUS2) || defined(GSM_ENABLE_FBUS2PL2303) 428 if (error !=
ERR_NONE)
return error;
433 if (error !=
ERR_NONE)
return error;
438 if (error !=
ERR_NONE)
return error;
440 error = FBUS2_ATSwitch(s);
441 if (error !=
ERR_NONE)
return error;
444 if (error !=
ERR_NONE)
return error;
446 error = FBUS2_InitSequence(s, 32, 0,
TRUE);
447 if (error !=
ERR_NONE)
return error;
453 if (error !=
ERR_NONE)
return error;
457 if (error !=
ERR_NONE)
return error;
459 error = FBUS2_InitSequence(s, 32, 0,
TRUE);
460 if (error !=
ERR_NONE)
return error;
463 #ifdef GSM_ENABLE_FBUS2IRDA 466 if (error !=
ERR_NONE)
return error;
468 error = FBUS2_InitSequence(s, 32, 0,
TRUE);
469 if (error !=
ERR_NONE)
return error;
472 if (error !=
ERR_NONE)
return error;
482 error = FBUS2_InitSequence(s, 250, 100,
FALSE);
483 if (error !=
ERR_NONE)
return error;
void GSM_DumpMessageBinary(GSM_StateMachine *s, unsigned const char *message, size_t messagesize, int type)
GSM_Error(* DeviceSetDtrRts)(GSM_StateMachine *s, gboolean dtr, gboolean rts)
struct GSM_Protocol::@1 Data
void GSM_DumpMessageTextRecv(GSM_StateMachine *s, unsigned const char *message, size_t messagesize, int type)
GSM_Error(* DeviceSetParity)(GSM_StateMachine *s, gboolean parity)
GSM_ConnectionType ConnectionType
#define FBUS2_DEVICE_PHONE
#define FBUS2_MAX_TRANSMIT_LENGTH
int(* WriteDevice)(GSM_StateMachine *s, const void *buf, size_t nbytes)
unsigned char Destination
int smprintf_level(GSM_StateMachine *s, GSM_DebugSeverity severity, const char *format,...)
GSM_Protocol_Message MultiMsg
int(* ReadDevice)(GSM_StateMachine *s, void *buf, size_t nbytes)
unsigned char CheckSum[2]
GSM_Device_Functions * Functions
GSM_Phone_Functions * Functions
#define FBUS2_IRDA_FRAME_ID
GSM_Error(* DispatchMessage)(GSM_StateMachine *s)
GSM_Protocol_Message * RequestMsg
GSM_Error(* DeviceSetSpeed)(GSM_StateMachine *s, int speed)
void GSM_DumpMessageText(GSM_StateMachine *s, unsigned const char *message, size_t messagesize, int type)
int smprintf(GSM_StateMachine *s, const char *format,...)