Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b78c503b31 | |||
| b0caa42ca2 |
@@ -9,6 +9,8 @@ from georideapilib.objects import GeorideAccount
|
|||||||
import georideapilib.api as GeorideApi
|
import georideapilib.api as GeorideApi
|
||||||
from georideapilib.socket import GeorideSocket
|
from georideapilib.socket import GeorideSocket
|
||||||
|
|
||||||
|
from threading import Thread
|
||||||
|
|
||||||
_LOGGER = logging.getLogger('example')
|
_LOGGER = logging.getLogger('example')
|
||||||
|
|
||||||
|
|
||||||
@@ -23,11 +25,20 @@ def example():
|
|||||||
_LOGGER.info("token 1: %s", account.auth_token)
|
_LOGGER.info("token 1: %s", account.auth_token)
|
||||||
# pylint: disable=W0105
|
# pylint: disable=W0105
|
||||||
|
|
||||||
# socket = GeorideSocket()
|
def locked_locked(data):
|
||||||
# socket.init()
|
_LOGGER.info("Locke received")
|
||||||
# socket.connect(account.auth_token)
|
|
||||||
# time.sleep(10)
|
|
||||||
# socket.disconnect()
|
def connect_socket(account):
|
||||||
|
socket = GeorideSocket()
|
||||||
|
socket.subscribe_locked(locked_locked)
|
||||||
|
socket.init()
|
||||||
|
socket.connect(account.auth_token)
|
||||||
|
time.sleep(10)
|
||||||
|
socket.disconnect()
|
||||||
|
|
||||||
|
thread = Thread(target=connect_socket, args=(account))
|
||||||
|
thread.start()
|
||||||
|
|
||||||
"""
|
"""
|
||||||
account.auth_token = GeorideApi.renewToken(account.auth_token)
|
account.auth_token = GeorideApi.renewToken(account.auth_token)
|
||||||
|
|||||||
@@ -63,21 +63,21 @@ class GeorideSocket():
|
|||||||
""" on_message """
|
""" on_message """
|
||||||
_LOGGER.debug('Message received: %s', data)
|
_LOGGER.debug('Message received: %s', data)
|
||||||
if self._on_message_callback is not None:
|
if self._on_message_callback is not None:
|
||||||
self._on_message_callback()
|
self._on_message_callback(data)
|
||||||
|
|
||||||
@sio.on('device')
|
@sio.on('device')
|
||||||
def on_device(data):
|
def on_device(data):
|
||||||
""" on_device """
|
""" on_device """
|
||||||
_LOGGER.debug('Device received: %s', data)
|
_LOGGER.debug('Device received: %s', data)
|
||||||
if self._on_device_callback is not None:
|
if self._on_device_callback is not None:
|
||||||
self._on_device_callback()
|
self._on_device_callback(data)
|
||||||
|
|
||||||
@sio.on('position')
|
@sio.on('position')
|
||||||
def on_position(data):
|
def on_position(data):
|
||||||
""" on_position """
|
""" on_position """
|
||||||
_LOGGER.debug('Position received:%s', data)
|
_LOGGER.debug('Position received:%s', data)
|
||||||
if self._on_position_callback is not None:
|
if self._on_position_callback is not None:
|
||||||
self._on_position_callback()
|
self._on_position_callback(data)
|
||||||
|
|
||||||
@sio.on('alarm')
|
@sio.on('alarm')
|
||||||
def on_alarm(data):
|
def on_alarm(data):
|
||||||
@@ -98,7 +98,9 @@ class GeorideSocket():
|
|||||||
""" on_locked """
|
""" on_locked """
|
||||||
_LOGGER.debug('Locked received: %s', data)
|
_LOGGER.debug('Locked received: %s', data)
|
||||||
if self._on_locked_callback is not None:
|
if self._on_locked_callback is not None:
|
||||||
self._on_locked_callback()
|
self._on_locked_callback(data)
|
||||||
|
else:
|
||||||
|
_LOGGER.debug('Lallback is none')
|
||||||
|
|
||||||
self._initialised = True
|
self._initialised = True
|
||||||
|
|
||||||
|
|||||||
2
setup.py
2
setup.py
@@ -19,7 +19,7 @@ CURRENT_DIR = os.path.dirname(__file__)
|
|||||||
setup(
|
setup(
|
||||||
name='georideapilib',
|
name='georideapilib',
|
||||||
packages=['georideapilib'], # this must be the same as the name above
|
packages=['georideapilib'], # this must be the same as the name above
|
||||||
version='0.4.0',
|
version='0.4.1',
|
||||||
description='Lib to control georide tracker devices with their rest api',
|
description='Lib to control georide tracker devices with their rest api',
|
||||||
author='Matthieu DUVAL',
|
author='Matthieu DUVAL',
|
||||||
author_email='georideapilib@duval-dev.fr',
|
author_email='georideapilib@duval-dev.fr',
|
||||||
|
|||||||
Reference in New Issue
Block a user