* switch from mbed to mbed-src, which works better with my board * list APs and their RSSI * read CC3000 firmware version
Dependencies: cc3000_hostdriver_mbedsocket mbed-src
Fork of cc3000_hello_world_demo_sparkfun by
main.cpp@4:2304a105c87f, 2013-11-06 (annotated)
- Committer:
- Kojto
- Date:
- Wed Nov 06 17:03:29 2013 +0000
- Revision:
- 4:2304a105c87f
- Parent:
- 1:c3a27e2adf93
- Child:
- 7:a4e91e42f008
update to the newest host driver, change to use EthernetInterface
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Kojto | 0:db8738fc21e8 | 1 | /* mbed Microcontroller Library |
Kojto | 0:db8738fc21e8 | 2 | * Copyright (c) 2006-2013 ARM Limited |
Kojto | 0:db8738fc21e8 | 3 | * |
Kojto | 0:db8738fc21e8 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
Kojto | 0:db8738fc21e8 | 5 | * you may not use this file except in compliance with the License. |
Kojto | 0:db8738fc21e8 | 6 | * You may obtain a copy of the License at |
Kojto | 0:db8738fc21e8 | 7 | * |
Kojto | 0:db8738fc21e8 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
Kojto | 0:db8738fc21e8 | 9 | * |
Kojto | 0:db8738fc21e8 | 10 | * Unless required by applicable law or agreed to in writing, software |
Kojto | 0:db8738fc21e8 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
Kojto | 0:db8738fc21e8 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Kojto | 0:db8738fc21e8 | 13 | * See the License for the specific language governing permissions and |
Kojto | 0:db8738fc21e8 | 14 | * limitations under the License. |
Kojto | 0:db8738fc21e8 | 15 | */ |
Kojto | 0:db8738fc21e8 | 16 | #include "mbed.h" |
Kojto | 0:db8738fc21e8 | 17 | #include "cc3000.h" |
Kojto | 0:db8738fc21e8 | 18 | #include "main.h" |
Kojto | 0:db8738fc21e8 | 19 | |
Kojto | 0:db8738fc21e8 | 20 | using namespace mbed_cc3000; |
Kojto | 0:db8738fc21e8 | 21 | |
Kojto | 0:db8738fc21e8 | 22 | /* cc3000 module declaration specific for user's board. Check also init() */ |
Kojto | 0:db8738fc21e8 | 23 | #if (MY_BOARD == WIGO) |
Kojto | 4:2304a105c87f | 24 | cc3000 wifi(PTA16, PTA13, PTD0, SPI(PTD2, PTD3, PTC5), "ssid", "key", WPA2, false); |
Kojto | 0:db8738fc21e8 | 25 | Serial pc(USBTX, USBRX); |
Kojto | 0:db8738fc21e8 | 26 | #elif (MY_BOARD == WIFI_DIPCORTEX) |
Kojto | 4:2304a105c87f | 27 | cc3000 wifi(p28, p27, p30, SPI(p21, p14, p37), "ssid", "key", WPA2, false); |
Kojto | 0:db8738fc21e8 | 28 | Serial pc(UART_TX, UART_RX); |
Kojto | 4:2304a105c87f | 29 | #elif (MY_BOARD == MBED_BOARD_EXAMPLE) |
Kojto | 4:2304a105c87f | 30 | cc3000 wifi(p9, p10, p8, SPI(p5, p6, p7), "ssid", "key", WPA2, false); |
Kojto | 4:2304a105c87f | 31 | Serial pc(USBTX, USBRX); |
Kojto | 0:db8738fc21e8 | 32 | #else |
Kojto | 0:db8738fc21e8 | 33 | |
Kojto | 0:db8738fc21e8 | 34 | #endif |
Kojto | 0:db8738fc21e8 | 35 | |
Kojto | 0:db8738fc21e8 | 36 | /** |
Kojto | 4:2304a105c87f | 37 | * \brief Hello World |
Kojto | 0:db8738fc21e8 | 38 | * \param none |
Kojto | 0:db8738fc21e8 | 39 | * \return int |
Kojto | 0:db8738fc21e8 | 40 | */ |
Kojto | 0:db8738fc21e8 | 41 | int main() { |
Kojto | 0:db8738fc21e8 | 42 | init(); /* board dependent init */ |
Kojto | 0:db8738fc21e8 | 43 | pc.baud(115200); |
Kojto | 0:db8738fc21e8 | 44 | |
Kojto | 0:db8738fc21e8 | 45 | printf("cc3000 Hello World demo. \r\n"); |
Kojto | 4:2304a105c87f | 46 | wifi.init(); |
Kojto | 4:2304a105c87f | 47 | if (wifi.connect() == -1) { |
Kojto | 4:2304a105c87f | 48 | printf("Failed to connect. Please verify connection details and try again. \r\n"); |
Kojto | 4:2304a105c87f | 49 | } else { |
Kojto | 4:2304a105c87f | 50 | printf("IP address: %s \r\n",wifi.getIPAddress()); |
Kojto | 4:2304a105c87f | 51 | printf("\r\ncc3000 connected to the Internet. Demo completed. \r\n"); |
Kojto | 0:db8738fc21e8 | 52 | } |
Kojto | 1:c3a27e2adf93 | 53 | |
Kojto | 0:db8738fc21e8 | 54 | wifi.disconnect(); |
Kojto | 0:db8738fc21e8 | 55 | } |
Kojto | 0:db8738fc21e8 | 56 |