Setting physical channel parameters from an agent

56 views Asked by At

In the startup method of my agent I get the agent ID of the physical agent as:
phy = agentForService(Services.PHYSICAL)

Then I have tried different ways to set the powerLevel but usually something like:
phy.send(new ParameterReq().set(PhysicalChannelParam.powerLevel, -20))
phy.send(new ParameterReq().set(PhysicalChannelParam.powerLevel, [-20 -20 -20])) phy.set(PhysicalChannelParam.powerLevel, [-20 -20 -20]

Neither of them works.
I guess this is because there are multiple physical channels (CONTROL, DATA).
How do I specify which channel type to change the power level of?

EDIT:
A solution was to apparently to change the parameter directly:
control_channel = phy[1]
control_channel.powerLevel = -20
However, this feels like violating the basic ideas behind Fjåge.

1

There are 1 answers

2
Mandar Chitre On BEST ANSWER

The phy[1].powerLevel = -20 syntax is just a syntactic sugar for roughly this:

def phy = agentForService(Services.PHYSICAL)
def req = new ParameterReq(phy)
req.setIndex(1)
req.set(PhysicalChannelParam.powerLevel, -20)
def rsp = request(req, 1000)
assert rsp?.get(PhysicalChannelParam.powerLevel) == -20

The req.setIndex(1) was the magic ingredient you were missing.

Also see: ParameterReq API docs.