Exemplo n.º 1
0
def main():
    mylogging.setLogging()
    LOG.debug('hello')
    queue = Queue.Queue(100)
    a = MyMQTT('172.17.0.2', 1883, queue)
    # attenion, subscribe should be done before init,
    # because multi-thread use the same list
    a.subscribe('ericsson/iot/things/ev3first/shadow')
    a.start()

    mygo = {'action': 'go', 'speed': 50}
    myback = {'action': 'back', 'speed': -50}
    mystop = {'action': 'stop'}

    mygo_str = json.dumps(mygo)
    myback_str = json.dumps(myback)
    mystop_str = json.dumps(mystop)

    while True:
        a.publish('ericsson/iot/things/ev3first/target', mygo_str)
        time.sleep(8)
        a.publish('ericsson/iot/things/ev3first/target', mystop_str)
        time.sleep(5)
        a.publish('ericsson/iot/things/ev3first/target', myback_str)
        time.sleep(8)
        a.publish('ericsson/iot/things/ev3first/target', mystop_str)
        time.sleep(5)

    a.stop()
    return 0
Exemplo n.º 2
0
def main():
    mylogging.setLogging(mylogging.DEBUG)
    LOG.debug('hello')
    queue = Queue.Queue(1)

    mynats = MyNATS('nats://172.17.0.2:4222', queue)
    mynats.subscribe('ericsson.iot.things.ev3first.shadow')
    mynats.start()
    while True:
        time.sleep(2)
Exemplo n.º 3
0
def main():
    mylogging.setLogging()
    LOG.debug('hello')
    queue = Queue.Queue(1)

    mynats = MyNATS('nats://172.17.0.3:4222', queue)
    mynats.subscribe('foo')
    mynats.start()
    while True:
        time.sleep(2)
Exemplo n.º 4
0
def main():
    mylogging.setLogging()
    LOG.debug('hello')
    myurl = MyUrl()
    headers = {
            'Content-Type': 'application/x-www-form-urlencoded',
            'Authorization': 'Basic ZWxpdXhpaTphcGNlcmE=',
            'Content-Length': 16
            }
    myurl.action('http://auth.myapceraliu4.apcera-platform.io/v1/oauth2/token',
                 'POST',
                 headers,
                 'grant_type=basic')
Exemplo n.º 5
0
def main():
    mylogging.setLogging()
    LOG.info('hello')