Example #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
Example #2
0
def get_transport(sel_transport, softap_endpoint=None, ble_devname=None):
    try:
        tp = None
        if (sel_transport == 'softap'):
            tp = transport.Transport_Softap(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
            tp = transport.Transport_BLE(
                devname=ble_devname,
                service_uuid='0000ffff-0000-1000-8000-00805f9b34fb',
                nu_lookup={
                    'prov-session': 'ff51',
                    'prov-config': 'ff52',
                    'proto-ver': 'ff53'
                })
        elif (sel_transport == 'console'):
            tp = transport.Transport_Console()
        return tp
    except RuntimeError as e:
        print(e)
        return None
Example #3
0
def get_transport(provmode, softap_endpoint=None, ble_devname=None):
    try:
        tp = None
        if (provmode == 'softap'):
            tp = transport.Transport_Softap(softap_endpoint)
        elif (provmode == 'ble'):
            tp = transport.Transport_BLE(ble_devname)
        elif (provmode == 'cli'):
            tp = transport.Transport_CLI()
        return tp
    except RuntimeError as e:
        print(e)
        return None
Example #4
0
def get_transport(sel_transport, softap_endpoint=None, ble_devname=None):
    try:
        tp = None
        if (sel_transport == 'softap'):
            tp = transport.Transport_Softap(softap_endpoint)
        elif (sel_transport == 'ble'):
            tp = transport.Transport_BLE(devname=ble_devname,
                                         service_uuid='0000ffff-0000-1000-8000-00805f9b34fb',
                                         nu_lookup={'prov-session': 'ff51',
                                                    'prov-config': 'ff52',
                                                    'proto-ver': 'ff53'
                                                    })
        elif (sel_transport == 'console'):
            tp = transport.Transport_Console()
        return tp
    except RuntimeError as e:
        on_except(e)
        return None
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
Example #6
0
print "==== Esp_Prov Version: 0.1 ===="

if args.secver == 1:
    security = security.Security1(args.pop, args.verbose)
elif args.secver == 0:
    security = security.Security0(args.verbose)
else:
    print "---- Unexpected state ----"
    exit(1)

if (args.provmode == 'softap'):
    transport = transport.Transport_Softap(args.softap_endpoint)

elif (args.provmode == 'ble'):
    try:
        transport = transport.Transport_BLE(args.ble_devname,
                                            verbose=args.verbose)
    except RuntimeError, e:
        print "---- Error occured in BLE provisioning mode ----"
        print e
        exit()

elif (args.provmode == 'cli'):
    transport = transport.Transport_CLI()

else:
    print "---- Invalid provisioning mode ----"
    exit()

print "==== Starting Session ===="
response = None
while True: