質問編集履歴

3

画像追記

2018/05/23 07:07

投稿

KEEL
KEEL

スコア52

test CHANGED
File without changes
test CHANGED
@@ -402,6 +402,18 @@
402
402
 
403
403
 
404
404
 
405
+ 送信元IP192.168.4.1
406
+
407
+ ![イメージ説明](7fd6928c29c830784b7b52f49d9c4b6a.png)
408
+
409
+
410
+
411
+ 送信元IP192.168.4.2
412
+
413
+ ![イメージ説明](e308bb09230640cf0f3b1fbb0eb31814.png)
414
+
415
+ ![イメージ説明](b329200da37682b533c89ce8a2be130e.png)
416
+
405
417
  ### 環境
406
418
 
407
419
  Unity2017.3.0f3

2

wiresharkでのパケットの確認を質問欄に追加

2018/05/23 07:07

投稿

KEEL
KEEL

スコア52

test CHANGED
File without changes
test CHANGED
@@ -222,6 +222,186 @@
222
222
 
223
223
 
224
224
 
225
+ ### wiresharkでのパケットの確認
226
+
227
+ ESPrDeveloper側のコードを以下のように改変し、wiresharkでWiFiにどんなパケットが流れているか確認しました。
228
+
229
+ ```Arduino
230
+
231
+ #include <ESP8266WiFi.h>
232
+
233
+ #include <WiFiUdp.h>
234
+
235
+ extern "C" {
236
+
237
+ #include "user_interface.h"
238
+
239
+ }
240
+
241
+ const char* ssid = "ESP_WROOM_02";
242
+
243
+ const char* password = "hoge4444";
244
+
245
+
246
+
247
+ WiFiUDP UDPTestServer;
248
+
249
+ static const char *udpReturnAddr = "192.168.150.64";
250
+
251
+ unsigned int UDPPort = 22222;
252
+
253
+
254
+
255
+ const int packetSize = 2;
256
+
257
+ byte packetBuffer[packetSize];
258
+
259
+
260
+
261
+ void setup() {
262
+
263
+ Serial.begin(115200);
264
+
265
+ delay(10);
266
+
267
+
268
+
269
+ Serial.println();
270
+
271
+ Serial.println();
272
+
273
+ Serial.print("Connecting to ");
274
+
275
+ Serial.println(ssid);
276
+
277
+
278
+
279
+ WiFi.begin(ssid, password);
280
+
281
+ WiFi.config(IPAddress(192, 168, 4, 1), IPAddress(192, 168, 4, 2), IPAddress(255, 255, 255, 0));
282
+
283
+
284
+
285
+ while (WiFi.softAPgetStationNum() <= 0) {
286
+
287
+ delay(500);
288
+
289
+ Serial.print(".");
290
+
291
+ }
292
+
293
+
294
+
295
+ Serial.println("");
296
+
297
+ Serial.println("WiFi connected");
298
+
299
+ Serial.print("IP address: ");
300
+
301
+ Serial.println(WiFi.localIP());
302
+
303
+
304
+
305
+ IPAddress myIP = WiFi.softAPIP();
306
+
307
+ Serial.print("AP IP address: ");
308
+
309
+ Serial.println(myIP);
310
+
311
+
312
+
313
+ byte mac[6];
314
+
315
+ WiFi.macAddress(mac);
316
+
317
+ char buf[20];
318
+
319
+ Serial.print("MAC address: ");
320
+
321
+ sprintf(buf,"%02X:%02X:%02X:%02X:%02X:%02X",mac[0],mac[1],mac[2],mac[3],mac[4],mac[5]);
322
+
323
+ Serial.print(buf);
324
+
325
+ sprintf(buf," %02x%02x%02x%02x%02x%02x",mac[0],mac[1],mac[2],mac[3],mac[4],mac[5]);
326
+
327
+ Serial.println(buf);
328
+
329
+ UDPTestServer.begin(UDPPort);
330
+
331
+
332
+
333
+ }
334
+
335
+
336
+
337
+ int value = 0;
338
+
339
+
340
+
341
+ void loop()
342
+
343
+ {
344
+
345
+ if(WiFi.softAPgetStationNum() <= 0)
346
+
347
+ {
348
+
349
+ delay(500);
350
+
351
+ Serial.print(".");
352
+
353
+ }
354
+
355
+ else
356
+
357
+ {
358
+
359
+ handleUDPServer();
360
+
361
+ }
362
+
363
+ delay(1);
364
+
365
+ }
366
+
367
+
368
+
369
+ void handleUDPServer()
370
+
371
+ {
372
+
373
+ uint ADC_Value = 0;
374
+
375
+ ADC_Value = system_adc_read();
376
+
377
+ String str = String(ADC_Value) ;
378
+
379
+ int a = str.length();
380
+
381
+ char msg[a+1];
382
+
383
+ str.toCharArray(msg, a+1);
384
+
385
+ Serial.print(".");
386
+
387
+ UDPTestServer.beginPacket(udpReturnAddr, UDPPort);
388
+
389
+ UDPTestServer.write(msg, a+1);
390
+
391
+ UDPTestServer.endPacket();
392
+
393
+ delay(3);
394
+
395
+ }
396
+
397
+ ```
398
+
399
+ 結果は以下のようになりUDPパケットは流れず、ARPパケットやICMPパケットが多くみられました。
400
+
401
+ ![イ![イメージ説明](b8f5af7b2e6ee51aa6571631b0923c46.png)
402
+
403
+
404
+
225
405
  ### 環境
226
406
 
227
407
  Unity2017.3.0f3

1

初心者アイコン追加

2018/05/23 06:20

投稿

KEEL
KEEL

スコア52

test CHANGED
File without changes
test CHANGED
File without changes