File tree Expand file tree Collapse file tree 2 files changed +73
-0
lines changed
Expand file tree Collapse file tree 2 files changed +73
-0
lines changed Original file line number Diff line number Diff line change 1+ // script.js
2+
3+ // Enable strict mode
4+ "use strict" ;
5+
6+ // Print a message
7+ print ( "Hello from Elk JavaScript!" ) ;
8+
9+ // Declare all variables at the top level
10+ let ssid = "Personal-80E-2.4GHz" ;
11+ let password = "17EF32280E" ;
12+ let connected ;
13+ let ip ;
14+ let fileList ;
15+ let writeSuccess ;
16+ let ledPin = 10 ; // Adjust pin number as needed
17+ let i ;
18+
19+ // Connect to Wi-Fi
20+ print ( "Connecting to Wi-Fi..." ) ;
21+ connected = wifi_connect ( ssid , password ) ;
22+
23+ // Debugging: Print the value of 'connected'
24+ print ( "connected =" ) ;
25+ print ( connected ) ;
26+
27+ if ( connected ) {
28+ print ( "Connected to Wi-Fi" ) ;
29+
30+ // Get IP address
31+ ip = wifi_get_ip ( ) ;
32+ print ( "IP Address:" ) ;
33+ print ( ip ) ;
34+ } else {
35+ print ( "Failed to connect to Wi-Fi" ) ;
36+ }
37+
38+ print ( "After Wi-Fi connection attempt" ) ;
39+
40+ // Check Wi-Fi status
41+ if ( wifi_status ( ) ) {
42+ print ( "Wi-Fi is connected" ) ;
43+ } else {
44+ print ( "Wi-Fi is not connected" ) ;
45+ }
46+
47+ print ( "Before listing directory" ) ;
48+
49+ // List files in the root directory
50+ fileList = sd_list_dir ( "/" ) ;
51+ print ( "After sd_list_dir call" ) ;
52+
53+ print ( "fileList is:" ) ;
54+ print ( fileList ) ;
55+
56+ if ( fileList ) {
57+ print ( "Directory contents:" ) ;
58+ print ( fileList ) ;
59+ } else {
60+ print ( "Failed to list directory" ) ;
61+ }
62+
63+ print ( "After listing directory" ) ;
64+
65+ // Optionally, proceed with other operations
66+ print ( "Script execution completed" ) ;
67+
Original file line number Diff line number Diff line change 1+
2+ settings :
3+ wifi :
4+ ssid : Personal-80E-2.4GHz
5+ pass : 17EF32280E
6+ last_read : 1
You can’t perform that action at this time.
0 commit comments