|
Message
From: cvs at opencores.org<cvs@o...>
Date: Wed Nov 22 20:12:31 CET 2006
Subject: [cvs-checkins] MODIFIED: jop ...
Date: 00/06/11 22:20:12 Modified: jop/java/target/src/app/oebb BgPpp.java Comm.java Main.java Log: BG version 1.04 (+GSM connection) Revision Changes Path 1.2 jop/java/target/src/app/oebb/BgPpp.java http://www.opencores.org/cvsweb.shtml/jop/java/target/src/app/oebb/BgPpp.java.diff?r1=1.1&r2=1.2 (In the diff below, changes in quantity of whitespace are not shown.) Index: BgPpp.java =================================================================== RCS file: /cvsroot/martin/jop/java/target/src/app/oebb/BgPpp.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -r1.1 -r1.2 --- BgPpp.java 8 Jun 2006 17:53:09 -0000 1.1 +++ BgPpp.java 22 Nov 2006 19:12:31 -0000 1.2 @@ -68,6 +68,8 @@ private static final int NEG_SEND= 3000; // Period of send negotiation (in ms) private static final int IP_SEND= 10000; // Send timout for ip for reconnect (in ms) + private static final int GPRS_TRY_CNT = 3; // After that count connect via GSM + /** * receive buffer */ @@ -135,6 +137,8 @@ private static int connCount; + private static boolean useGSM; + /** * The one and only reference to this object. */ @@ -172,6 +176,8 @@ reconnectRequest = false; disconnectRequest = false; + useGSM = true; + initStr(); ser = serPort; @@ -202,8 +208,9 @@ int i, j; // System.out.println("start Conn"); - // TODO correct dial string in Strecken data - // copyStr(dialstr, dial); + copyStr(dialstr, dial, gsm_dial); + dial.append('\r'); + gsm_dial.append('\r'); con.setLength(0); con.append("AT+CGDCONT=1,\"IP\",\""); @@ -211,8 +218,8 @@ for (j=0; j<i; ++j) con.append(connect.charAt(j)); con.append("\"\r"); - copyStr(user, uid); - copyStr(passwd, pwd); + copyStr(user, uid, gsm_uid); + copyStr(passwd, pwd, gsm_pwd); reconnectRequest = true; connCount = 0; @@ -256,6 +263,11 @@ private static StringBuffer uid; private static StringBuffer pwd; + private static StringBuffer gsm_dial; + private static StringBuffer gsm_uid; + private static StringBuffer gsm_pwd; + + private static String ok; private static String connect; private static String ath; @@ -267,12 +279,24 @@ /** * a little helper: */ - static void copyStr(StringBuffer src, StringBuffer dst) { + static void copyStr(StringBuffer src, StringBuffer dst, + StringBuffer gsm_dst) { int i, j; dst.setLength(0); i = src.length(); - for (j=0; j<i; ++j) dst.append(src.charAt(j)); + for (j=0; j<i; ++j) { + char ch = src.charAt(j); + if (ch=='|') { + ++j; // skip it + break; + } + dst.append(ch);
+ }
+ gsm_dst.setLength(0);
+ for (; j<i; ++j) {
+ gsm_dst.append(src.charAt(j));
+ }
}
private static void initStr() {
@@ -282,14 +306,18 @@
uid = new StringBuffer(20);
pwd = new StringBuffer(20);
+ gsm_dial = new StringBuffer(20);
+ gsm_uid = new StringBuffer(20);
+ gsm_pwd = new StringBuffer(20);
+
/* we get the information from startConnection
con.append("AT+CGDCONT=1,\"IP\",\"A1.net\"\r");
uid.append("ppp@A...");
pwd.append("ppp");
+ dial.append("ATD*99***1#\r");
*/
- dial.append("ATD*99***1#\r");
client = "CLIENT";
ver = "VER";
@@ -302,19 +330,6 @@
flow = "AT\\Q3\r";
strBuf = new StringBuffer(40);
-
- // int [] s7 = { 'A', 'T', '+', 'C', 'G', 'D', 'C', 'O', 'N', 'T', '=', '1', ',', '"', 'I', 'P', '"', ',', '"', 'w', 'e', 'b', '.', 'o', 'n', 'e', '.', 'a', 't', '"', '\r' };
- /* A1 */
- // int [] s7 = { 'A', 'T', '+', 'C', 'G', 'D', 'C', 'O', 'N', 'T', '=', '1', ',', '"', 'I', 'P', '"', ',', '"', 'A', '1', '.', 'n', 'e', 't', '"', '\r' };
- /* OEBB VPN */
- /*
- int [] s7 = { 'A', 'T', '+', 'C', 'G', 'D', 'C', 'O', 'N', 'T', '=', '1', ',', '"', 'I', 'P', '"', ',',
- '"', 'o', 'e', 'b', 'b', '.', 'A', '1', '.', 'n', 'e', 't', '"', '\r' };
- */
- /*
- int [] s8 = { 'A', 'T', 'D', '*', '9', '9', '*', '*', '*', '1', '#', '\r' };
- int [] s9 = { 'A', 'T', '\\', 'Q', '3', '\r' };
- */
}
/**
@@ -339,7 +354,7 @@
*/
boolean wrString(StringBuffer s) {
- int i, j, k, val;
+ int i, j, val;
i = ser.txFreeCnt();
j = s.length();
@@ -429,6 +444,7 @@
void modemInit() {
+ useGSM = false;
++connCount;
for (;;++connCount) {
System.out.print("Modem init ");
@@ -438,6 +454,10 @@
Led.startModem();
waitSec(1);
+ if (connCount>GPRS_TRY_CNT) {
+ useGSM = true;
+ }
+
if (sendWait(ath, ok, 3)) {
if (sendWait(flow, ok, 3)) {
if (!sendWait(con, ok, 2)) { // when ERROR PIN is not set
@@ -446,11 +466,20 @@
continue; // something really strange happend!
}
}
- if (sendWait(dial, connect, 10)) {
+ sendWait("ATD", null, 1);
+ if (useGSM) {
+ if (sendWait(gsm_dial, connect, 30)) {
+ System.out.println("GSM connect ok");
+ break;
+ }
+ } else {
+ if (sendWait(dial, connect, 30)) {
+ System.out.println("GPRS connect ok");
break;
}
}
}
+ }
// waitSec(1);
}
@@ -634,10 +663,10 @@
} else { // do the negotiation stuff
dropIp();
if (Timer.timeout(globTimer)) {
-/*
-Dbg.intVal(state);
-if (lcpAck) Dbg.wr('t'); else Dbg.wr('f');
-*/
+
+//Dbg.intVal(state); Dbg.intVal(scnt);
+//if (lcpAck) Dbg.wr('t'); else Dbg.wr('f');
+
if (scnt==0) { // once every three seconds send a REQ
if (state == MODEM_OK) {
makeLCP();
@@ -742,16 +771,25 @@
sbuf[3] = lcpId;
sbuf[4] = 0;
- int ulen = uid.length();
- int plen = pwd.length();
+ StringBuffer u, p;
+ if (useGSM) {
+ u = gsm_uid;
+ p = gsm_pwd;
+ } else {
+ u = uid;
+ p = pwd;
+ }
+
+ int ulen = u.length();
+ int plen = p.length();
sbuf[5] = ulen + plen + 6; // length including code, id and length field
sbuf[6] = ulen; // length of user id
for (i=0; i<ulen; ++i) {
- sbuf[7+i] = uid.charAt(i);
+ sbuf[7+i] = u.charAt(i);
}
sbuf[7+ulen] = plen;
for (i=0; i<plen; ++i) {
- sbuf[8+ulen+i] = pwd.charAt(i);
+ sbuf[8+ulen+i] = p.charAt(i);
}
checksum(ulen + plen + 8);
@@ -779,31 +817,8 @@
checksum(24);
*/
-/* OEBB
-// Z252245
-// EN$Pf1dV
- sbuf[5] = 22-2; // length including code, id and length field
- sbuf[6] = 7; // length of user id
- sbuf[7] = 'z';
- sbuf[8] = '2';
- sbuf[9] = '5';
- sbuf[10] = '2';
- sbuf[11] = '2';
- sbuf[12] = '4';
- sbuf[13] = '5';
- sbuf[14] = 7; // length of password
- sbuf[15] = 'S';
- sbuf[16] = 't';
- sbuf[17] = 'T';
- sbuf[18] = 'f';
- sbuf[19] = 'D';
- sbuf[20] = 'g';
- sbuf[21] = '$';
- checksum(22);
-*/
-
/* ONE
sbuf[7] = 30-4; // length including code, id and length field
sbuf[8] = 14; // length of user id
@@ -1103,9 +1118,9 @@
if (fcs==0xf0b8) { // checksum ok?
ready = true;
} else {
-Dbg.wr('d');
-Dbg.intVal(cnt);
-Dbg.wr('\n');
+//Dbg.wr('d');
+//Dbg.intVal(cnt);
+//Dbg.wr('\n');
cnt = 0; // just drop it
}
break;
@@ -1127,11 +1142,18 @@
}
// rfc1549 3.2 Address-and-Control-Field-Compression
- if (cnt==0 && val!=0xff) rbuf[cnt++] = 0xff;
- if (cnt==1 && val!=0x03) rbuf[cnt++] = 0x03;
+ if (cnt==0 && val!=0xff) {
+ rbuf[cnt++] = 0xff;
+ }
+ if (cnt==1 && val!=0x03) {
+ rbuf[cnt++] = 0x03;
+ }
// rfc1548 6.6 Protocol-Field-Compression
- if (cnt==2 && (val&1)!=0) rbuf[cnt++] = 0x00;
+ if (cnt==2 && (val&1)!=0) {
+ rbuf[cnt++] = 0x00;
+ }
rbuf[cnt++] = val;
+//Dbg.byteVal(val);
fcs = check(val^fcs) ^ (fcs>>8);
@@ -1202,4 +1224,16 @@
return connCount;
}
+ /**
+ * GPRS or GSM
+ * @return 0=GPRS, 1=GSM
+ */
+ public static int getConnType() {
+ if (useGSM) {
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+
}
1.5 jop/java/target/src/app/oebb/Comm.java
http://www.opencores.org/cvsweb.shtml/jop/java/target/src/app/oebb/Comm.java.diff?r1=1.4&r2=1.5
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Comm.java
===================================================================
RCS file: /cvsroot/martin/jop/java/target/src/app/oebb/Comm.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- Comm.java 25 Aug 2005 09:13:28 -0000 1.4
+++ Comm.java 22 Nov 2006 19:12:31 -0000 1.5
@@ -391,7 +391,8 @@
if (m!=null) {
m.data[0] = (Main.VER_MAJ<<16)+Main.VER_MIN; // SW Ver.
m.data[1] = Flash.getVer();
- m.len = 2;
+ m.data[2] = BgPpp.getConnType();
+ m.len = 3;
Status.connOk = false;
Status.download = false;
m.send();
1.17 jop/java/target/src/app/oebb/Main.java
http://www.opencores.org/cvsweb.shtml/jop/java/target/src/app/oebb/Main.java.diff?r1=1.16&r2=1.17
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Main.java
===================================================================
RCS file: /cvsroot/martin/jop/java/target/src/app/oebb/Main.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- Main.java 8 Jun 2006 17:53:38 -0000 1.16
+++ Main.java 22 Nov 2006 19:12:31 -0000 1.17
@@ -62,7 +62,7 @@
// SW version
public static final int VER_MAJ = 1;
- public static final int VER_MIN = 3;
+ public static final int VER_MIN = 4;
private static final int STRECKE_PRIO = 1;
private static final int STRECKE_PERIOD = 100000;
|
 |