/****************************************************************************
**
** Copyright (c) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator
**
**
** GNU Free Documentation License
**
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of this
** file.
**
**
****************************************************************************/

    /*!

    \contentspage index.html
    \previouspage creator-developing-maemo.html
    \page creator-developing-meego.html
    \nextpage creator-developing-qnx.html

    \title Connecting MeeGo Harmattan Devices

    MeeGo Harmattan is a Linux-based software platform developed by Nokia for
    mobile devices. It allows developers to create applications using the Qt
    framework. You can install and configure the whole tool chain that you need
    to create, build, debug, run, and deploy Harmattan applications as part of
    the Qt 4 SDK.

    \note In \QC 2.7, and later, the Madde plugin that you need for MeeGo
    development is disabled by default. To enable it, select \gui Help >
    \gui {About Plugins} > \gui {Device Support} > \gui Madde and restart \QC.

    For more information about the Harmattan platform, see
    \l{http://library.developer.nokia.com/topic/MeeGo_1.2_Harmattan_API/html/guide/html/Developer_Library_Harmattan_overview_5dcf.html}
    {Harmattan Overview} in the MeeGo 1.2 Harmattan Developer Library.

    \note Qt 4 SDK does not contain the tool chains for building applications for
    other MeeGo devices than MeeGo Harmattan. You can try to run applications
    from \QC on other MeeGo devices, but it has not been extensively
    tested, and the instructions might not always apply.

    \note The only supported build system for Harmattan in \QC is qmake.

    \section1 Setting Up Connectivity in Harmattan Devices

    To build and run Qt applications for Harmattan, you need a Harmattan device:
    Nokia N950 or Nokia N9.

    You can connect your device to your development PC using either a USB or
    WLAN connection.

    For the device, you need to use the SDK Connectivity tool that is
    preinstalled on the device to create the device-side end point for USB and
    WLAN connections. It provides no diagnostics functions but is essential for
    creating connections between the device and your development PC.

    To use a WLAN connection, you must activate WLAN on the device and connect
    it to the same WLAN as the development PC. The network address is displayed
    in the connectivity tool.

    To use a USB connection, you might need to set up the device as a network
    device on the development PC. However, on Linux, Mac OS X, and Windows 7,
    the USB interface is usually automatically configured.

    \note If you plan to connect your development PC to the device only over
    WLAN, you can ignore the USB-specific parts in the following sections.

    \section2 Starting SDK Connectivity

    SDK Connectivity application is preinstalled in Harmattan devices and
    available in developer mode.

    To start SDK Connectivity:

    \list

        \li On the device, select \gui {Settings > Security > Developer
            mode} to turn on developer mode.

        \li Select \gui {Applications > SDK Connectivity} to start the SDK
            Connectivity application.

        \li Select \gui {Select Connection} and then select the type of the
            connection to create: \gui WLAN or \gui USB.

        \li For a USB connection, select the operating system of the
            development PC in \gui {Select Module}.

    \endlist

    \gui {Connectivity Details} displays the IP address and developer password.
    The address 192.168.2.15 is used by default. You must enter the password in
    \QC. For more information, see
    \l{Configuring Connections to Harmattan Devices}.

    \section1 Setting Up Network Connectivity on Development PC

    Use the network configuration tools on your platform to specify the
    connection to the device on the development PC. You need to do this
    only if you use a USB connection.

    The device uses the IP address 192.168.2.15 with the subnet 255.255.255.0
    for its USB connection by default, so you can create the network interface
    with a different address inside the same subnet too.

    \note If you have changed the IP address of the device in the connectivity
    tool, you need to reflect those changes in your development PC USB
    network settings.

    \section2 Linux

    The USB interface is automatically configured. If, for some reason, that is
    not the case, run the following command in a shell as root user to create a
    new network interface:

    \c{ifconfig usb0 192.168.2.14 up}

    \section2 Mac OS X

    The USB interface is automatically configured. If, for some reason, that is
    not the case, create a new network interface manually:

    \list

        \li Open the network settings.

        \li Click the + button on the network settings panel.

        \li When the interface is available, select \gui {Configure IPv4 > Using
            DHCP with manual address}.

        \li  Enter the address 192.168.2.14 into the IP address field.

        \li  Click \gui Apply.

        The network connection between your device and workstation is now
        configured.

    \endlist

    \section2 Windows 7

    When you connect your device to your Windows 7 computer, Windows installs a
    driver for the Linux USB Ethernet connection automatically. If the
    installation does not start, unplug the USB cable and try another USB port
    on your computer.

    \note Driver installation takes some time.

    The USB interface is automatically configured. If, for some reason, that is
    not the case, create a new network interface manually:

    \list 1

        \li Open the \gui {Network and Sharing Center} and select \gui {Change
            adapter settings}.

            The Linux USB Ethernet connection you just installed is displayed
            as a new \gui {Local Area Connection Linux USB Ethernet/RNDIS
            gadget}.

            \note If you cannot see \gui {Linux USB Ethernet/RNDIS gadget}, try
            to unplug and replug the USB cable.

        \li Right-click \gui {Linux USB Ethernet/RNDIS gadget} and select
            \gui Properties.

    \li Edit the \gui {Internet Protocol Version 4 (TCP/IPv4)} properties
        to specify the IP address for the connection. In the \gui {Use the
        following IP address} field, enter the following values:

        \list

           \li \gui {IP Address}: \b {192.168.2.14}
           \li \gui SubnetMask: \b {255.255.255.0}
           \li \gui {Default gateway}: leave this field empty

        \endlist

    \endlist

    \section2 Windows XP

    If you develop on Windows XP and use a USB connection to run applications on
    the device, you need the Nokia USB drivers that are installed as part of the
    Qt 4 SDK.

    When you connect the device to your Windows PC, Windows tries to install a
    driver for the Linux USB Ethernet connection. In the
    \gui{Found New Hardware Wizard}, select \gui{No, not this time} in the
    first dialog and \gui{Install the software automatically} in the second
    dialog.

    To specify a network connection:

    \list 1

    \li Open the Network Connections window.

    \li Select the Linux USB Ethernet connection that is displayed as a new
        Local Area Connection.

    \li Edit the \gui {Internet Protocol Version 4 (TCP/IPv4)} properties
        to specify the IP address for the connection. In the \gui {Use the
        following IP address} field, enter the following values:

        \list

           \li \gui {IP Address}: \b {192.168.2.14}
           \li \gui SubnetMask: \b {255.255.255.0}
           \li \gui {Default gateway}: leave this field empty

        \endlist

    \endlist

    Depending on your version of Microsoft Windows you may have to unplug and
    re-plug the device to reload the driver with its configuration accordingly.

    \section1 Configuring Connections to Harmattan Devices

    To be able to run and debug applications on the emulator and devices, you
    must set up connections to the emulator and devices in the \QC build
    and run settings. If you install Qt 4 SDK, the connection to the emulator is
    configured automatically and you only need to configure a connection to the
    device.

    You use a wizard to create the connections. You can edit the settings later
    in \gui Tools > \gui Options > \gui Devices.

    \image qtcreator-meego-device-configurations.png "Devices dialog"

    By default, you create the connection as the \e developer user. This
    protects real user data on the device from getting corrupted during testing.
    If you write applications that use Qt Mobility APIs, you might want to test
    them with real user data. To create a connection as a user, specify the
    \gui Username and \gui Password in \QC. For more information, see
    \l{Testing with User Data on MeeGo Devices}.

    You can protect the connections between \QC and a device by using
    either a password or an SSH key. If you use a password, you must generate it
    in the connectivity tool and enter it in \QC every time you start the
    connectivity tool.

    If you do not have an SSH key, you can create it in \QC. Encrypted
    keys are not supported. For more information, see
    \l{Generating SSH Keys}.

    You can view processes running on devices and kill them. For more
    information, see
    \l{Managing Device Processes}.

    To configure connections between \QC and a device:

    \list 1

        \li To deploy applications and run them remotely on devices,
            specify parameters for accessing devices:

            \list a

                \li Connect your device to the development PC via a USB cable or
                    a WLAN. For a USB connection, you are prompted to select the
                    mode to use. Choose \gui{PC suite mode}.

                    \note If you experience connection problems due to a USB
                    port issue, switch to a different port or use WLAN to
                    connect to the device.

                \li Select \gui Tools > \gui Options > \gui Devices > \gui Add.

                \li Select \gui {MeeGo 1.2 Harmattan} > \gui {Start Wizard} to
                    add a new configuration for a device.

                    \image qtcreator-screenshot-devconf.png

                \li In the \gui {The name to identify this configuration} field,
                    enter a name for the connection.

                \li In the \gui {The kind of device} field, select
                    \gui {Hardware device}.

                \li In the \gui {The device's host name or IP address} field,
                    enter the IP address from the connectivity tool on the
                    device.

                \li In the \gui {The SSH server port} field, enter the port
                    number to use for SSH connections.

                \li Click \gui Next.

                \li Follow the instructions of the wizard to create the
                    configuration.

            \endlist

        \li To test applications on the emulator (QEMU), you must
            create a connection to it from the development PC. If you installed
            Qt 4 SDK, the connection is created automatically and you can omit this
            step.

            \list a

                \li In \QC, select \gui Tools > \gui Options > \gui Devices >
                    \gui Add to add a new configuration.

                \li Select \gui {MeeGo 1.2 Harmattan} > \gui {Start Wizard}.

                \li In the \gui {The name to identify this configuration} field,
                    enter a name for the connection.

                \li In the \gui {The kind of device} field, select
                    \gui Emulator.

                \li Click \gui Next.

                \li Follow the instructions of the wizard to create the
                    connection.

                    SDK Connectivity is not needed for emulator connections, and
                    therefore, you do not need to authenticate the emulator
                    connection.

            \endlist

            \li Select \gui Tools > \gui Options > \gui {Build & Run} >
                \gui Kits > \gui Add to add a kit for building for the device:

            \list a

                \li In the \gui {Device type} field, select
                    \gui {MeeGo 1.2 Harmattan}.

                \li In the \gui Device field, select the device that you added
                    above.

                \li In the \gui Sysroot field, specify the path to the sysroot.
                    By default, the Qt 4 SDK installer places sysroot in the
                    following folder:
                    \c{QtSDK\Madde\bin\sysroots\harmattan_sysroot_10.2011.34-1_slim}.

                \li In the \gui {Compiler type} field, select GCC.

                \li In the \gui Compiler field, specify the path to the GCC
                    compiler. By default, the Qt 4 SDK installer places the
                    compiler in the following folder:
                    \c{QtSDK\Madde\targets\harmattan_10.2011.34-1_rt1.2\bin\}.

                \li In the \gui Debugger field, specify the path to GDB. By
                    default, the Qt 4 SDK installer places the debugger
                    in the following folder:
                    \c{QtSDK\Madde\targets\harmattan_10.2011.34-1_rt1.2\bin\}.

                \li In the \gui {Qt version} field, choose the MADDE Qt version
                    for MeeGo 1.2 Harmattan. By default, the Qt 4 SDK installer
                    places qmake in the following folder:
                    \c{QtSDK\Madde\targets\harmattan_10.2011.34-1_rt1.2\bin\}.

             \endlist

                You can leave the \gui {Qt mkspec} field empty.

                    \li Open a project for an application you want to develop
                        for your device.

            \li Select \gui Projects > \gui {Build & Run} > \gui {Add Kit} to
                add the kit that you specified above.

                \li Select \gui Run to specify run settings for the project.

            \li The Qt Quick project wizards automatically set the folder
                where the file is installed on the device in the \gui {Remote
                Directory} field. For example, \c {/opt/usr/bin}. If the text
                \gui {<no target path set>} is displayed, click it to specify a
                folder.

        \endlist

    \section2 Testing with User Data on MeeGo Devices

    To run your application as the default user, you must first assign a
    password for the user account and then create the connection to the device
    as the user:

    \list 1

        \li On the device, select \gui Terminal to open a
            terminal window.

        \li To specify the password, enter the following command:
            \c{/usr/lib/mad-developer/devrootsh passwd user}

        \li In \QC, select \gui Tools > \gui Options > \gui Devices.

        \li Specify the username \c user and the password in the device
            configuration.

    \endlist

    \include linux-mobile/linuxdev-keys.qdocinc
    \include linux-mobile/linuxdev-processes.qdocinc

    \section1 Troubleshooting Harmattan Connections

    The addresses used in this example might be reserved by some other
    application in your network. If you cannot establish a connection, try the
    following optional configurations:

    \table

        \header
            \li  IP Address and Network on Device
            \li  USB Network on Development PC
            \li  Host Name in \QC Build Settings

        \row
            \li  172.30.7.15 255.255.255.0
            \li  172.30.7.14 255.255.255.0
            \li  172.30.7.15

        \row
            \li  10.133.133.15
            \li  10.133.133.14
            \li  10.133.133.15

        \row
            \li  192.168.133.15
            \li  192.168.133.14
            \li  192.168.133.15

            \note You cannot use the value localhost for connections to a
            device.

        \endtable

    \note VPN connections might block the device connection.

*/

