module Tello::Wifi
Attributes
macos_airport[RW]
tello_ssid[RW]
Public Class Methods
connect(ssid = nil)
click to toggle source
Find and connect to a Tello
Wi-Fi
# 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()
click to toggle source
Connect to an SSID stored in `@tello_ssid`
# 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()
click to toggle source
Look for a Tello
Wi-Fi SSID starting with “TELLO-” Returns an SSID, e.g. “TELLO-B5889D”, or `nil` if nothing found
# 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()
click to toggle source
Linux `#connect_tello_wifi`
# 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()
click to toggle source
Linux `#get_tello_wifi`
# File lib/tello/wifi.rb, line 112 def linux_get_tello_wifi puts "`#linux_get_tello_wifi` not implemented"; false end
linux_wifi_connected?()
click to toggle source
Linux `#wifi_connected?`
# File lib/tello/wifi.rb, line 83 def linux_wifi_connected? puts "`#linux_connected?` not implemented"; false end
macos_connect_tello_wifi()
click to toggle source
macOS `#connect_tello_wifi`
# 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()
click to toggle source
macOS `#get_tello_wifi`
# 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?()
click to toggle source
macOS `#wifi_connected?`
# 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?()
click to toggle source
Check if already connected to a Tello
Wi-Fi, e.g. “TELLO-A5983D”
# 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()
click to toggle source
Windows `#connect_tello_wifi`
# 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()
click to toggle source
Windows `#get_tello_wifi`
# File lib/tello/wifi.rb, line 117 def windows_get_tello_wifi puts "`#windows_get_tello_wifi` not implemented"; false end
windows_wifi_connected?()
click to toggle source
Windows `#wifi_connected?`
# File lib/tello/wifi.rb, line 88 def windows_wifi_connected? puts "`#windows_connected?` not implemented"; false end