Exemplo n.º 1
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
Exemplo n.º 2
0
def get_transport(sel_transport, softap_endpoint=None):
    try:
        tp = None
        if (sel_transport == 'softap'):
            tp = transport.Transport_Softap(softap_endpoint)
        return tp
    except RuntimeError as e:
        print(e)
        return None
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 5
0
                    help="increase output verbosity",
                    action="store_true")
args = parser.parse_args()

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 ----"