wifi provisioning demo

After flashing the cc3200 launchpad a way of setting the wlan credentials have to be accomplished for connecting to a wifi access point.

The following python script prompt the user the wlan identifier and the password and setup the board.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"""Persist a WLAN profile to the board
"""
import logging
import asyncio
import sys
import click
import pynais as ns

logging.basicConfig(
    level=logging.DEBUG,
    format='%(name)s: %(message)s',
    stream=sys.stderr
)
LOG = logging.getLogger()


async def main(port):
    sock = await ns.connect('0.0.0.0', port)

    uid = ''
    while not uid:
        uid = input("enter username: ")

    pwd = ''
    while not pwd:
        pwd = input("enter password: ")

    add_profile = ns.msg.Profile(uid, pwd)

    # send the profile message to enable wifi and autoconnect the board to AP
    # send the config message to configure the server ip address
    await ns.proto_send(sock, add_profile, wait_ack=True)

    sock.close()


@click.command()
@click.option('--port', default=3002, help='line port')
def trampoline(port):
    """Starter
    """
    loop = asyncio.get_event_loop()

    loop.run_until_complete(main(port))
    loop.close()


#pylint: disable=E1120
if __name__ == "__main__":
    trampoline()

The script connect to the NAIS junction using tcp port 3002. It is the work of junction to deliver the message using the serial port to the board.

Just for give a little taste of a NAIS junction use case, you could test the frontend provisioning script attaching a virtual board at the junction in case the hardware is not ready for integration.