LMS 2012
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
c_wifi.h File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <fcntl.h>
#include <netdb.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/un.h>
#include <errno.h>
#include <bytecodes.h>
#include "wpa_ctrl.h"
#include "common.h"
#include "lms2012.h"

Go to the source code of this file.

Data Structures

struct  aps
 

Macros

#define _GNU_SOURCE
 
#define WIFI_PERSISTENT_PATH   vmSETTINGS_DIR
 
#define WIFI_PERSISTENT_FILENAME   "WiFiConnections.dat"
 
#define MAC_ADDRESS_LENGTH   18
 
#define FREQUENCY_LENGTH   5
 
#define SIGNAL_LEVEL_LENGTH   4
 
#define SECURITY_LENGTH   129
 
#define FRIENDLY_NAME_LENGTH   33
 
#define PSK_LENGTH   65
 
#define KEY_MGMT_LENGTH   33
 
#define PAIRWISE_LENGTH   33
 
#define GROUP_LENGTH   33
 
#define PROTO_LENGTH   33
 
#define WIFI_INIT_TIMEOUT   10
 
#define WIFI_INIT_DELAY   10
 
#define BROADCAST_IP_LOW   "255"
 
#define BROADCAST_PORT   3015
 
#define TCP_PORT   5555
 
#define BEACON_TIME   5
 
#define TIME_FOR_WIFI_DONGLE_CHECK   10
 
#define BLUETOOTH_SER_LENGTH   13
 
#define BRICK_HOSTNAME_LENGTH   (NAME_LENGTH + 1)
 
#define AP_FLAG_ADJUST_FOR_STORAGE   ((unsigned char)(~(VISIBLE + CONNECTED + UNKNOWN)))
 

Enumerations

enum  {
  WIFI_NOT_INITIATED, WIFI_INIT, WIFI_INITIATED, READY_FOR_AP_SEARCH,
  SEARCH_APS, SEARCH_PENDING, AP_LIST_UPDATED, AP_CONNECTING,
  WIFI_CONNECTED_TO_AP, UDP_NOT_INITIATED, INIT_UDP_CONNECTION, UDP_FIRST_TX,
  UDP_VISIBLE, UDP_CONNECTED, TCP_NOT_CONNECTED, TCP_CONNECTED,
  CLOSED
}
 
enum  { NOT_INIT = 0x00, LOAD_SUPPLICANT = 0x01, WAIT_ON_INTERFACE = 0x02, DONE = 0x80 }
 
enum  {
  TCP_IDLE = 0x00, TCP_WAIT_ON_START = 0x01, TCP_WAIT_ON_LENGTH = 0x02, TCP_WAIT_ON_FIRST_CHUNK = 0x04,
  TCP_WAIT_ON_ONLY_CHUNK = 0x08, TCP_WAIT_COLLECT_BYTES = 0x10
}
 
enum  BEACON_MODE { NO_TX, TX_BEACON }
 
enum  KNOWN_HW { HW_NOT_KNOWN, HW_KNOWN }
 
enum  TCP_STATES { TCP_DOWN, TCP_UP }
 
enum  {
  VISIBLE = 0x1, CONNECTED = 0x02, WPA2 = 0x04, KNOWN = 0x08,
  UNKNOWN = 0x80
}
 
enum  { NO_CONNECTION = 0x0, CONNECTION_MADE = 0x01, SEARCHING = 0x02 }
 

Functions

RESULT cWiFiGetIpAddr (char *IpAddress)
 
RESULT cWiFiGetMyMacAddr (char *MacAddress)
 
RESULT cWiFiKnownDongleAttached (void)
 
RESULT cWiFiTxingBeacons (void)
 
void cWiFiUdpClientClose (void)
 
RESULT cWiFiTcpConnected (void)
 
UWORD cWiFiWriteTcp (UBYTE *Buffer, UWORD Length)
 
UWORD cWiFiReadTcp (UBYTE *Buffer, UWORD Length)
 
void cWiFiMoveUpInList (int Index)
 
void cWiFiMoveDownInList (int Index)
 
void cWiFiDeleteInList (int Index)
 
RESULT cWiFiGetApMacAddr (char *MacAddr, int Index)
 
RESULT cWiFiGetHiddenMacAddr (char *MacAddr, int Index)
 
RESULT cWiFiGetName (char *ApName, int Index, char Length)
 
RESULT cWiFiSetName (char *ApName, int Index)
 
RESULT cWiFiSetSsid (char *Ssid)
 
RESULT cWiFiSetKeyManagToWpa2 (void)
 
RESULT cWiFiSetKeyManagToNone (void)
 
RESULT cWiFiGetIndexFromName (char *Name, UBYTE *Index)
 
void cWiFiSetEncryptToWpa2 (int Index)
 
void cWiFiSetEncryptToNone (int Index)
 
void cWiFiSetKnown (int Index)
 
