コード例 #1
0
def get_transport(sel_transport, service_name):
    try:
        tp = None
        if (sel_transport == 'softap'):
            if service_name is None:
                service_name = '192.168.4.1:80'
            tp = transport.Transport_HTTP(service_name)
        elif (sel_transport == 'ble'):
            if service_name is None:
                raise RuntimeError(
                    '"--service_name" must be specified for ble transport')
            # BLE client is now capable of automatically figuring out
            # the primary service from the advertisement data and the
            # characteristics corresponding to each endpoint.
            # Below, the service_uuid field and 16bit UUIDs in the nu_lookup
            # table are provided only to support devices running older firmware,
            # in which case, the automated discovery will fail and the client
            # will fallback to using the provided UUIDs instead
            nu_lookup = {
                'prov-session': 'ff51',
                'prov-config': 'ff52',
                'proto-ver': 'ff53'
            }
            tp = transport.Transport_BLE(
                devname=service_name,
                service_uuid='021a9004-0382-4aea-bff4-6b3f1c5adfb4',
                nu_lookup=nu_lookup)
        elif (sel_transport == 'console'):
            tp = transport.Transport_Console()
        return tp
    except RuntimeError as e:
        on_except(e)
        return None
コード例 #2
0
def get_transport(sel_transport, softap_endpoint=None, ble_devname=None):
    try:
        tp = None
        if (sel_transport == 'softap'):
            tp = transport.Transport_HTTP(softap_endpoint)
        elif (sel_transport == 'ble'):
            # BLE client is now capable of automatically figuring out
            # the primary service from the advertisement data and the
            # characteristics corresponding to each endpoint.
            # Below, the service_uuid field and 16bit UUIDs in the nu_lookup
            # table are provided only to support devices running older firmware,
            # in which case, the automated discovery will fail and the client
            # will fallback to using the provided UUIDs instead
            nu_lookup = {
                'prov-session': 'ff51',
                'prov-config': 'ff52',
                'proto-ver': 'ff53'
            }
            tp = transport.Transport_BLE(
                devname=ble_devname,
                service_uuid='0000ffff-0000-1000-8000-00805f9b34fb',
                nu_lookup=nu_lookup)
        elif (sel_transport == 'console'):
            tp = transport.Transport_Console()
        return tp
    except RuntimeError as e:
        on_except(e)
        return None
コード例 #3
0
def get_transport(sel_transport, service_name):
    """
    Get object of class `Transport` based on input parameters
    `sel_transport` - Transport Mode (softap/ble)
    `service_name` - Service Name to connect to
    """
    try:
        tp = None
        if (sel_transport == 'softap'):
            if service_name is None:
                service_name = '192.168.4.1:80'
            tp = transport.Transport_HTTP(service_name)
        elif (sel_transport == 'ble'):
            if service_name is None:
                raise RuntimeError(
                    '"--service_name" must be specified for ble transport')
            # BLE client is now capable of automatically figuring out
            # the primary service from the advertisement data and the
            # characteristics corresponding to each endpoint.
            # Below, the service_uuid field and 16bit UUIDs in the nu_lookup
            # table are provided only to support devices running older firmware,
            # in which case, the automated discovery will fail and the client
            # will fallback to using the provided UUIDs instead
            nu_lookup = {
                'prov-session': 'ff51',
                'prov-config': 'ff52',
                'proto-ver': 'ff53'
            }
            tp = transport.Transport_BLE(
                devname=service_name,
                service_uuid='0000ffff-0000-1000-8000-00805f9b34fb',
                nu_lookup=nu_lookup)
        elif (sel_transport == 'console'):
            tp = transport.Transport_Console()
        return tp
    except RuntimeError as e:
        on_except(e)
        return None