コード例 #1
0
def block_server():
    """
    Provides a block server that uses Packet API functions to build the
    response.
    """
    base_folder = os.environ.get('RIOTAPPSBASE', None)
    board       = os.environ.get('BOARD', 'native')

    term_cmd = 'make term'
    term_resp = 'gcoap block handler'
        
    host = ExpectHost(os.path.join(base_folder, 'gcoap-block-server'), term_cmd,
                      putenv={'PORT':'tap1'})
    term = host.connect()
    term.expect(term_resp)

    # set ULA
    pid = '5' if proto_params['is_dtls'] else '6'
    cmd = 'ifconfig {0} add unicast fd00:bbbb::1/64'.format(pid)
    host.send_recv(cmd, 'success:')

    yield host

    # teardown
    host.disconnect()
コード例 #2
0
def rd_server():
    """Runs an aiocoap Resource Directory server as an ExpectHost."""
    folder = os.environ.get('AIOCOAP_BASE', None)

    host = ExpectHost(folder, './aiocoap-rd')
    term = host.connect()
    # allow a couple of seconds for initialization
    time.sleep(2)
    yield host

    # teardown
    host.disconnect()
コード例 #3
0
def cord_cli():
    """Runs the RIOT cord_epsim example process as an ExpectHost."""
    base_folder = os.environ.get('RIOTBASE', None)

    host = ExpectHost(os.path.join(base_folder, 'examples/cord_epsim'),
                      'make term')
    term = host.connect()
    term.expect('Simplified CoRE RD registration example')
    yield host

    # teardown
    host.disconnect()
コード例 #4
0
def retry_server(ignores):
    """Runs a server that ignores requests as an ExpectHost."""

    cmd = './con_ignore_server.py -i {0}'.format(ignores)

    host = ExpectHost(pwd, cmd)
    term = host.connect()
    # allow a couple of seconds for initialization
    time.sleep(2)
    yield host

    # teardown
    host.disconnect()
コード例 #5
0
def aiocoap_client():
    """Registers an observe client and waits for a notification."""
    # server handles same quantity of messages as client sends
    cmd = './observe_client.py -r [fd00:bbbb::2]'

    host = ExpectHost(pwd, cmd)
    term = host.connect()
    # allow a couple of seconds for initialization
    time.sleep(2)
    yield host

    # teardown
    host.disconnect()
コード例 #6
0
def aiocoap_client():
    """Runs an aiocoap client to query gcoap_example as a server."""
    # server handles same quantity of messages as client sends
    cmd = './repeat_send_client.py -r [fd00:bbbb::2] -p /cli/stats -q {0}'.format(
        10)

    host = ExpectHost(pwd, cmd)
    term = host.connect()
    # allow a couple of seconds for initialization
    time.sleep(2)
    yield host

    # teardown
    host.disconnect()
コード例 #7
0
def aiocoap_client():
    """Runs an aiocoap client to query gcoap_example as a server."""
    # server handles same quantity of messages as client sends
    cmdText = './repeat_send_client.py -r [fd00:bbbb::2] -p /cli/stats -q {0} {1}'
    cmd = cmdText.format(
        10, '-c dtls-credentials.json' if proto_params['is_dtls'] else '')

    host = ExpectHost(pwd, cmd)
    term = host.connect()
    # allow a couple of seconds for initialization
    time.sleep(2)
    yield host

    # teardown
    host.disconnect()
コード例 #8
0
def cord_cli():
    """Runs the RIOT cord_ep example process as an ExpectHost."""
    base_folder = os.environ.get('RIOTBASE', None)

    host = ExpectHost(os.path.join(base_folder, 'examples/cord_ep'), 'make term')
    term = host.connect()
    term.expect('CoRE RD client example!')

    # set ULA
    host.send_recv('ifconfig 7 add unicast fd00:bbbb::2/64',
                   'success:')
    yield host

    # teardown
    host.disconnect()