void cWiFiDeleteAsKnown (int LocalIndex)
 
unsigned char cWiFiGetFlags (int Index)
 
RESULT cWiFiConnectToAp (int Index)
 
RESULT cWiFiMakePsk (char *ApSsid, char *PassPhrase, int Index)
 
int cWiFiGetApListSize (void)
 
void cWiFiIncApListSize (void)
 
RESULT cWiFiAddHidden (char *HiddenApName, char *Security, char *PassWord)
 
RESULT cWiFiScanForAPs (void)
 
RESULT cWiFiGetOnStatus (void)
 
RESULT cWiFiGetStatus (void)
 
void cWiFiSetBtSerialNo (void)
 
void cWiFiSetBrickName (void)
 
void cWiFiControl (void)
 
RESULT cWiFiTurnOn (void)
 
RESULT cWiFiTurnOff (void)
 
RESULT cWiFiExit (void)
 
RESULT cWiFiInit (void)
 

Macro Definition Documentation

#define _GNU_SOURCE

Definition at line 23 of file c_wifi.h.

#define AP_FLAG_ADJUST_FOR_STORAGE   ((unsigned char)(~(VISIBLE + CONNECTED + UNKNOWN)))

Definition at line 144 of file c_wifi.h.

#define BEACON_TIME   5

Definition at line 67 of file c_wifi.h.

#define BLUETOOTH_SER_LENGTH   13

Definition at line 71 of file c_wifi.h.

#define BRICK_HOSTNAME_LENGTH   (NAME_LENGTH + 1)

Definition at line 72 of file c_wifi.h.

#define BROADCAST_IP_LOW   "255"

Definition at line 64 of file c_wifi.h.

#define BROADCAST_PORT   3015

Definition at line 65 of file c_wifi.h.

#define FREQUENCY_LENGTH   5

Definition at line 50 of file c_wifi.h.

#define FRIENDLY_NAME_LENGTH   33

Definition at line 53 of file c_wifi.h.

#define GROUP_LENGTH   33

Definition at line 58 of file c_wifi.h.

#define KEY_MGMT_LENGTH   33

Definition at line 56 of file c_wifi.h.

#define MAC_ADDRESS_LENGTH   18

Definition at line 49 of file c_wifi.h.

#define PAIRWISE_LENGTH   33

Definition at line 57 of file c_wifi.h.

#define PROTO_LENGTH   33

Definition at line 59 of file c_wifi.h.

#define PSK_LENGTH   65

Definition at line 55 of file c_wifi.h.

#define SECURITY_LENGTH   129

Definition at line 52 of file c_wifi.h.

#define SIGNAL_LEVEL_LENGTH   4

Definition at line 51 of file c_wifi.h.

#define TCP_PORT   5555

Definition at line 66 of file c_wifi.h.

#define TIME_FOR_WIFI_DONGLE_CHECK   10

Definition at line 69 of file c_wifi.h.

#define WIFI_INIT_DELAY   10

Definition at line 62 of file c_wifi.h.

#define WIFI_INIT_TIMEOUT   10

Definition at line 61 of file c_wifi.h.

#define WIFI_PERSISTENT_FILENAME   "WiFiConnections.dat"

Definition at line 47 of file c_wifi.h.

#define WIFI_PERSISTENT_PATH   vmSETTINGS_DIR

Definition at line 46 of file c_wifi.h.

Enumeration Type Documentation

anonymous enum
Enumerator
WIFI_NOT_INITIATED 
WIFI_INIT 
WIFI_INITIATED 
READY_FOR_AP_SEARCH 
SEARCH_APS 
SEARCH_PENDING 
AP_LIST_UPDATED 
AP_CONNECTING 
WIFI_CONNECTED_TO_AP 
UDP_NOT_INITIATED 
INIT_UDP_CONNECTION 
UDP_FIRST_TX 
UDP_VISIBLE 
UDP_CONNECTED 
TCP_NOT_CONNECTED 
TCP_CONNECTED 
CLOSED 

Definition at line 74 of file c_wifi.h.

anonymous enum
Enumerator
NOT_INIT 
LOAD_SUPPLICANT 
WAIT_ON_INTERFACE 
DONE 

Definition at line 96 of file c_wifi.h.

anonymous enum
Enumerator
TCP_IDLE 
TCP_WAIT_ON_START 
TCP_WAIT_ON_LENGTH 
TCP_WAIT_ON_FIRST_CHUNK 
TCP_WAIT_ON_ONLY_CHUNK 
TCP_WAIT_COLLECT_BYTES 

Definition at line 104 of file c_wifi.h.

anonymous enum
Enumerator
VISIBLE 
CONNECTED 
WPA2 
KNOWN 
UNKNOWN 

Definition at line 135 of file c_wifi.h.

anonymous enum
Enumerator
NO_CONNECTION 
CONNECTION_MADE 
SEARCHING 

Definition at line 146 of file c_wifi.h.

