diff options
author | Edi Feschiyan <edi.feschiyan@konsulko.com> | 2020-03-09 15:28:38 +0200 |
---|---|---|
committer | Edi Feschiyan <edi.feschiyan@konsulko.com> | 2020-03-09 15:43:47 +0200 |
commit | 5ef7f0b592e609775352ad41c3fd656b10f86d24 (patch) | |
tree | cdbfb68c494b1f9e1d48930ec0523e067e0ad089 /geoclue.py | |
parent | da9b205f77f0e88ca808bbbf2bbd95d661f29ac4 (diff) |
Writing abstract class, adding geoclue
Diffstat (limited to 'geoclue.py')
-rw-r--r-- | geoclue.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/geoclue.py b/geoclue.py new file mode 100644 index 0000000..d296397 --- /dev/null +++ b/geoclue.py @@ -0,0 +1,33 @@ +import asyncio +from random import randint +from aglbaseservice import AGLBaseService, AFBT + + +class GeoClueService(AGLBaseService): + def __init__(self): + super().__init__(api='geoclue', ip='192.168.234.202', port='30009') + + async def location(self): + verb = 'location' + msgid = randint(0, 999999) + + await self.send(f'[2,"{msgid}","{self.api}/{verb}",""]') + return await self.receive() + + async def subscribe(self, event='location'): + super().subscribe(event=event) + + async def unsubscribe(self, event='location'): + super().unsubscribe(event=event) + + +async def main(loop): + GCS = await GeoClueService() + print(await GCS.location()) + listener = loop.create_task(GCS.listener()) + await listener + + +if __name__ == '__main__': + loop = asyncio.get_event_loop() + loop.run_until_complete(main(loop)) |