コード例 #9
0
def libcoap_server(request):
    """Runs a libcoap example server process, and provides a pexpect spawn
       object to interact with it."""
    folder = os.environ.get('LIBCOAP_BASE', None)
    if folder:
        cmd = os.path.join('examples/coap-server')
    else:
        cmd = 'coap-server'

    host = ExpectHost(folder, cmd)
    term = host.connect()
    yield host

    # teardown
    host.disconnect()
コード例 #10
0
def aiocoap_client():
    """Registers an observe client and waits for a notification."""

    # server handles same quantity of messages as client sends
    dtls_arg = '-c dtls-credentials.json' if proto_params['is_dtls'] else ''
    cmd = './observe_client.py -r [fd00:bbbb::2] {0}'.format(dtls_arg)

    #host = ExpectHost(pwd, cmd, putenv={'PYTHONPATH' : '/home/kbee/dev/aiocoap/repo'})
    host = ExpectHost(pwd, cmd)
    term = host.connect()
    # allow a couple of seconds for initialization
    time.sleep(2)
    yield host

    # teardown
    host.disconnect()
コード例 #11
0
def nano_block_client():
    """
    Provides an ExpectHost that runs the nanocoap block client app.
    """
    base_folder = os.environ.get('RIOTAPPSBASE', None)

    host = ExpectHost(os.path.join(base_folder, 'nano-block-client'), 'make term')
    term = host.connect()
    term.expect('nanocoap block client app')

    # set ULA
    host.send_recv('ifconfig 5 add unicast fd00:bbbb::2/64','success:')

    yield host

    # teardown
    host.disconnect()
コード例 #12
0
def lwm2m_client():
    """
    Provides an ExpectHost that runs the LwM2M client app.
    """
    base_folder = os.environ.get('RIOTAPPSBASE', None)

    host = ExpectHost(os.path.join(base_folder, 'lwm2m-client'), 'make term')
    term = host.connect()
    term.expect('This is RIOT!')

    # set ULA
    host.send_recv('ifconfig 6 add unicast fd00:bbbb::2/64', 'success:')

    yield host

    # teardown
    host.disconnect()
コード例 #13
0
def gcoap_block_client():
    """
    Provides an ExpectHost that runs the nanocoap block client app.
    """
    base_folder = os.environ.get('RIOTAPPSBASE', None)

    host = ExpectHost(os.path.join(base_folder, 'gcoap-block-client'), 'make term')
    term = host.connect()
    term.expect('gcoap block client')

    # set ULA
    pid = '5' if proto_params['is_dtls'] else '6'
    cmd = 'ifconfig {0} add unicast fd00:bbbb::2/64'.format(pid)
    host.send_recv(cmd, 'success:')

    yield host

    # teardown
    host.disconnect()
コード例 #14
0
def leshan_server(tmpdir):
    """
    Provides an ExpectHost that runs the Leshan LwM2M server app.
    """
    base_folder = os.environ.get('LESHAN_BASE', None)
    board = os.environ.get('BOARD', 'native')

    jar = '{0}/leshan-server-demo/target/leshan-server-demo-1.0.0-SNAPSHOT-jar-with-dependencies.jar'.format(
        base_folder)
    term_cmd = 'java -jar {0} --coaphost [fd00:bbbb::1]'.format(jar)
    term_resp = 'Web server started'

    host = ExpectHost(tmpdir, term_cmd)
    term = host.connect()
    term.expect(term_resp)

    yield host

    # teardown
    host.disconnect()
コード例 #15
0
def pkt_block_server():
    """
    Provides a block server that uses Packet API functions to build the
    response.
    """
    base_folder = os.environ.get('RIOTAPPSBASE', None)
    board = os.environ.get('BOARD', 'native')

    term_cmd = 'make term'
    term_resp = 'gcoap block handler'

    host = ExpectHost(os.path.join(base_folder, 'gcoap-block-server'),
                      term_cmd)
    term = host.connect()
    term.expect(term_resp)

    # set ULA
    host.send_recv('ifconfig 6 add unicast fd00:bbbb::2/64', 'success:')

    yield host

    # teardown
    host.disconnect()