Experiment.name = "caliber-1b"
Experiment.project = "orbit:tutorial"

#define variables used in experimennt

txPowerLevel = [ 1, 10, 50, 100]
channelSetting = [1,2,3,4,5,6,7,8,9,10,11]

#
# Define nodes used in experiment
#
#defNodes('otgSender', [1,2]) {|node|
#  node.image = nil  # assume the right image to be on disk
#  node.prototype("test:proto:sender", {
#    'destinationHost' => '192.168.1.1',
#    'packetSize' => 1024,
#    'rate' => 300,
#    'protocol' => 'udp'
#  })
#  node.net.w0.mode = "master"
#}

defNodes('rssiMonitorCard0', [1,1]) {|node|
  node.image = nil  # assume the right image to be on disk
  node.prototype("test:proto:rssimonitor" , {
    'interface' => 'ath0',
    'txpowerSetting' => 1,
  })
  node.net.w0.mode = "monitor"
  node.net.w0.type = 'b'
  node.net.w0.channel = 6
  node.net.w0.essid = "helloworld"
  node.net.w0.ip = "%192.168.%x.%y"
}

#defNodes('rssiMonitorCard1', [1,1]) {|node|
#  node.image = nil  # assume the right image to be on disk
#  node.prototype("test:proto:rssimonitor" , {
#    'interface' => 'ath1',
#    'txpowerSetting' => 1,
#  })
#  node.net.w1.mode = "monitor"
#}

#allNodes.net.w0 { |w|
#  w.type = 'b'
#  w.channel = 6
#  w.essid = "helloworld"
#  w.ip = "%192.168.%x.%y"
#}

whenAllInstalled() {|node|

  nodes('rssiMonitorCard0').startApplications
 
  channelnumber.each {|channelSetting|
   nodes('sender').net.w0.channel = channelnumber
   wait 30
 }

#
# Now, start the application
#
whenAllInstalled() {|node|
  wait 30
  #nodes('otgSender').startApplications
  #wait 10
  #nodes('otgSender').stopApplications
  nodes('rssiMonitor').startApplications
  #allNodes.startApplications
  wait 10

  Experiment.done
}
