Connect to SSID, get ip by dhcp, ping google.com, display statistics

Dependencies:   NVIC_set_all_priorities cc3000_hostdriver_mbedsocket mbed

Committer:
Kojto
Date:
Sat Sep 14 05:13:00 2013 +0000
Revision:
0:26d9788555b6
Child:
1:1ef047ffeef4
initial version of cc3000 ping demo;   - ping google.com and print statistics

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 0:26d9788555b6 1 /* mbed Microcontroller Library
Kojto 0:26d9788555b6 2 * Copyright (c) 2006-2013 ARM Limited
Kojto 0:26d9788555b6 3 *
Kojto 0:26d9788555b6 4 * Licensed under the Apache License, Version 2.0 (the "License");
Kojto 0:26d9788555b6 5 * you may not use this file except in compliance with the License.
Kojto 0:26d9788555b6 6 * You may obtain a copy of the License at
Kojto 0:26d9788555b6 7 *
Kojto 0:26d9788555b6 8 * http://www.apache.org/licenses/LICENSE-2.0
Kojto 0:26d9788555b6 9 *
Kojto 0:26d9788555b6 10 * Unless required by applicable law or agreed to in writing, software
Kojto 0:26d9788555b6 11 * distributed under the License is distributed on an "AS IS" BASIS,
Kojto 0:26d9788555b6 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Kojto 0:26d9788555b6 13 * See the License for the specific language governing permissions and
Kojto 0:26d9788555b6 14 * limitations under the License.
Kojto 0:26d9788555b6 15 */
Kojto 0:26d9788555b6 16 #ifndef MAIN_H
Kojto 0:26d9788555b6 17 #define MAIN_H
Kojto 0:26d9788555b6 18
Kojto 0:26d9788555b6 19 #ifndef FALSE
Kojto 0:26d9788555b6 20 #define FALSE 0
Kojto 0:26d9788555b6 21 #endif
Kojto 0:26d9788555b6 22
Kojto 0:26d9788555b6 23 #ifndef TRUE
Kojto 0:26d9788555b6 24 #define TRUE 1
Kojto 0:26d9788555b6 25 #endif
Kojto 0:26d9788555b6 26
Kojto 0:26d9788555b6 27 #define SMART_CONFIG_SET 0x55
Kojto 0:26d9788555b6 28 #define TCPIP_PORT 15000
Kojto 0:26d9788555b6 29
Kojto 0:26d9788555b6 30 #define USE_DHCP 1
Kojto 0:26d9788555b6 31 #define USE_STATIC_IP 2
Kojto 0:26d9788555b6 32
Kojto 0:26d9788555b6 33 #define NONE 0
Kojto 0:26d9788555b6 34 #define WEP 1
Kojto 0:26d9788555b6 35 #define WPA 2
Kojto 0:26d9788555b6 36 #define WPA2 3
Kojto 0:26d9788555b6 37
Kojto 0:26d9788555b6 38 // Modify the following settings as necessary for your Wi-Fi Network setup:
Kojto 0:26d9788555b6 39 #define IP_ALLOC_METHOD USE_DHCP // for DHCP assigned IP address
Kojto 0:26d9788555b6 40 //#define IP_ALLOC_METHOD USE_STATIC_IP // for static IP address
Kojto 0:26d9788555b6 41
Kojto 0:26d9788555b6 42 // Default SSID Settings
Kojto 0:26d9788555b6 43 #define AP_KEY "87654321"
Kojto 0:26d9788555b6 44 #define AP_SECURITY WPA2 // WPA2 must be enabled for use with iPhone or Android phone hotspot!
Kojto 0:26d9788555b6 45 #define SSID "test"
Kojto 0:26d9788555b6 46 //#define AP_SECURITY NONE // no security but will connect quicker!
Kojto 0:26d9788555b6 47 #define STATIC_IP_OCT1 192
Kojto 0:26d9788555b6 48 #define STATIC_IP_OCT2 168
Kojto 0:26d9788555b6 49 #define STATIC_IP_OCT3 0
Kojto 0:26d9788555b6 50 #define STATIC_IP_OCT4 103
Kojto 0:26d9788555b6 51
Kojto 0:26d9788555b6 52 #define STATIC_GW_OCT4 1 // Static Gateway address = STATIC_IP_OCT1.STATIC_IP_OCT2.STATIC_IP_OCT3.STATIC_GW_OCT4
Kojto 0:26d9788555b6 53
Kojto 0:26d9788555b6 54 #define REQ_BUFFER_SIZE 400
Kojto 0:26d9788555b6 55
Kojto 0:26d9788555b6 56 #define WIGO_BOARD 1
Kojto 0:26d9788555b6 57
Kojto 0:26d9788555b6 58 #if (WIGO_BOARD == 1)
Kojto 0:26d9788555b6 59
Kojto 0:26d9788555b6 60 #define SET_PWR_EN1 PWR_EN1 = 0
Kojto 0:26d9788555b6 61 #define SET_PWR_EN2 PWR_EN2 = 1
Kojto 0:26d9788555b6 62
Kojto 0:26d9788555b6 63 #define WLAN_ISF_PCR PORTA->PCR[16]
Kojto 0:26d9788555b6 64 #define WLAN_ISF_ISFR PORTA->ISFR
Kojto 0:26d9788555b6 65 #define WLAN_ISF_MASK (1<<16)
Kojto 0:26d9788555b6 66
Kojto 0:26d9788555b6 67 #define CLEAR_PCR_INTERRUPT WLAN_ISF_PCR|=PORT_PCR_ISF_MASK;
Kojto 0:26d9788555b6 68 #define CLEAN_PORT_INTERRUPT WLAN_ISF_ISFR|=WLAN_ISF_MASK;
Kojto 0:26d9788555b6 69
Kojto 0:26d9788555b6 70 #else
Kojto 0:26d9788555b6 71
Kojto 0:26d9788555b6 72 #endif
Kojto 0:26d9788555b6 73
Kojto 0:26d9788555b6 74 #endif