Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion platform/arduino/wtfconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

# path to arduino directory... must be changed
IDE = "/home/jacob/dev/arduino_project/MeshableMCU/arduino-1.5.6-r2"
BOARD = "gmc200_dbg"

arduino_comm = wtf.comm.Serial(port="/dev/ttyUSB2", prompt="")
arduino_comm.name = "arduino"
Expand All @@ -20,4 +21,4 @@
sta = wtf.node.ap.Hostapd(sta_ssh, [iface], ops=ops)

wtf.conf = wtf.config("arduino", comm=arduino_comm, nodes=[sta],
name="arduino mc200 tests", data={'IDE': IDE})
name="arduino mc200 tests", data={'IDE': IDE, 'BOARD': BOARD})
16 changes: 6 additions & 10 deletions tests/arduino.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ def setUpClass(cls):
cls.IDE = wtfconfig.data['IDE']
else:
cls.IDE = ''
if 'BOARD' in wtfconfig.data:
cls.BOARD = wtfconfig.data['BOARD']
else:
cls.BOARD = 'mc200_dbg'

# set up a fake X server for a computer without one...
if not 'DISPLAY' in cls.env or cls.env['DISPLAY'] == '':
Expand Down Expand Up @@ -81,7 +85,7 @@ def build_and_upload(self, build_path):
self.fail("You do not have the correct arduino ide directory path set")

ret = Popen(["./arduino", "--upload", "--board",
"cozybit:mc200:mc200_dbg", "-v", "--pref",
"cozybit:mc200:%s" % self.BOARD, "-v", "--pref",
"build.path=" + self.build_dir, "--port", self.cereal.port,
build_path], env=self.env)
ret.wait()
Expand All @@ -97,14 +101,12 @@ def setup_run(self, path, write=None):

def start_hostapd(self, apconf):
""" Set hostap.conf and init/start node """
self.AP.stop()
self.AP.config = apconf
self.AP.init()
self.AP.start()
time.sleep(5)

def stop_hostapd(self):
self.AP.stop()

def test_01_string_addition_operators(self):
self.setup_run('./examples/08.Strings/StringAdditionOperator/'
'StringAdditionOperator.ino')
Expand Down Expand Up @@ -250,12 +252,9 @@ def test_14_string_to_int(self):
def test_15_connect_wifi_no_password(self):
self.start_hostapd(ap.APConfig(ssid="wtf-arduino-ap"))
self.setup_run(os.getcwd() + '/platform/arduino/SimpleWiFi/SimpleWiFi.ino')
# set to 20 incase connection takes longer than 10 seconds
time.sleep(20)
self.ffd.expect(re.escape("You're connected to the network"));
# [1-9] first so we don't match 0.0.0.0 with d+.d+.d+.d+
self.ffd.expect(re.escape("the ip is ") + r'[1-9]\d+\.\d+\.\d+\.\d+')
self.stop_hostapd()

def test_16_connect_wifi_with_password(self):
self.start_hostapd(ap.APConfig(ssid="wtf-arduino-pass-ap",
Expand All @@ -264,9 +263,6 @@ def test_16_connect_wifi_with_password(self):
password="thisisasecret",
encrypt=ap.ENCRYPT_CCMP))
self.setup_run(os.getcwd() + '/platform/arduino/SimpleWiFiPass/SimpleWiFiPass.ino')
# set to 20 incase connection takes longer than 10 seconds
time.sleep(20)
self.ffd.expect(re.escape("You're connected to the password protected network"));
# [1-9] first so we don't match 0.0.0.0 with d+.d+.d+.d+
self.ffd.expect(re.escape("the ip is ") + r'[1-9]\d+\.\d+\.\d+\.\d+')
self.stop_hostapd()
18 changes: 17 additions & 1 deletion wtf/node/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"""WTF network node definitions."""

import os
import time
from collections import namedtuple
from textwrap import dedent
import time

from wtf.util import CapData
from wtf.util import PerfConf
Expand Down Expand Up @@ -622,3 +623,18 @@ def bond(self, ifaces, ip):
for iface in ifaces:
self._cmd_or_die("ip addr flush " + iface.name)
self._cmd_or_die("ifenslave bond0 " + iface.name)

def start_udhcpd(self):
"""Start udhcpd, assumes it is on the system"""
n = 10
for iface in self.iface:
self.set_ip(iface.name, "192.168.%d.1" % n)
dhcp_conf = dedent("""
start 192.168.%d.10
end 192.168.%d.100
interface %s
""" % (n, n, iface.name))
self.comm.send_cmd("killall udhcpd")
self._cmd_or_die("echo -e \"" + dhcp_conf + "\">/tmp/udhcp.conf")
self._cmd_or_die("udhcpd /tmp/udhcp.conf")
n += 1
1 change: 1 addition & 0 deletions wtf/node/ap.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def start(self):
raise node.InsufficientConfigurationError()
self._configure()
self._cmd_or_die("hostapd -B /tmp/hostapd.conf")
self.start_udhcpd()

def stop(self):
node.LinuxNode.stop(self)
Expand Down