36 import os, sys, string, time, getopt, re
42 from pr2_msgs.msg
import AccessPoint
44 from std_msgs.msg
import Header
46 wifi_data = {
"header": {
"seq": 24,
"stamp": 1257901832.6,
"frame_id":
"0"},
"networks": [{
"macaddr":
"00:18:F8:F9:6C:41",
"essid":
"willow",
"channel": 11,
"rssi": -35,
"noise": -88,
"beacon": 100}, {
"macaddr":
"00:18:F8:F9:6B:BD",
"essid":
"willow",
"channel": 11,
"rssi": -71,
"noise": -88,
"beacon": 100}, {
"macaddr":
"00:18:F8:F9:6C:1D",
"essid":
"willow",
"channel": 1,
"rssi": -70,
"noise": -92,
"beacon": 100}, {
"macaddr":
"00:30:44:03:1F:F9",
"essid":
"PRLAN",
"channel": 1,
"rssi": -73,
"noise": -92,
"beacon": 100}, {
"macaddr":
"00:30:44:03:1F:F4",
"essid":
"PRGLAN",
"channel": 2,
"rssi": -80,
"noise": -89,
"beacon": 100}, {
"macaddr":
"00:18:F8:F9:6C:4D",
"essid":
"willow",
"channel": 6,
"rssi": -81,
"noise": -86,
"beacon": 100}, {
"macaddr":
"00:18:F8:F9:6C:44",
"essid":
"willow",
"channel": 6,
"rssi": -79,
"noise": -85,
"beacon": 100}]}
49 if v < lower: v = lower
50 if v > upper: v = upper
55 self.
ap = AccessPoint()
60 ap = random.choice(wifi_data[
'networks'])
61 self.ap.macaddr = ap[
'macaddr']
62 self.ap.channel = ap[
'channel']
63 self.ap.essid = ap[
'essid']
64 self.ap.rate =
'54 Mbps' 65 self.ap.tx_power =
'71 mW' 66 self.ap.signal = random.randint(-100, -48)
73 if time.time() - self.
t > 20:
75 self.ap.signal =
minmax(self.ap.signal + random.randint(-d, d), -70, -20)
77 self.ap.snr =
minmax(self.ap.snr + random.randint(-d, d), 30, 90)
78 self.ap.noise =
minmax(self.ap.noise + random.randint(-d, d), -95, -30)
79 self.ap.quality = int(self.ap.signal * 1.24 + 116)
83 header.stamp = rospy.Time.now()
85 survey = SiteSurvey(header, networks)
87 for network
in wifi_data[
"networks"]:
88 network = Network(network[
'macaddr'], network[
'essid'], network[
'channel'], network[
'rssi'], network[
'noise'], network[
'beacon'])
89 survey.networks.append(network)
93 if time.time() - self.
t > 60:
98 self.ap.header = Header()
99 self.ap.header.stamp = rospy.Time.now()
104 rospy.init_node(
"wifi_ddwrt")
108 pub1 = rospy.Publisher(
"ddwrt/sitesurvey", SiteSurvey)
109 pub2 = rospy.Publisher(
"ddwrt/accesspoint", AccessPoint)
111 while not rospy.is_shutdown():
112 survey = ap.fetchSiteSurvey()
114 node = ap.fetchCurrentAP()
119 print __doc__ % vars()
121 def main(argv, stdout, environ):
123 optlist, args = getopt.getopt(argv[1:],
"", [
"help",])
125 for (field, val)
in optlist:
126 if field ==
"--help":
132 if __name__ ==
"__main__":
133 main(sys.argv, sys.stdout, os.environ)
def fetchSiteSurvey(self)
def main(argv, stdout, environ)
def minmax(v, lower, upper)