Enumerator
NO_TX 
TX_BEACON 

Definition at line 114 of file c_wifi.h.

enum KNOWN_HW
Enumerator
HW_NOT_KNOWN 
HW_KNOWN 

Definition at line 121 of file c_wifi.h.

enum TCP_STATES
Enumerator
TCP_DOWN 
TCP_UP 

Definition at line 128 of file c_wifi.h.

Function Documentation

RESULT cWiFiAddHidden ( char *  HiddenApName,
char *  Security,
char *  PassWord 
)

Definition at line 1119 of file c_wifi.c.

RESULT cWiFiConnectToAp ( int  Index)

Definition at line 2011 of file c_wifi.c.

void cWiFiControl ( void  )

Definition at line 3462 of file c_wifi.c.

void cWiFiDeleteAsKnown ( int  LocalIndex)

Definition at line 1112 of file c_wifi.c.

void cWiFiDeleteInList ( int  Index)

Definition at line 597 of file c_wifi.c.

RESULT cWiFiExit ( void  )

Definition at line 3998 of file c_wifi.c.

int cWiFiGetApListSize ( void  )

Definition at line 2544 of file c_wifi.c.

RESULT cWiFiGetApMacAddr ( char *  MacAddr,
int  Index 
)

Definition at line 1064 of file c_wifi.c.

unsigned char cWiFiGetFlags ( int  Index)

Definition at line 1726 of file c_wifi.c.

RESULT cWiFiGetHiddenMacAddr ( char *  MacAddr,
int  Index 
)

Definition at line 1156 of file c_wifi.c.

RESULT cWiFiGetIndexFromName ( char *  Name,
UBYTE Index 
)

Definition at line 2152 of file c_wifi.c.

RESULT cWiFiGetIpAddr ( char *  IpAddress)

Definition at line 1197 of file c_wifi.c.

RESULT cWiFiGetMyMacAddr ( char *  MacAddress)

Definition at line 1209 of file c_wifi.c.

RESULT cWiFiGetName ( char *  ApName,
int  Index,
char  Length 
)

Definition at line 1681 of file c_wifi.c.

RESULT cWiFiGetOnStatus ( void  )

Definition at line 3875 of file c_wifi.c.

RESULT cWiFiGetStatus ( void  )

Definition at line 2601 of file c_wifi.c.

void cWiFiIncApListSize ( void  )

Definition at line 2536 of file c_wifi.c.

RESULT cWiFiInit ( void  )

Definition at line 4006 of file c_wifi.c.

RESULT cWiFiKnownDongleAttached ( void  )

Definition at line 1311 of file c_wifi.c.

RESULT cWiFiMakePsk ( char *  ApSsid,
char *  PassPhrase,
int  Index 
)

Definition at line 2078 of file c_wifi.c.

void cWiFiMoveDownInList ( int  Index)

Definition at line 586 of file c_wifi.c.

void cWiFiMoveUpInList ( int  Index)

Definition at line 465 of file c_wifi.c.

UWORD cWiFiReadTcp ( UBYTE Buffer,
UWORD  Length 
)

Definition at line 2824 of file c_wifi.c.

RESULT cWiFiScanForAPs ( void  )

Definition at line 2477 of file c_wifi.c.

void cWiFiSetBrickName ( void  )

Definition at line 3247 of file c_wifi.c.

void cWiFiSetBtSerialNo ( void  )

Definition at line 3234 of file c_wifi.c.

void cWiFiSetEncryptToNone ( int  Index)

Definition at line 1099 of file c_wifi.c.

void cWiFiSetEncryptToWpa2 ( int  Index)

Definition at line 1076 of file c_wifi.c.

RESULT cWiFiSetKeyManagToNone ( void  )

Definition at line 1006 of file c_wifi.c.

RESULT cWiFiSetKeyManagToWpa2 ( void  )

Definition at line 979 of file c_wifi.c.

void cWiFiSetKnown ( int  Index)

Definition at line 1107 of file c_wifi.c.

RESULT cWiFiSetName ( char *  ApName,
int  Index 
)

Definition at line 1699 of file c_wifi.c.

RESULT cWiFiSetSsid ( char *  Ssid)

Definition at line 927 of file c_wifi.c.

RESULT cWiFiTcpConnected ( void  )

Definition at line 2619 of file c_wifi.c.

RESULT cWiFiTurnOff ( void  )

Definition at line 3929 of file c_wifi.c.

RESULT cWiFiTurnOn ( void  )

Definition at line 3885 of file c_wifi.c.

RESULT cWiFiTxingBeacons ( void  )

Definition at line 2611 of file c_wifi.c.

void cWiFiUdpClientClose ( void  )

Definition at line 577 of file c_wifi.c.

UWORD cWiFiWriteTcp ( UBYTE Buffer,
UWORD  Length 
)

Definition at line 2757 of file c_wifi.c.