Martin Kojtal / Mbed 2 deprecated cc3000_simple_socket_demo

Dependencies:   NVIC_set_all_priorities cc3000_hostdriver_mbedsocket mbed

doTCPIP.h

Committer:
Kojto
Date:
2013-09-08
Revision:
0:ce33c63eefe5

File content as of revision 0:ce33c63eefe5:

/****************************************************************************
*
*  doTCPIP.h - CC3000 TCP/IP
*  Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
*
*  Redistribution and use in source and binary forms, with or without
*  modification, are permitted provided that the following conditions
*  are met:
*
*    Redistributions of source code must retain the above copyright
*    notice, this list of conditions and the following disclaimer.
*
*    Redistributions in binary form must reproduce the above copyright
*    notice, this list of conditions and the following disclaimer in the
*    documentation and/or other materials provided with the
*    distribution.
*
*    Neither the name of Texas Instruments Incorporated nor the names of
*    its contributors may be used to endorse or promote products derived
*    from this software without specific prior written permission.
*
*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
*  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*****************************************************************************/

#ifndef DOTCPIP_H
#define DOTCPIP_H

#include "cc3000.h"

/** TCP/IP Functions
*
*/
#ifndef FALSE
#define FALSE 0
#endif

#ifndef TRUE
#define TRUE 1
#endif

#define SMART_CONFIG_SET 0x55
#define TCPIP_PORT 15000

#define USE_DHCP      1
#define USE_STATIC_IP 2

#define NONE 0
#define WEP  1
#define WPA  2
#define WPA2 3

// Modify the following settings as necessary for your Wi-Fi Network setup:
#define IP_ALLOC_METHOD USE_DHCP        // for DHCP assigned IP address
//#define IP_ALLOC_METHOD USE_STATIC_IP // for static IP address

// Default SSID Settings
#define AP_KEY       "87654321"
#define AP_SECURITY     WPA2            // WPA2 must be enabled for use with iPhone or Android phone hotspot!
#define SSID           "test"
//#define AP_SECURITY    NONE          // no security but will connect quicker!
#define STATIC_IP_OCT1 192
#define STATIC_IP_OCT2 168
#define STATIC_IP_OCT3 0
#define STATIC_IP_OCT4 103

#define STATIC_GW_OCT4 1             // Static Gateway address  = STATIC_IP_OCT1.STATIC_IP_OCT2.STATIC_IP_OCT3.STATIC_GW_OCT4

#define REQ_BUFFER_SIZE 400

// typedef struct {
//     uint8_t FTC;           // First time config performed
//     uint8_t PP_version[2]; // Patch Programmer version
//     uint8_t SERV_PACK[2];  // Service Pack Version
//     uint8_t DRV_VER[3];    // Driver Version
//     uint8_t FW_VER[3];     // Firmware Version
//     uint8_t validCIK;      // CIK[] is valid (Client Interface Key)
//     uint8_t CIK[40];
// } userFS_t;

extern mbed_cc3000::tUserFS userFS;

// extern volatile uint32_t ulSmartConfigFinished,ulCC3000DHCP, OkToDoShutDown, ulCC3000DHCP_configured;
// extern int32_t server_running;
// extern volatile uint8_t newData;
// extern uint8_t ForceFixedSSID;
// extern int8_t runSmartConfig;
// extern int8_t requestBuffer[];
 extern uint8_t myMAC[8];
 extern uint8_t SmartConfigProfilestored;

// extern void StartSmartConfig(void);

bool check_dhcp(void);
void start_smart_config(void);
void create_tcp_connection(int32_t port);
void init_tcp(void);
void run_tcp_server(void);
void do_FTC(void);

#endif // DOTCPIP_H