Module: Tello::Wifi
- Defined in:
- lib/tello/wifi.rb
Instance Attribute Summary collapse
-
#macos_airport ⇒ Object
Returns the value of attribute macos_airport.
-
#tello_ssid ⇒ Object
Returns the value of attribute tello_ssid.
Class Method Summary collapse
-
.connect(ssid = nil) ⇒ Object
Find and connect to a Tello Wi-Fi.
-
.connect_tello_wifi ⇒ Object
Connect to an SSID stored in ‘@tello_ssid`.
-
.get_tello_wifi ⇒ Object
Look for a Tello Wi-Fi SSID starting with “TELLO-” Returns an SSID, e.g.
-
.linux_connect_tello_wifi ⇒ Object
Linux ‘#connect_tello_wifi`.
-
.linux_get_tello_wifi ⇒ Object
Linux ‘#get_tello_wifi`.
-
.linux_wifi_connected? ⇒ Boolean
Linux ‘#wifi_connected?`.
-
.macos_connect_tello_wifi ⇒ Object
macOS ‘#connect_tello_wifi`.
-
.macos_get_tello_wifi ⇒ Object
macOS ‘#get_tello_wifi`.
-
.macos_wifi_connected? ⇒ Boolean
macOS ‘#wifi_connected?`.
-
.wifi_connected? ⇒ Boolean
Check if already connected to a Tello Wi-Fi, e.g.
-
.windows_connect_tello_wifi ⇒ Object
Windows ‘#connect_tello_wifi`.
-
.windows_get_tello_wifi ⇒ Object
Windows ‘#get_tello_wifi`.
-
.windows_wifi_connected? ⇒ Boolean
Windows ‘#wifi_connected?`.
Instance Attribute Details
#macos_airport ⇒ Object
Returns the value of attribute macos_airport.
6 7 8 |
# File 'lib/tello/wifi.rb', line 6 def macos_airport @macos_airport end |
#tello_ssid ⇒ Object
Returns the value of attribute tello_ssid.
6 7 8 |
# File 'lib/tello/wifi.rb', line 6 def tello_ssid @tello_ssid end |
Class Method Details
.connect(ssid = nil) ⇒ Object
Find and connect to a Tello Wi-Fi
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 |
# File 'lib/tello/wifi.rb', line 17 def connect(ssid = nil) # Skip connecting to Wi-Fi if in test mode if Tello.testing puts "In test mode, skipping Wi-Fi setup..." return true end # Assume Wi-Fi manually connected on Linux and Windows, for now # TODO: Actually implement unless Tello.os == :macos return true end # If provided SSID, set it, else look for a Tello Wi-Fi if ssid @tello_ssid = ssid else # Look for a Tello over Wi-Fi print "📶 Looking for Tello Wi-Fi..." # Done if already connected if wifi_connected? puts "already connected!" return true end # Search for a Tello Wi-Fi SSID (by default starting with "TELLO-") @tello_ssid = get_tello_wifi if @tello_ssid puts "found!" else puts "nothing found" return false end end # Connect to the Tello Wi-Fi print "🔗 Connecting to #{@tello_ssid}..." if connect_tello_wifi puts "done!"; true else puts "failed!"; false end end |
.connect_tello_wifi ⇒ Object
Connect to an SSID stored in ‘@tello_ssid`
122 123 124 125 126 127 128 129 130 131 |
# File 'lib/tello/wifi.rb', line 122 def connect_tello_wifi case Tello.os when :macos macos_connect_tello_wifi when :linux linux_connect_tello_wifi when :windows windows_connect_tello_wifi end end |
.get_tello_wifi ⇒ Object
Look for a Tello Wi-Fi SSID starting with “TELLO-” Returns an SSID, e.g. “TELLO-B5889D”, or ‘nil` if nothing found
94 95 96 97 98 99 100 101 102 103 |
# File 'lib/tello/wifi.rb', line 94 def get_tello_wifi case Tello.os when :macos macos_get_tello_wifi when :linux linux_get_tello_wifi when :windows windows_get_tello_wifi end end |
.linux_connect_tello_wifi ⇒ Object
Linux ‘#connect_tello_wifi`
142 143 144 |
# File 'lib/tello/wifi.rb', line 142 def linux_connect_tello_wifi puts "`#linux_get_tello_wifi` not implemented"; false end |
.linux_get_tello_wifi ⇒ Object
Linux ‘#get_tello_wifi`
112 113 114 |
# File 'lib/tello/wifi.rb', line 112 def linux_get_tello_wifi puts "`#linux_get_tello_wifi` not implemented"; false end |
.linux_wifi_connected? ⇒ Boolean
Linux ‘#wifi_connected?`
83 84 85 |
# File 'lib/tello/wifi.rb', line 83 def linux_wifi_connected? puts "`#linux_connected?` not implemented"; false end |
.macos_connect_tello_wifi ⇒ Object
macOS ‘#connect_tello_wifi`
134 135 136 137 138 139 |
# File 'lib/tello/wifi.rb', line 134 def macos_connect_tello_wifi # Assumes `en0` is wifi, might have to use this to confirm: # networksetup -listallhardwareports res = `networksetup -setairportnetwork en0 #{@tello_ssid}` res == '' ? true : false end |
.macos_get_tello_wifi ⇒ Object
macOS ‘#get_tello_wifi`
106 107 108 109 |
# File 'lib/tello/wifi.rb', line 106 def macos_get_tello_wifi res = `#{@macos_airport} scan`.match(/(tello-)\w+/i) res ? res[0] : nil end |
.macos_wifi_connected? ⇒ Boolean
macOS ‘#wifi_connected?`
78 79 80 |
# File 'lib/tello/wifi.rb', line 78 def macos_wifi_connected? if `#{@macos_airport} -I`.match(/(tello-)\w+/i) then true else false end end |
.wifi_connected? ⇒ Boolean
Check if already connected to a Tello Wi-Fi, e.g. “TELLO-A5983D”
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/tello/wifi.rb', line 66 def wifi_connected? @connected = case Tello.os when :macos macos_wifi_connected? when :linux linux_wifi_connected? when :windows windows_wifi_connected? end end |
.windows_connect_tello_wifi ⇒ Object
Windows ‘#connect_tello_wifi`
147 148 149 |
# File 'lib/tello/wifi.rb', line 147 def windows_connect_tello_wifi puts "`#windows_get_tello_wifi` not implemented"; false end |
.windows_get_tello_wifi ⇒ Object
Windows ‘#get_tello_wifi`
117 118 119 |
# File 'lib/tello/wifi.rb', line 117 def windows_get_tello_wifi puts "`#windows_get_tello_wifi` not implemented"; false end |
.windows_wifi_connected? ⇒ Boolean
Windows ‘#wifi_connected?`
88 89 90 |
# File 'lib/tello/wifi.rb', line 88 def windows_wifi_connected? puts "`#windows_connected?` not implemented"; false end |