Ignore:
Timestamp:
2015-04-10T13:52:11Z (10 years ago)
Author:
Jan Kolarik <kolarik@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a931b7b
Parents:
d7dadcb4
Message:

Locking, correctly disconnecting device, sending DHCP address discover after connecting to WiFi network

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/wifi_supplicant/wifi_supplicant.c

    rd7dadcb4 r053fc2b  
    3636#include <ieee80211_iface.h>
    3737
     38#include <inet/inetcfg.h>
     39#include <inet/dhcp.h>
    3840#include <errno.h>
    3941#include <stdio.h>
     
    173175        }
    174176       
    175         int rc = ieee80211_connect(sess, ssid_start, password);
     177        int rc = ieee80211_disconnect(sess);
     178        if(rc != EOK) {
     179                if(rc == EREFUSED) {
     180                        printf("Device is not ready yet.\n");                   
     181                } else {
     182                        printf("Error when disconnecting device. "
     183                                "Error: %d\n", rc);
     184                }
     185               
     186                return rc;
     187        }
     188       
     189        ieee80211_connect(sess, ssid_start, password);
    176190        if(rc != EOK) {
    177191                if(rc == EREFUSED) {
     
    179193                } else if(rc == ETIMEOUT) {
    180194                        printf("Timeout when authenticating to network.\n");
    181                 } else if(rc == EPERM) {
    182                         printf("Bad password provided.\n");
     195                } else if(rc == ENOENT) {
     196                        printf("Given SSID not in scan results.\n");
    183197                } else {
    184198                        printf("Error when connecting to network. "
     
    188202                return rc;
    189203        }
     204       
     205        // TODO: Wait for DHCP address ?
    190206       
    191207        printf("Successfully connected to network!\n");
     
    274290        int rc;
    275291        uint32_t index;
     292       
     293        rc = inetcfg_init();
     294        if (rc != EOK) {
     295                printf(NAME ": Failed connecting to inetcfg service (%d).\n",
     296                    rc);
     297                return 1;
     298        }
     299       
     300        rc = dhcp_init();
     301        if (rc != EOK) {
     302                printf(NAME ": Failed connecting to dhcp service (%d).\n", rc);
     303                return 1;
     304        }
    276305       
    277306        if(argc == 2) {
Note: See TracChangeset for help on using the changeset viewer.