SNIC UART Interface library for Murata Type-YD module

Dependents:   WebSocketServerTest

Fork of SNICInterface_mod by Toyomasa Watarai

SNIC_WifiInterface.h

Committer:
kishino
Date:
2014-03-28
Revision:
25:67183ed15708
Parent:
24:987e412ae879
Child:
26:f2e1030964e4

File content as of revision 25:67183ed15708:

/******************* Murata Manufacturing Co.,Ltd. 2014 *****************
 *
 * Filename:   SNIC_WifiInterface.h
 *
 * Purpose:    This module has define of API for SNIC UART of Wi-Fi.
 *              
 * $Author: kishino $
 *
 * $Date: 2014/03/26 $
 *
 * $Revision: 0.0.0.1 $
 * ***********************************************************************/
#ifndef _SNIC_WIFIINTERFACE_H_
#define _SNIC_WIFIINTERFACE_H_

#include "SNIC_Core.h"
#include "MurataObject.h"

namespace murata_wifi
{

/** Wi-Fi status used by getWifiStatus(). */
typedef struct
{
    /** status */
    E_WIFI_STATUS status;
    /** Mac address */
    char mac_address[BSSID_MAC_LENTH];
    /** SSID */
    char ssid[SSID_MAX_LENGTH+1];
}tagWIFI_STATUS_T;

/** Interface class for using SNIC UART.
 */
class C_SNIC_WifiInterface : public C_MurataObject {
public:
    /** Constructor
        @param tx mbed pin to use for tx line of Serial interface
        @param rx mbed pin to use for rx line of Serial interface
        @param cts mbed pin to use for cts line of Serial interface
        @param rts mbed pin to use for rts line of Serial interface
        @param reset reset pin of the wifi module
        @param alarm alarm pin of the wifi module (default: NC)
        @param baud baud rate of Serial interface (default: 9600)
    */
    C_SNIC_WifiInterface(PinName tx, PinName rx, PinName cts, PinName rts, PinName reset, PinName alarm = NC, int baud = 115200);

    /** Initialize the interface.
        @return 0 on success, a negative number on failure
    */
    int init();

    /** Get Firmware version string.
        @param  version_p Pointer of FW version string.(null terminated)[output]
        @return 0:success/other:fail
        @note   This function is blocked until a returns.
                When you use it by UI thread, be careful. 
    */
    int getFWVersion( unsigned char *version_p );

    /** Connect to AP
        @param ssid_p       Wi-Fi SSID(null terminated)
        @param ssid_len     Wi-Fi SSID length
        @param sec_type     Wi-Fi security type.
        @param sec_key_len  Wi-Fi passphrase or security key length
        @param sec_key_p    Wi-Fi passphrase or security key
        @return 0 on success, a negative number on failure
        @note   This function is blocked until a returns.
                When you use it by UI thread, be careful. 
    */
    int connect(const char *ssid_p, unsigned char ssid_len, E_SECURITY sec_type, const char *sec_key_p, unsigned char sec_key_len);
  
    /** Disconnect from AP
        @return 0 on success, a negative number on failure
        @note   This function is blocked until a returns.
                When you use it by UI thread, be careful. 
    */
    int disconnect();

    /** Scan AP
        @param  ssid_p  Wi-Fi SSID(null terminated)
                        If do not specify SSID, set to NULL.
        @param  bssid_p Wi-Fi BSSID(null terminated)
                        If do not specify SSID, set to NULL.
        @param  result_handler_p Pointer of scan result callback function.
        @return 0 on success, a negative number on failure
        @note   This function is blocked until a returns.
                When you use it by UI thread, be careful. 
                Scan results will be notified by asynchronous callback function.
                If there is no continuity data, result_handler_p will be set NULL..
    */
    int scan( const char *ssid_p, unsigned char *bssid_p
            ,void (*result_handler_p)(tagSCAN_RESULT_T *scan_result) );

    /** Wi-Fi Turn on
        @param country_p Pointer of country code.
        @return 0 on success, a negative number on failure
        @note   This function is blocked until a returns.
                When you use it by UI thread, be careful. 
    */
    int wifi_on( const char *country_p );

    /** Wi-Fi Turn off
        @return 0 on success, a negative number on failure
        @note   This function is blocked until a returns.
                When you use it by UI thread, be careful. 
    */
    int wifi_off();

    /** Get Wi-Fi RSSI
        @param rssi_p Pointer of RSSI.[output]
        @return 0 on success, a negative number on failure
        @note   This function is blocked until a returns.
                When you use it by UI thread, be careful. 
    */
    int getRssi( signed char *rssi_p );

    /** Get Wi-Fi status
        @param status_p Pointer of status structure.[output]
        @return 0 on success, a negative number on failure
        @note   This function is blocked until a returns.
                When you use it by UI thread, be careful. 
    */
    int getWifiStatus( tagWIFI_STATUS_T *status_p);

#if 0  
  /** Get the MAC address of your Ethernet interface
   * \return a pointer to a string containing the MAC address
   */
  char* getMACAddress();
  
  /** Get the IP address of your Ethernet interface
   * \return a pointer to a string containing the IP address
   */
  char* getIPAddress();

  /** Get the Gateway address of your Ethernet interface
   * \return a pointer to a string containing the Gateway address
   */
  char* getGateway();
 
  /** Get the Network mask of your Ethernet interface
   * \return a pointer to a string containing the Network mask
   */
  char* getNetworkMask();
#endif

private:
    PinName mUART_tx;
    PinName mUART_rx;
    PinName mUART_cts;
    PinName mUART_rts;
    int     mUART_baud;
    PinName mModuleReset;
};
}
#endif  /* _YD_WIFIINTERFACE_H_ */