events for power on/off and vol up/down
### #350
while(true)
@buff = conn_.Recv(128,50)
if(@buff.length() == 0)
break
end
debugin(@buff)
response = @buff;
avrcommand = response[1..3]
avrvalue = response[5]
case avrcommand
when 'SRC'
log('input changed: '+ avrvalue);
input_param=0
case avrvalue
when 'D'
log('Input #420: CDR')
input_param=420
when '4'
log('Input #178: DSS')
input_param=178
when '2'
log('Input #165: DVD')
input_param=165
when '3'
log('Input #282: VCR-1')
input_param=282
when 'E'
log('Input #160: TAPE')
input_param=160
end
cmd = Command.new(device_.devid_, -1001, 1, 2, 49);
cmd.params_[41] = input_param.to_s();
SendCommand(cmd);
when 'VOL'
volume = response[5..-1].to_i();
log('volume changed: ' + volume.to_s);
SetDeviceDataInDB( device_.devid_, 158, volume.to_s ) # 158 = DEVICEDATA_Volume_Level_CONST
cmd = Command.new(device_.devid_, -1001, 1, 2, 71);
cmd.params_[30] = volume.to_s
SendCommand(cmd);
when 'PWR'
case avrvalue
when '1'
log('power changed: off');
cmd.params_[10] = "0";
when '2'
log('power changed: on');
cmd.params_[10] = "1";
end
cmd = Command.new(device_.devid_, -1001, 1, 2, 48);
SendCommand(cmd);
else
log('not handling command: ' + avrcommand.to_s())
end
end
### END OF #350