@@ -84,7 +84,7 @@ public void deviceDiscoveryTest() throws IOException {
8484 String deviceResponse = sb .toString ().trim ();
8585 System .out .print ("ASAP LoRaEngine Test Device Response: " );
8686 System .out .println (deviceResponse );
87- assertEquals ("{\" COMMAND\" :\" .DeviceDiscoveredASAPLoRaMessage\" ,\" address\" :\" 0000 \" }" , deviceResponse );
87+ assertEquals ("{\" COMMAND\" :\" .DeviceDiscoveredASAPLoRaMessage\" ,\" address\" :\" 1000 \" }" , deviceResponse );
8888 break ;
8989 }
9090 }
@@ -99,15 +99,15 @@ public void deviceDiscoveryTest() throws IOException {
9999 String deviceResponse = sb .toString ().trim ();
100100 System .out .print ("ASAP LoRaEngine Test Device Response: " );
101101 System .out .println (deviceResponse );
102- assertEquals ("{\" COMMAND\" :\" .DeviceDiscoveredASAPLoRaMessage\" ,\" address\" :\" 0001 \" }" , deviceResponse );
102+ assertEquals ("{\" COMMAND\" :\" .DeviceDiscoveredASAPLoRaMessage\" ,\" address\" :\" 1001 \" }" , deviceResponse );
103103 break ;
104104 }
105105 }
106106 }
107107
108108 @ Test (timeout =10000 )
109109 public void simpleAliceToBobMessageTest () throws IOException {
110- this .AliceSocket .getOutputStream ().write ("{\" COMMAND\" :\" .ASAPLoRaMessage\" ,\" address\" :\" 0001 \" ,\" message\" :\" Hello World!\" }" .getBytes ());
110+ this .AliceSocket .getOutputStream ().write ("{\" COMMAND\" :\" .ASAPLoRaMessage\" ,\" address\" :\" 1001 \" ,\" message\" :\" Hello World!\" }" .getBytes ());
111111
112112 while (true ){
113113 if (this .BobSocket .getInputStream ().available () > 0 ) {
@@ -119,15 +119,15 @@ public void simpleAliceToBobMessageTest() throws IOException {
119119 String deviceResponse = sb .toString ().trim ();
120120 System .out .print ("ASAP LoRaEngine Test Device Response: " );
121121 System .out .println (deviceResponse );
122- assertEquals ("{\" COMMAND\" :\" .ASAPLoRaMessage\" ,\" address\" :\" 0000 \" ,\" message\" :\" Hello World!\" }" , deviceResponse );
122+ assertEquals ("{\" COMMAND\" :\" .ASAPLoRaMessage\" ,\" address\" :\" 1000 \" ,\" message\" :\" Hello World!\" }" , deviceResponse );
123123 break ;
124124 }
125125 }
126126 }
127127
128128 @ Test (timeout =10000 )
129129 public void simpleBobToAliceMessageTest () throws IOException {
130- this .BobSocket .getOutputStream ().write ("{\" COMMAND\" :\" .ASAPLoRaMessage\" ,\" address\" :\" 0000 \" ,\" message\" :\" Hello World!\" }" .getBytes ());
130+ this .BobSocket .getOutputStream ().write ("{\" COMMAND\" :\" .ASAPLoRaMessage\" ,\" address\" :\" 1000 \" ,\" message\" :\" Hello World!\" }" .getBytes ());
131131
132132 while (true ){
133133 if (this .AliceSocket .getInputStream ().available () > 0 ) {
@@ -139,7 +139,48 @@ public void simpleBobToAliceMessageTest() throws IOException {
139139 String deviceResponse = sb .toString ().trim ();
140140 System .out .print ("ASAP LoRaEngine Test Device Response: " );
141141 System .out .println (deviceResponse );
142- assertEquals ("{\" COMMAND\" :\" .ASAPLoRaMessage\" ,\" address\" :\" 0001\" ,\" message\" :\" Hello World!\" }" , deviceResponse );
142+ assertEquals ("{\" COMMAND\" :\" .ASAPLoRaMessage\" ,\" address\" :\" 1001\" ,\" message\" :\" Hello World!\" }" , deviceResponse );
143+ break ;
144+ }
145+ }
146+ }
147+
148+ @ Test (timeout =20000 )
149+ public void simultaneousMessageTest () throws IOException {
150+ this .BobSocket .getOutputStream ().write ("{\" COMMAND\" :\" .ASAPLoRaMessage\" ,\" address\" :\" 1000\" ,\" message\" :\" Hello World!\" }" .getBytes ());
151+ try {
152+ Thread .sleep (500 );
153+ } catch (InterruptedException e ) {
154+ e .printStackTrace ();
155+ }
156+ this .AliceSocket .getOutputStream ().write ("{\" COMMAND\" :\" .ASAPLoRaMessage\" ,\" address\" :\" 1001\" ,\" message\" :\" Hello World!\" }" .getBytes ());
157+
158+ while (true ){
159+ if (this .BobSocket .getInputStream ().available () > 0 ) {
160+ BufferedReader br = new BufferedReader (new InputStreamReader (this .BobSocket .getInputStream ()));
161+ StringBuilder sb = new StringBuilder (this .BobSocket .getInputStream ().available ());
162+ do {
163+ sb .append (br .readLine ()).append ("\n " );
164+ } while (br .ready ());
165+ String deviceResponse = sb .toString ().trim ();
166+ System .out .print ("ASAP LoRaEngine Test Device Response: " );
167+ System .out .println (deviceResponse );
168+ assertEquals ("{\" COMMAND\" :\" .ASAPLoRaMessage\" ,\" address\" :\" 1000\" ,\" message\" :\" Hello World!\" }" , deviceResponse );
169+ break ;
170+ }
171+ }
172+
173+ while (true ){
174+ if (this .AliceSocket .getInputStream ().available () > 0 ) {
175+ BufferedReader br = new BufferedReader (new InputStreamReader (this .AliceSocket .getInputStream ()));
176+ StringBuilder sb = new StringBuilder (this .AliceSocket .getInputStream ().available ());
177+ do {
178+ sb .append (br .readLine ()).append ("\n " );
179+ } while (br .ready ());
180+ String deviceResponse = sb .toString ().trim ();
181+ System .out .print ("ASAP LoRaEngine Test Device Response: " );
182+ System .out .println (deviceResponse );
183+ assertEquals ("{\" COMMAND\" :\" .ASAPLoRaMessage\" ,\" address\" :\" 1001\" ,\" message\" :\" Hello World!\" }" , deviceResponse );
143184 break ;
144185 }
145186 }
0 commit comments