This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Yamaha R-N301 control and PA System automation
#3
(09.07.2015, 11:54)admin Wrote: Nice example, one small improvement: you can use captures inside of regexps like this:

Code:
power=string.sub(string.match(response_body,"<Power>%a+</Power>"), 8, -9)

power=string.match(response_body,"<Power>(%a+)</Power>")

Both lines do exactly the same thing, but you don't have to count characters when using captures Smile

Rolleyes  You are right, didn't cross my mind to use string.match because the reply is pretty much static but will be helpfull on futher control.

Thank you

For anyone find it usefull below are the complete responce from Yamaha R-N301 on GET command. PUT command replies only the header section.

Headers:
Code:
200 OK
Server: Network_Player/3.1 (R-N301)
Content-Type: text/xml; charset="utf-8"
Content-Length: 480

Body:
Code:
<YAMAHA_AVrsp="GET"RC="0">
    <Main_Zone>
       <Basic_Status>
            <Power_Control>
                <Power>On</Power>
            </Power_Control>
        <Volume>
            <Lvl>
                <Val>45</Val>
                <Exp>0</Exp>
                <Unit/>
            </Lvl>
            <Mute>Off</Mute>
        </Volume>
        <Input>
            <Input_Sel>SERVER</Input_Sel>
            <Input_Sel_Item_Info>
            <Param>SERVER</Param>
            <RW>RW</RW>
            <Title/>
            <Icon>
                <On>/YamahaRemoteControl/Icons/icon067.png</On>
                <Off/>
            </Icon>
            <Src_Name>SERVER</Src_Name>
            <Src_Number>1</Src_Number>
            </Input_Sel_Item_Info>
        </Input>
       </Basic_Status>
    </Main_Zone>
</YAMAHA_AV>
Reply


Messages In This Thread
RE: Yamaha R-N301 control and PA System automation - by gtsamis - 09.07.2015, 15:18

Forum Jump: