File tree Expand file tree Collapse file tree 6 files changed +56
-6
lines changed Expand file tree Collapse file tree 6 files changed +56
-6
lines changed Original file line number Diff line number Diff line change @@ -33,12 +33,12 @@ idf.py -p $(YOUR_SERIAL_PORT) flash monitor
33
33
34
34
The valiable ` YOU_WISH_TO_TRY_FILE ` can be replaced with one of the following:
35
35
36
- * _ simplest_mrb .rb_ - Simply prints two strings
37
- * _ gpio .rb_ - An example of using GPIO
38
- * _ wifi_example_mrb .rb_ - An example of connecting to WiFi, you will need to
39
- modify this file to include your SSID and password
40
- * _ mqtt_publish.rb_ - An sample of publishing to MQTT broker
41
- * _ system_mrb .rb_ - Examples of most of the system APIs
36
+ * _ simplest .rb_ - Prints two strings
37
+ * _ system .rb_ - Demonstrates most system APIs
38
+ * _ gpio .rb_ - GPIO blink example
39
+ * _ wifi_connect.rb _ - Connects to WiFi. You need to replace your SSID and password in this file.
40
+ * _ mqtt_publish.rb_ - Publishes to MQTT broker
41
+ * _ filesystem .rb_ - Write/Append/Read example on the virtual filesystem
42
42
43
43
The clean command will clean both the ESP32 build and the mruby build:
44
44
Original file line number Diff line number Diff line change
1
+ # Wait a bit for startup to complete.
2
+ ESP32 ::System . delay ( 1000 )
3
+
4
+ string1 = "testing "
5
+ string2 = "1,2,3..."
6
+
7
+ puts "Writing to /spiffs/test.txt: \" #{ string1 } #{ string2 } \" "
8
+ File . open ( '/spiffs/test.txt' , 'w' ) { |f | f . write ( string1 ) }
9
+ File . open ( '/spiffs/test.txt' , 'a' ) { |f | f . write ( string2 ) }
10
+
11
+ print "Read from /spiffs/text.txt: "
12
+ File . open ( '/spiffs/test.txt' , 'r' ) { |f | f . each_line { |l | puts l } }
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
1
+ # Stack sizes may need to be increased.
2
+ # See: https://github.com/mruby-esp32/mruby-socket/blob/0.4/README.md
3
+ #
4
+ puts "Getting ready to start Wi-Fi"
5
+
6
+ wifi = ESP32 ::WiFi . new
7
+
8
+ wifi . on_connected do |ip |
9
+ puts "Wi-Fi Connected: #{ ip } (#{ Socket . gethostname } )"
10
+ soc = TCPSocket . open ( "www.kame.net" , 80 )
11
+ msg = "HEAD / HTTP/1.1\r \n Host: www.kame.net\r \n Connection: close\r \n \r \n "
12
+ msg . split ( "\r \n " ) . each do |e |
13
+ puts ">>> #{ e } "
14
+ end
15
+ soc . send ( msg , 0 )
16
+ puts "--------------------------------------------------------------------------------"
17
+ loop do
18
+ buf = soc . recv ( 128 , 0 )
19
+ break if buf . length == 0
20
+ print buf
21
+ end
22
+ puts ""
23
+ puts "--------------------------------------------------------------------------------"
24
+ end
25
+
26
+ wifi . on_disconnected do
27
+ puts "Wi-Fi Disconnected"
28
+ end
29
+
30
+ puts "Connecting to Wi-Fi"
31
+ wifi . connect ( 'SSID' , 'PASSWORD' )
32
+
33
+ #
34
+ # Loop forever otherwise the script ends
35
+ #
36
+ while true do
37
+ ESP32 ::System . delay ( 1000 )
38
+ end
You can’t perform that action at this time.
0 commit comments