# SoftBank Robotics documentation What's new in NAOqi 2.8?

# ALConnectionManager

NAOqi Core - Overview | API | NetworkInfo | NetworkInfo-IPInfo

## What it does

ALConnectionManager provides methods to manage the network connectivity. It contains commands allowing you to configure or connect a network, but also to get the network properties or to create a network.

ALConnectionManager supports several technologies such as Ethernet, WiFi and Bluetooth.

The main features are:

- List available network services.
- Connect to a network service.
- Create a network service (supports WiFi Access Point and Bluetooth PAN).
- List available network technologies.
- Configure a network service.

This module gives access to useful information about the different network services, such as the strength of a WiFi service, its current state or its security requirement.

This module notifies through events the changes about the network connectivity.

## How it works

ALConnectionManager is based on the open source software ConnMan to get information about all networks services and connecting to them.

SoftBank Robotics is a contributor to the ConnMan project, our ConnMan sources are hosted on github http://github.com/aldebaran, only a few patches differs from the official ConnMan version, our goal is to limit as much as possible the differences between the two versions.

The WiFi services are handled by WPA Supplicant. The Bluetooth services are handled by BlueZ.

## Performance and Limitations

Limitation

- ALConnectionManager is only available on the robot.
- ALConnectionManager currently doesn’t support WPA entreprise security.
- The list of WiFi services are not available when the tethering mode is enabled.
- ALConnectionManager does not handle bluetooth devices pairing.

## Warning about tethering and security issue

The Tethering mode makes the robot acting as an Access Point, but it also shares your Internet connectivity. If the robot is connected to a corporate network, you have to verify if this mode is compatible with your network security policy.

## Getting Started

Essential information to deal with ALConnectionManager:

Services objects from ConnectionManager are represented as NetworkInfo.

Getting the global state of the network connectivity

    #! /usr/bin/env python
    # -*- encoding: UTF-8 -*-

    """Example: Use state Method"""

    import qi
    import argparse
    import sys

    def main(session):
        """
        This example uses the state method.
        """
        # Get the service ALConnectionManager.

        con_mng_service = session.service("ALConnectionManager")

        # Get network state.
        print "Network state: " + con_mng_service.state()

    if __name__ == "__main__":
        parser = argparse.ArgumentParser()
        parser.add_argument("--ip", type=str, default="127.0.0.1",
                            help="Robot IP address. On robot or Local Naoqi: use '127.0.0.1'.")
        parser.add_argument("--port", type=int, default=9559,
                            help="Naoqi port number")

        args = parser.parse_args()
        session = qi.Session()
        try:
            session.connect("tcp://" + args.ip + ":" + str(args.port))
        except RuntimeError:
            print ("Can't connect to Naoqi at ip \"" + args.ip + "\" on port " + str(args.port) +".\n"
                   "Please check your script arguments. Run with -h option for help.")
            sys.exit(1)
        main(session)

Getting the network services list

    #! /usr/bin/env python
    # -*- encoding: UTF-8 -*-

    """Example: Use scan and services Methods"""

    import qi
    import argparse
    import sys

    def main(session):
        """
        This example uses the scan and services method.
        """
        # Get the service ALConnectionManager.

        con_mng_service = session.service("ALConnectionManager")

        #Scanning is required to update the services list
        con_mng_service.scan()
        services = con_mng_service.services()

        for service in services:
            network = dict(service)
            if network["Name"] == "":
                print "{hidden} " + network["ServiceId"]
            else:
                print network["Name"] + " " + network["ServiceId"]

    if __name__ == "__main__":
        parser = argparse.ArgumentParser()
        parser.add_argument("--ip", type=str, default="127.0.0.1",
                            help="Robot IP address. On robot or Local Naoqi: use '127.0.0.1'.")
        parser.add_argument("--port", type=int, default=9559,
                            help="Naoqi port number")

        args = parser.parse_args()
        session = qi.Session()
        try:
            session.connect("tcp://" + args.ip + ":" + str(args.port))
        except RuntimeError:
            print ("Can't connect to Naoqi at ip \"" + args.ip + "\" on port " + str(args.port) +".\n"
                   "Please check your script arguments. Run with -h option for help.")
            sys.exit(1)
        main(session)

Glossary Site map Index Support Contact Legal Notices