-
Notifications
You must be signed in to change notification settings - Fork 3
/
ESP_Easy_Netscan.scp
691 lines (669 loc) · 21.9 KB
/
ESP_Easy_Netscan.scp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
// COMPILE_OPTS|C:\Users\Jimmy\Desktop\ESP_Easy_Netscan.exe|C:\Users\Jimmy\Dropbox\Diverse\ESP-projekt\ESP_Easy_Netscan\ICON.ico|CONSOLE=0|INCLUDES=1| /NOSYSTRAY|RUNTIMES=1|BMPS=1
//Set IGNORESPACES to 1 to force script interpreter to ignore spaces.
//If using IGNORESPACES quote strings in {" ... "}
//Let>IGNORESPACES=1
Let>DEBUG_LEVEL=0
//Global variables (version is MAYOR.MINOR.MINIMAL)
Let>VERSION=0.01.000
Let>APP_TITLE=ESP Easy Netscan (%VERSION%)
Let>MAX_PARALLEL_PINGS=10
Let>HTTP_TIMEOUT=5
//Below are for the popup menu
Let>SHOW_POPUP_MENU=0
//Start of program
GoSub>DIALOG_MAIN
GoSub>GET_LOCAL_IP
GoSub>GET_THE_IP_OCTETS
GoSub>CONCAT_THE_MAC
GoSub>ADD_DIALOG_HANDLERS
GoSub>DO_A_SCAN,0,0,0
Show>Dialog_MAIN
Wait>%TIME_TO_DISPLAY_MESSAGE%
SetDialogProperty>Dialog_MAIN,STATUS_INFO_BAR,Visible,False
Let>SHOW_POPUP_MENU=1
//Loop to let dialog_MAIN stay alive and listen to interactions from user
Label>WAITING_FOR_A_WHILE
Let>WAIT_FOR_CROWS=0.02
Wait>%WAIT_FOR_CROWS%
Goto>WAITING_FOR_A_WHILE
//Sub routines...
SRT>DIALOG_MAIN
Dialog>Dialog_MAIN
object Dialog_MAIN: TForm
Left = -1398
Top = 172
HelpContext = 5000
BorderIcons = [biSystemMenu]
BorderStyle = bsSingle
Caption = 'ESP Easy node scanner'
ClientHeight = 825
ClientWidth = 1186
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -14
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = True
Position = poDefault
ShowHint = True
OnTaskBar = False
PixelsPerInch = 120
TextHeight = 16
object MAIN_PANEL: TPanel
Left = 0
Top = 0
Width = 1186
Height = 825
Margins.Left = 2
Margins.Top = 2
Margins.Right = 2
Margins.Bottom = 2
Align = alClient
Caption = 'MAIN_PANEL'
TabOrder = 0
object Panel1: TPanel
Left = 12
Top = 12
Width = 1162
Height = 665
Margins.Left = 4
Margins.Top = 4
Margins.Right = 4
Margins.Bottom = 4
TabOrder = 0
object THE_GRID: tMSStringGrid
Left = 1
Top = 1
Width = 1160
Height = 663
Margins.Left = 4
Margins.Top = 4
Margins.Right = 4
Margins.Bottom = 4
Align = alClient
ColCount = 9
DefaultColWidth = 150
ColWidths = (
110
190
60
70
140
70
100
140
58)
DefaultRowHeight = 35
FixedCols = 0
RowCount = 2
FixedRows = 0
Font.Charset = ANSI_CHARSET
Font.Color = clBlack
Font.Height = -27
Font.Name = 'Agency FB'
Font.Style = []
Options = [goHorzLine, goRowSizing, goColSizing, goRowSelect]
ParentFont = False
TabOrder = 0
end
end
object Panel2: TPanel
Left = 12
Top = 689
Width = 1162
Height = 123
Margins.Left = 4
Margins.Top = 4
Margins.Right = 4
Margins.Bottom = 4
TabOrder = 1
object STATUS_INFO_BAR: TLabel
Left = 10
Top = 69
Width = 128
Height = 16
Margins.Left = 4
Margins.Top = 4
Margins.Right = 4
Margins.Bottom = 4
Caption = 'STATUS_INFO_BAR'
end
object LOCAL_IP: TLabel
Left = 212
Top = 15
Width = 51
Height = 16
Margins.Left = 4
Margins.Top = 4
Margins.Right = 4
Margins.Bottom = 4
Caption = 'Local IP:'
end
object Button_Scan: tMSButton
Left = 10
Top = 7
Width = 92
Height = 31
Margins.Left = 4
Margins.Top = 4
Margins.Right = 4
Margins.Bottom = 4
Caption = 'Fetch info'
TabOrder = 0
DoBrowse = False
BrowseStyle = fbOpen
end
object Button_Deep_Scan: tMSButton
Left = 108
Top = 7
Width = 93
Height = 31
Margins.Left = 4
Margins.Top = 4
Margins.Right = 4
Margins.Bottom = 4
Caption = 'Deep scan'
TabOrder = 1
DoBrowse = False
BrowseStyle = fbOpen
end
object ProgressBar: TProgressBar
Left = 7
Top = 91
Width = 1146
Height = 21
Margins.Left = 4
Margins.Top = 4
Margins.Right = 4
Margins.Bottom = 4
Position = 33
TabOrder = 2
end
object LIST_IP_ADDRESSES: tMSComboBox
Left = 268
Top = 7
Width = 179
Height = 28
Margins.Left = 4
Margins.Top = 4
Margins.Right = 4
Margins.Bottom = 4
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -17
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
TabOrder = 3
Text = 'XXX.XXX.XXX.XXX'
Items.Strings = (
'XXX.XXX.XXX.XXX')
ListText = 'XXX.XXX.XXX.XXX'#13#10
end
end
end
end
EndDialog>Dialog_MAIN
END>DIALOG_MAIN
//Just kill the app
SRT>EXIT_APP
Exit>
END>EXIT_APP
//Add dialog handlers...
SRT>ADD_DIALOG_HANDLERS
SetDialogProperty>Dialog_MAIN,,Caption,APP_TITLE
SetDialogProperty>Dialog_MAIN,ProgressBar,Position,0
SetDialogProperty>Dialog_MAIN,STATUS_INFO_BAR,Visible,False
SetDialogProperty>Dialog_MAIN,LIST_IP_ADDRESSES,ListText,%LIST_IP_ADDRESSES_FOUND%
SetDialogProperty>Dialog_MAIN,LIST_IP_ADDRESSES,Text,%ACTIVE_IP_ADDRESS%
AddDialogHandler>Dialog_MAIN,,OnClose,EXIT_APP
AddDialogHandler>Dialog_MAIN,THE_GRID,OnSelectCell,CLICK_ROW_GET_INFO
AddDialogHandler>Dialog_MAIN,THE_GRID,OnDblClick,OPEN_MENU
AddDialogHandler>Dialog_MAIN,Button_Deep_Scan,OnClick,DO_A_SCAN(1,1,1)
AddDialogHandler>Dialog_MAIN,Button_Scan,OnClick,DO_A_SCAN(0,0,1)
END>ADD_DIALOG_HANDLERS
SRT>DO_A_SCAN
GetDialogProperty>Dialog_MAIN,LIST_IP_ADDRESSES,Text,ACTIVE_IP_ADDRESS
RegEx>[IPAddress],ACTIVE_IP_ADDRESS,1,,FOUND_IP_count,,,
If>FOUND_IP_count>0
GoSub>GET_THE_IP_OCTETS
SetDialogProperty>Dialog_MAIN,Button_Deep_Scan,Enabled,False
SetDialogProperty>Dialog_MAIN,Button_Scan,Enabled,False
SetDialogProperty>Dialog_MAIN,LIST_IP_ADDRESSES,Enabled,False
Let>SUM_OF_ALL_INPUTS={%DO_A_SCAN_Var_1%+%DO_A_SCAN_Var_2%+%DO_A_SCAN_Var_3%}
Let>DEEP_SCAN=DO_A_SCAN_Var_1
Let>PING_SCAN=DO_A_SCAN_Var_2
Let>INFO_SCAN=DO_A_SCAN_Var_3
If>PING_SCAN>0
//Not used...
//GoSub>
Endif>
If>DEEP_SCAN>0
GoSub>PING_THE_NETWORK
Let>SUM_OF_ALL_INPUTS=0
Let>INFO_SCAN=1
Endif>
If>SUM_OF_ALL_INPUTS=0
GoSub>GET_THE_MAC
Endif>
If>INFO_SCAN>0
GoSub>FETCH_INFO_ABOUT_UNITS
Endif>
GoSub>THE_CSV_TO_THE_DIALOG
SetDialogProperty>Dialog_MAIN,THE_GRID,LoadFromCSV,THE_GRID_CSV
SetDialogProperty>Dialog_MAIN,Button_Deep_Scan,Enabled,True
SetDialogProperty>Dialog_MAIN,Button_Scan,Enabled,True
SetDialogProperty>Dialog_MAIN,LIST_IP_ADDRESSES,Enabled,True
RegEx>[IPAddress],THE_GRID_CSV,1,,FOUND_IN_ARP,,,
If>FOUND_IN_ARP>0
//YES, we found something
Else>
Let>EXTRA_TEXT=, please run "Deep scan"
SetDialogProperty>Dialog_MAIN,STATUS_INFO_BAR,Caption,No ESP Easy units found in ARP table%EXTRA_TEXT%.
SetDialogProperty>Dialog_MAIN,STATUS_INFO_BAR,Visible,True
Let>TIME_TO_DISPLAY_MESSAGE=5
Endif>
Else>
SetDialogProperty>Dialog_MAIN,STATUS_INFO_BAR,Caption,Not a valid IP address entered!
Let>k_blink=0
Repeat>k_blink
Let>k_blink=k_blink+1
SetDialogProperty>Dialog_MAIN,STATUS_INFO_BAR,Visible,True
Wait>0.5
SetDialogProperty>Dialog_MAIN,STATUS_INFO_BAR,Visible,False
Wait>0.5
Until>k_blink=5
Endif>
END>DO_A_SCAN
SRT>GET_THE_IP_OCTETS
Separate>ACTIVE_IP_ADDRESS,.,IP_OCTETS
Let>ACTIVE_SUB_NET=%IP_OCTETS_1%.%IP_OCTETS_2%.%IP_OCTETS_3%
END>GET_THE_IP_OCTETS
SRT>PING_THE_NETWORK
Let>RP_WINDOWMODE=0
Let>RP_WAIT=0
Let>IP_OCTETS_4=0
Let>IP_OCTETS_4_max=254
Let>k_ping=0
Repeat>IP_OCTETS_4
Let>k_ping=k_ping+1
Let>IP_OCTETS_4=IP_OCTETS_4+1
Let>IP_NUMBER=%ACTIVE_SUB_NET%.%IP_OCTETS_4%
Let>PROGRESS_POSITION={round(100*%IP_OCTETS_4%/%IP_OCTETS_4_max%)}
SetDialogProperty>Dialog_MAIN,ProgressBar,Position,%PROGRESS_POSITION%
SetDialogProperty>Dialog_MAIN,STATUS_INFO_BAR,Caption,Pinging %IP_NUMBER% (%IP_OCTETS_4%/%IP_OCTETS_4_max%)
SetDialogProperty>Dialog_MAIN,STATUS_INFO_BAR,Visible,True
If>DEBUG_LEVEL>0
WriteLn>%SCRIPT_DIR%\APP_DATA\PING_RESULTS\PING_%IP_NUMBER%.txt,,########STARTED########
Let>DEBUG_OUTPUT= | tee '%SCRIPT_DIR%\APP_DATA\PING_RESULTS\PING_%IP_NUMBER%.txt'
IfNotDirExists>%SCRIPT_DIR%\APP_DATA\PING_RESULTS
CreateDir>%SCRIPT_DIR%\APP_DATA\PING_RESULTS
Endif>
IfFileExists>%SCRIPT_DIR%\APP_DATA\PING_RESULTS\PING_%IP_NUMBER%.txt
DeleteFile>%SCRIPT_DIR%\APP_DATA\PING_RESULTS\PING_%IP_NUMBER%.txt
Endif>
Else>
Let>DEBUG_OUTPUT=
Endif>
Let>RUN_STRING=powershell "test-connection -ComputerName %IP_NUMBER% -count 1 -ErrorAction SilentlyContinue | Format-List%DEBUG_OUTPUT%"
If>IP_OCTETS_4=IP_OCTETS_4_max
Let>k_ping=MAX_PARALLEL_PINGS
Endif>
If>k_ping=MAX_PARALLEL_PINGS
Let>RP_WAIT=1
RunProgram>%RUN_STRING%
Let>RP_WAIT=0
Let>k_ping=0
Else>
RunProgram>%RUN_STRING%
Endif>
Until>IP_OCTETS_4=IP_OCTETS_4_max
Let>RP_WAIT=1
SetDialogProperty>Dialog_MAIN,STATUS_INFO_BAR,Visible,False
SetDialogProperty>Dialog_MAIN,ProgressBar,Position,0
END>PING_THE_NETWORK
SRT>CLICK_ROW_GET_INFO
If>CLICK_ROW_GET_INFO_AROW=
//Do nothing
Let>SHOW_POPUP_MENU=0
Else>
Let>MARKED_IP_ADDRESS_FROM_ROW=FOUND_ESPRESSIF_UNITS_IP_ARRAY_%CLICK_ROW_GET_INFO_AROW%
Assigned>UNIT_NAME_%CLICK_ROW_GET_INFO_AROW%,IS_IT_ASSIGNED
If>IS_IT_ASSIGNED=TRUE
Let>MARKED_UNIT_NAME_FROM_ROW=UNIT_NAME_%CLICK_ROW_GET_INFO_AROW%
Let>MARKED_UNIT_NAME_FROM_ROW=%MARKED_UNIT_NAME_FROM_ROW%_
Else>
Let>MARKED_UNIT_NAME_FROM_ROW=
Endif>
Let>SHOW_POPUP_MENU=1
Endif>
END>CLICK_ROW_GET_INFO
SRT>OPEN_MENU
If>SHOW_POPUP_MENU>0
Wait>0.2
GetCursorPos>MOUSE_X,MOUSE_Y,
//0
Let>POPUP_MENU_LIST=Open %MARKED_IP_ADDRESS_FROM_ROW% in browser
//1
ConCat>POPUP_MENU_LIST,;Ping %MARKED_IP_ADDRESS_FROM_ROW% in cmd
//2
ConCat>POPUP_MENU_LIST,;Download config.dat
PopupMenu>MOUSE_X,MOUSE_Y,%POPUP_MENU_LIST%,OPTION_PICKED
If>OPTION_PICKED<0
//Nothing picked
Else>
//Something picked
Endif>
If>OPTION_PICKED=0
GoSub>OPEN_BROWSER
Endif>
If>OPTION_PICKED=1
GoSub>PING_ESPRESSIF_IPS
Endif>
If>OPTION_PICKED=2
GoSub>DOWNLOAD_CONFIG_DAT
Endif>
Endif>
END>OPEN_MENU
SRT>OPEN_BROWSER
Run>explorer "http://%MARKED_IP_ADDRESS_FROM_ROW%"
END>OPEN_BROWSER
SRT>DOWNLOAD_CONFIG_DAT
SetDialogProperty>Dialog_MAIN,STATUS_INFO_BAR,Visible,True
SetDialogProperty>Dialog_MAIN,STATUS_INFO_BAR,Caption,Config.dat downloadinge from %MARKED_IP_ADDRESS_FROM_ROW%...
SetDialogProperty>Dialog_MAIN,STATUS_INFO_BAR,Visible,True
Timer>TIMER1
HTTPRequest>http://%MARKED_IP_ADDRESS_FROM_ROW%/config.dat,%SCRIPT_DIR%\%MARKED_UNIT_NAME_FROM_ROW%%MARKED_IP_ADDRESS_FROM_ROW%_Config.dat,GET,,IE_ERROR,,,,
Timer>TIMER2
Let>TIME_DIFF=TIMER2-TIMER1
Let>ERROR_OUTPUT=0
If>IE_ERROR=404 Error connecting to host
Let>ERROR_OUTPUT=1
Endif>
If>IE_ERROR=404 HTTP/1.1 404 Not Found
Let>ERROR_OUTPUT=1
Endif>
IfFileExists>%SCRIPT_DIR%\%MARKED_UNIT_NAME_FROM_ROW%%MARKED_IP_ADDRESS_FROM_ROW%_Config.dat
Let>ERROR_OUTPUT=0
Else>
Let>ERROR_OUTPUT=1
Endif>
If>ERROR_OUTPUT>0
GetDialogProperty>Dialog_MAIN,STATUS_INFO_BAR,Caption,CURRENT_TEXT
SetDialogProperty>Dialog_MAIN,STATUS_INFO_BAR,Caption,%CURRENT_TEXT%TIMED OUT!
Else>
GetDialogProperty>Dialog_MAIN,STATUS_INFO_BAR,Caption,CURRENT_TEXT
SetDialogProperty>Dialog_MAIN,STATUS_INFO_BAR,Caption,%CURRENT_TEXT%DONE!
Endif>
SetDialogProperty>Dialog_MAIN,STATUS_INFO_BAR,Visible,True
SetDialogProperty>Dialog_MAIN,ProgressBar,Position,100
Wait>5
SetDialogProperty>Dialog_MAIN,STATUS_INFO_BAR,Visible,False
SetDialogProperty>Dialog_MAIN,STATUS_INFO_BAR,Visible,False
SetDialogProperty>Dialog_MAIN,ProgressBar,Position,0
END>DOWNLOAD_CONFIG_DAT
SRT>PING_ESPRESSIF_IPS
Let>RP_WINDOWMODE=1
RunProgram>ping -n 10 %MARKED_IP_ADDRESS_FROM_ROW%
Let>RP_WINDOWMODE=0
END>PING_ESPRESSIF_IPS
SRT>FETCH_INFO_ABOUT_UNITS
Separate>FOUND_ESPRESSIF_UNITS,%CRLF%,FOUND_ESPRESSIF_UNITS_IP_ARRAY
If>FOUND_ESPRESSIF_UNITS_IP_ARRAY_count=0
Let>EXTRA_TEXT=
If>DEEP_SCAN=1
Let>EXTRA_TEXT=, please run "Deep scan"
Endif>
SetDialogProperty>Dialog_MAIN,STATUS_INFO_BAR,Caption,No ESP Easy units found in ARP table%EXTRA_TEXT%.
Else>
SetDialogProperty>Dialog_MAIN,STATUS_INFO_BAR,Visible,True
Let>TOTAL_COUNT=FOUND_ESPRESSIF_UNITS_IP_ARRAY_count-1
Let>k_csv=0
Repeat>k_csv
Let>k_csv=k_csv+1
Let>CURRENT_IP=FOUND_ESPRESSIF_UNITS_IP_ARRAY_%k_csv%
Let>PROGRESS_POSITION={round(100*%k_csv%/%TOTAL_COUNT%)}
SetDialogProperty>Dialog_MAIN,ProgressBar,Position,%PROGRESS_POSITION%
SetDialogProperty>Dialog_MAIN,STATUS_INFO_BAR,Caption,Getting info from %CURRENT_IP% (%k_csv%/%TOTAL_COUNT%)
Timer>TIMER1
HTTPRequest>http://%CURRENT_IP%/json,,GET,,JSON_STRING,,,,
Timer>TIMER2
Let>TIME_DIFF=TIMER2-TIMER1
If>JSON_STRING=404 HTTP/1.1 404 Not Found
//
Let>BUILD_NUMBER_%k_csv%=?
Let>GIT_BUILD_NUMBER_%k_csv%=?
Let>UNIT_NUMBER_%k_csv%=?
Let>UNIT_NAME_%k_csv%=?
Let>UNIT_ONLINE_%k_csv%="<unknown>"
Let>UPTIME_%k_csv%=?
Else>
JSONParse>JSON_STRING,System.Build,TEMP_STRING
If>TEMP_STRING=
Let>TEMP_STRING=?
Endif>
Let>BUILD_NUMBER_%k_csv%=TEMP_STRING
JSONParse>JSON_STRING,System.Unit,TEMP_STRING
If>TEMP_STRING=
Let>TEMP_STRING=?
Endif>
Let>UNIT_NUMBER_%k_csv%=TEMP_STRING
JSONParse>JSON_STRING,System.Name,TEMP_STRING
If>TEMP_STRING=
Let>TEMP_STRING=?
Endif>
Let>UNIT_NAME_%k_csv%=TEMP_STRING
JSONParse>JSON_STRING,System.Git Build,TEMP_STRING
If>TEMP_STRING=
Let>TEMP_STRING=?
Endif>
Let>GIT_BUILD_NUMBER_%k_csv%=TEMP_STRING
Let>UNIT_ONLINE_%k_csv%="Online"
JSONParse>JSON_STRING,System.Uptime,TEMP_STRING
If>TEMP_STRING=
Let>TEMP_STRING=?
Endif>
Let>UPTIME_%k_csv%=TEMP_STRING
//Wifi
JSONParse>JSON_STRING,WiFi.BSSID,TEMP_STRING
If>TEMP_STRING=
Let>TEMP_STRING=?
Else>
GoSub>GET_AP_VERBOSE
IfNot>TEMP_VERBOSE_AP=
Let>TEMP_STRING=TEMP_VERBOSE_AP
Endif>
Endif>
Let>BSSID_%k_csv%=TEMP_STRING
JSONParse>JSON_STRING,WiFi.RSSI,TEMP_STRING
If>TEMP_STRING=
Let>TEMP_STRING=?
Endif>
Let>RSSI_%k_csv%=TEMP_STRING
Endif>
If>TIME_DIFF>5000
Let>UNIT_ONLINE_%k_csv%="Timed out"
Endif>
Let>TEMP_NAME=UNIT_NAME_%k_csv%
Let>TEMP_NUMBER=UNIT_NUMBER_%k_csv%
Let>TEMP_BUILD=BUILD_NUMBER_%k_csv%
Let>TEMP_GIT=GIT_BUILD_NUMBER_%k_csv%
Let>TEMP_ONLINE=UNIT_ONLINE_%k_csv%
Let>TEMP_UPTIME=UPTIME_%k_csv%
Let>TEMP_BSSID=BSSID_%k_csv%
Let>TEMP_RSSI=RSSI_%k_csv%
Let>TEMP_ROW_INFO_%k_csv%=,%TEMP_NAME%,%TEMP_NUMBER%,%TEMP_BUILD%,%TEMP_GIT%,%TEMP_ONLINE%,%TEMP_UPTIME%,%TEMP_BSSID%,%TEMP_RSSI%
Until>k_csv=TOTAL_COUNT
SetDialogProperty>Dialog_MAIN,STATUS_INFO_BAR,Visible,False
SetDialogProperty>Dialog_MAIN,ProgressBar,Position,0
Endif>
END>FETCH_INFO_ABOUT_UNITS
SRT>GET_AP_VERBOSE
IfFileExists>%SCRIPT_DIR%\Settings\AP.ini
ReadIniFile>%SCRIPT_DIR%\Settings\AP.ini,AP,%TEMP_STRING%,TEMP_VERBOSE_AP
If>TEMP_VERBOSE_AP=
EditIniFile>%SCRIPT_DIR%\Settings\AP.ini,AP,%TEMP_STRING%,
Endif>
Else>
IfNotDirExists>%SCRIPT_DIR%\Settings
CreateDir>%SCRIPT_DIR%\Settings
Endif>
WriteLn>%SCRIPT_DIR%\Settings\AP.ini,,######VERBOSE AP######
EditIniFile>%SCRIPT_DIR%\Settings\AP.ini,AP,%TEMP_STRING%,
Let>TEMP_VERBOSE_AP=
Endif>
END>GET_AP_VERBOSE
SRT>GET_THE_MAC
IfFileExists>%SCRIPT_DIR%\APP_DATA\ARP_INFO.txt
DeleteFile>%SCRIPT_DIR%\APP_DATA\ARP_INFO.txt
Endif>
Let>RUN_STRING=cmd /c arp -a -N %ACTIVE_IP_ADDRESS% > "%SCRIPT_DIR%\APP_DATA\ARP_INFO.txt"
Let>RP_WINDOWMODE=0
Let>RP_WAIT=1
RunProgram>%RUN_STRING%
ReadFile>%SCRIPT_DIR%\APP_DATA\ARP_INFO.txt,FILE_CONTENT
IfFileExists>%SCRIPT_DIR%\APP_DATA\ARP_INFO.txt
DeleteFile>%SCRIPT_DIR%\APP_DATA\ARP_INFO.txt
Endif>
Let>REGEX_PATTERN=%IP_OCTETS_1%\.%IP_OCTETS_2%\.%IP_OCTETS_3%\..[0123456789]{0,2} {0,}.{2}-.{2}-.{2}-.{2}-.{2}-.{2}
RegEx>REGEX_PATTERN,FILE_CONTENT,,FOUND_MAC_ADDRESSES,FOUND_MAC_ADDRESSES_num,,,
Let>FOUND_ESPRESSIF_UNITS=
If>FOUND_MAC_ADDRESSES_num>0
Let>k_espressif=0
Repeat>k_espressif
Let>k_espressif=k_espressif+1
Let>TEMP_CHECK=FOUND_MAC_ADDRESSES_%k_espressif%
RegEx> ,TEMP_CHECK,0,,,1,%CRLF%,TEMP_CHECK
Separate>TEMP_CHECK,%CRLF%,TEMP_CHECK_ARRAY
Let>CURRENT_IP_NUMBER=TEMP_CHECK_ARRAY_1
Trim>CURRENT_IP_NUMBER,CURRENT_IP_NUMBER
Let>CURRENT_MAC_ADDRESS=TEMP_CHECK_ARRAY_%TEMP_CHECK_ARRAY_count%
Trim>CURRENT_MAC_ADDRESS,CURRENT_MAC_ADDRESS
UpperCase>CURRENT_MAC_ADDRESS,CURRENT_MAC_ADDRESS
RegEx>REGEX_PATTERN_MAC,CURRENT_MAC_ADDRESS,0,,IS_IT_FOUND,,,
If>IS_IT_FOUND>0
Let>FOUND_ESPRESSIF_UNITS=%FOUND_ESPRESSIF_UNITS%%CURRENT_IP_NUMBER%%CRLF%
Endif>
Until>k_espressif=FOUND_MAC_ADDRESSES_num
Else>
//NOTHING FOUND IN ARP...
Endif>
END>GET_THE_MAC
SRT>CONCAT_THE_MAC
LabelToVar>OUI_INFORMATION,MAC_ADDRESSES,1,1,
LabelToVar>MANUAL_OUI,TEMP,1,1,
ConCat>MAC_ADDRESSES,TEMP
Let>REGEX_PATTERN=(?<=[0123456789]{3}: ).{2}-.{2}-.{2}
RegEx>REGEX_PATTERN,MAC_ADDRESSES,,MAC_ADDRESSES_ARRAY,MAC_ADDRESSES_ARRAY_num,,,
If>MAC_ADDRESSES_ARRAY_num>0
Let>REGEX_PATTERN_MAC=
Let>k_mac_list=0
Repeat>k_mac_list
Let>k_mac_list=k_mac_list+1
Let>TEMP_MAC=MAC_ADDRESSES_ARRAY_%k_mac_list%
Let>REGEX_PATTERN_MAC=%REGEX_PATTERN_MAC%%TEMP_MAC%
If>k_mac_list=MAC_ADDRESSES_ARRAY_num
//Do nothing
Else>
Let>REGEX_PATTERN_MAC=%REGEX_PATTERN_MAC%|
Endif>
Until>k_mac_list=MAC_ADDRESSES_ARRAY_num
Endif>
END>CONCAT_THE_MAC
SRT>THE_CSV_TO_THE_DIALOG
Let>THE_GRID_CSV="IP","Name","Number","Version","Git version","Status","Uptime [min]","AP","Signal"
Let>REGEX_PATTERN=,
RegEx>REGEX_PATTERN,THE_GRID_CSV,0,,NUMBER_OF_COLUMNS,0,,
Let>NUMBER_OF_COLUMNS=NUMBER_OF_COLUMNS+1
SetDialogProperty>Dialog_MAIN,THE_GRID,ColCount,%NUMBER_OF_COLUMNS%
Separate>FOUND_ESPRESSIF_UNITS,%CRLF%,FOUND_ESPRESSIF_UNITS_IP_ARRAY
If>FOUND_ESPRESSIF_UNITS_IP_ARRAY_count>0
Let>k_csv=0
Repeat>k_csv
Let>k_csv=k_csv+1
Let>TEMP_ROW=FOUND_ESPRESSIF_UNITS_IP_ARRAY_%k_csv%
If>k_csv=FOUND_ESPRESSIF_UNITS_IP_ARRAY_count
Let>THE_GRID_CSV=%THE_GRID_CSV%%TEMP_ROW%
Else>
Let>THE_GRID_CSV=%THE_GRID_CSV%%CRLF%
Let>THE_GRID_CSV=%THE_GRID_CSV%%TEMP_ROW%
Endif>
Assigned>TEMP_ROW_INFO_%k_csv%,IS_IT_ASSIGNED
If>IS_IT_ASSIGNED=FALSE
Let>TEMP_STRING=
Else>
Let>TEMP_STRING=TEMP_ROW_INFO_%k_csv%
Endif>
ConCat>THE_GRID_CSV,TEMP_STRING
Until>k_csv=FOUND_ESPRESSIF_UNITS_IP_ARRAY_count
Else>
Let>INFO_SCAN=1
Let>DEEP_SCAN=1
Endif>
END>THE_CSV_TO_THE_DIALOG
SRT>GET_LOCAL_IP
Let>RP_WAIT=1
Let>RP_WINDOWMODE=0
IfDirExists>%SCRIPT_DIR%\APP_DATA
//Do nothing
Else>
CreateDir>%SCRIPT_DIR%\APP_DATA
Endif>
IfFileExists>%SCRIPT_DIR%\APP_DATA\LOCAL_IP.txt
DeleteFile>%SCRIPT_DIR%\APP_DATA\LOCAL_IP.txt
Endif>
RunProgram>cmd /c tracert -4 %COMPUTER_NAME% > CreateDir>"%SCRIPT_DIR%\APP_DATA\LOCAL_IP.txt"
ReadFile>%SCRIPT_DIR%\APP_DATA\LOCAL_IP.txt,FILE_CONTENT
RegEx>[IPAddress],FILE_CONTENT,1,FOUND_IP,FOUND_IP_count,,,
Let>LIST_IP_ADDRESSES_FOUND=
Let>k_IP=0
Repeat>k_IP
Let>k_IP=k_IP+1
Let>TEMP_IP=FOUND_IP_%k_IP%
RegEx>TEMP_IP,LIST_IP_ADDRESSES_FOUND,,,ALREADY_IN_THERE,,,
If>ALREADY_IN_THERE>0
//Do nothing
Else>
Let>LIST_IP_ADDRESSES_FOUND=%LIST_IP_ADDRESSES_FOUND%%TEMP_IP%%CRLF%
Endif>
Until>k_IP=FOUND_IP_count
Let>ACTIVE_IP_ADDRESS=FOUND_IP_1
IfFileExists>%SCRIPT_DIR%\APP_DATA\LOCAL_IP.txt
DeleteFile>%SCRIPT_DIR%\APP_DATA\LOCAL_IP.txt
Endif>
Let>RP_WAIT=0
END>GET_LOCAL_IP
/*
OUI_INFORMATION:
#########MAC OUI to be able to search ESP units########
##################UPDATED: 2018-03-19##################
##Found here: http://standards-oui.ieee.org/oui.txt ###
##RegEx: (?:.){8}(?= {3}\(hex\)\t{2}Espressif Inc\.) ##
##################Espressif Inc. OUI###################
001: 54-5A-A6
002: 24-0A-C4
003: D8-A0-1D
004: EC-FA-BC
005: B4-E6-2D
006: A0-20-A6
007: 84-F3-EB
008: 84-0D-8E
009: 90-97-D5
010: 18-FE-34
011: 60-01-94
012: 2C-3A-E8
013: A4-7B-9D
014: BC-DD-C2
015: DC-4F-22
016: 5C-CF-7F
017: AC-D0-74
018: 30-AE-A4
019: 24-B2-DE
020: 68-C6-3A
021: CC-50-E3
*/
/*
MANUAL_OUI:
001: 38-2B-78
*/