예제 #1
0
파일: Main.py 프로젝트: VladVons/mpy-vRelay
    async def MSetup(self, aPath: str, aParam: list):
        Vars = ConfApp.Keys()
        self._ShowTree(Vars)
        if (not await self.AskYN('Continue')):
            return

        R = {}
        Items = [
            'WiFi Access',
            [['STA_ESSID', 'SSID', 'oster.com.ua'],
             ['STA_Paswd', 'Password*', '']]
        ]
        R.update(await self.Input(Items, Vars))

        Items = [
            'Mqtt Server',
            [['Mqtt_Host', 'Host', 'vpn2.oster.com.ua'],
             ['Mqtt_Port', 'Port', 1883], ['Mqtt_Login', 'Login', ''],
             ['Mqtt_Paswd', 'Password', '']]
        ]
        R.update(await self.Input(Items, Vars))

        self._ShowTree(R)
        if (await self.AskYN('Save')):
            ConfApp.update(R)
            ConfApp.Save()
            print('Saved')
예제 #2
0
async def DoUrl(aParent, aReader: asyncio.StreamReader,
                aWriter: asyncio.StreamWriter, aHead: dict):
    LenData = int(aHead.get('content-length', '0'))
    if (LenData > 0):
        R = 'about to reboot'

        Data = await aReader.read(LenData)
        Query = QueryToDict(Data.decode('utf-8'))
        ConfApp['STA_ESSID'] = Query.get('_STA_ESSID')
        ConfApp['STA_Paswd'] = Query.get('_STA_Paswd')
        ConfApp.Save()

        Reset()
    else:
        R = 'No data'

    await aParent.Answer(aWriter, 200, 'txt', R)