A WiFiDipCortex based robot. Control is via sockets over WiFi. See also: https://github.com/mfurseman/robo-android

Dependencies:   Motordriver USBDevice cc3000_hostdriver_mbedsocket_hacked mbed

Committer:
mfurseman
Date:
Sat Oct 18 02:28:52 2014 +0000
Revision:
0:993d6b65e255
Child:
1:b66a2d756c8a
Working connection after smartconfig setup

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mfurseman 0:993d6b65e255 1 #include "mbed.h"
mfurseman 0:993d6b65e255 2 #include "cc3000.h"
mfurseman 0:993d6b65e255 3 #include "USBSerial.h"
mfurseman 0:993d6b65e255 4
mfurseman 0:993d6b65e255 5 /* Quickly change debug flag to remove blocking serial code */
mfurseman 0:993d6b65e255 6 #define DEBUG
mfurseman 0:993d6b65e255 7 #ifdef DEBUG
mfurseman 0:993d6b65e255 8 USBSerial serial;
mfurseman 0:993d6b65e255 9 #define debug(x, ...) serial.printf(x, ##__VA_ARGS__);
mfurseman 0:993d6b65e255 10 #else
mfurseman 0:993d6b65e255 11 #define debug(x, ...)
mfurseman 0:993d6b65e255 12 #endif
mfurseman 0:993d6b65e255 13
mfurseman 0:993d6b65e255 14 using namespace mbed_cc3000;
mfurseman 0:993d6b65e255 15
mfurseman 0:993d6b65e255 16 /* On board LED */
mfurseman 0:993d6b65e255 17 DigitalOut led(P0_1);
mfurseman 0:993d6b65e255 18
mfurseman 0:993d6b65e255 19 /* Serial library for WiFi module */
mfurseman 0:993d6b65e255 20 cc3000 wifi(p28, p27, p30, SPI(p21, p14, p37));
mfurseman 0:993d6b65e255 21
mfurseman 0:993d6b65e255 22 /* Struct to hold connection data */
mfurseman 0:993d6b65e255 23 tNetappIpconfigRetArgs ipinfo;
mfurseman 0:993d6b65e255 24
mfurseman 0:993d6b65e255 25
mfurseman 0:993d6b65e255 26 void printConnectionInfo() {
mfurseman 0:993d6b65e255 27 if (( wifi.is_enabled() ) && ( wifi.is_dhcp_configured() )) {
mfurseman 0:993d6b65e255 28 wifi.get_ip_config(&ipinfo);
mfurseman 0:993d6b65e255 29 }
mfurseman 0:993d6b65e255 30 debug("\r\n");
mfurseman 0:993d6b65e255 31 if (! wifi.is_enabled() ) {
mfurseman 0:993d6b65e255 32 debug("CC3000 Disabled\r\n");
mfurseman 0:993d6b65e255 33 }
mfurseman 0:993d6b65e255 34 else if ( wifi.is_dhcp_configured() ) {
mfurseman 0:993d6b65e255 35 debug("SSID : %-33s|\r\n", ipinfo.uaSSID);
mfurseman 0:993d6b65e255 36 debug("IP : %-35s|\r\n", wifi.getIPAddress());
mfurseman 0:993d6b65e255 37 }
mfurseman 0:993d6b65e255 38 else if ( wifi.is_connected() ) {
mfurseman 0:993d6b65e255 39 debug("Connecting, waiting for DHCP\r\n");
mfurseman 0:993d6b65e255 40 }
mfurseman 0:993d6b65e255 41 else {
mfurseman 0:993d6b65e255 42 debug("Not Connected\r\n");
mfurseman 0:993d6b65e255 43 }
mfurseman 0:993d6b65e255 44 }
mfurseman 0:993d6b65e255 45
mfurseman 0:993d6b65e255 46 int main(void) {
mfurseman 0:993d6b65e255 47 NVIC_SetPriority(SSP1_IRQn, 0x0);
mfurseman 0:993d6b65e255 48 NVIC_SetPriority(PIN_INT0_IRQn, 0x1);
mfurseman 0:993d6b65e255 49
mfurseman 0:993d6b65e255 50 // SysTick set to lower priority than Wi-Fi SPI bus interrupt
mfurseman 0:993d6b65e255 51 NVIC_SetPriority(SysTick_IRQn, 0x2);
mfurseman 0:993d6b65e255 52
mfurseman 0:993d6b65e255 53 // Enable RAM1
mfurseman 0:993d6b65e255 54 LPC_SYSCON->SYSAHBCLKCTRL |= (0x1 << 26);
mfurseman 0:993d6b65e255 55
mfurseman 0:993d6b65e255 56 wait(1);
mfurseman 0:993d6b65e255 57 printConnectionInfo();
mfurseman 0:993d6b65e255 58
mfurseman 0:993d6b65e255 59 wifi.start(0);
mfurseman 0:993d6b65e255 60 printConnectionInfo();
mfurseman 0:993d6b65e255 61
mfurseman 0:993d6b65e255 62 wait_ms(750);
mfurseman 0:993d6b65e255 63
mfurseman 0:993d6b65e255 64 wifi._wlan.ioctl_set_connection_policy(0, 0, 1);
mfurseman 0:993d6b65e255 65 printConnectionInfo();
mfurseman 0:993d6b65e255 66
mfurseman 0:993d6b65e255 67 while(1) {
mfurseman 0:993d6b65e255 68 printConnectionInfo();
mfurseman 0:993d6b65e255 69 debug("test message\r\n");
mfurseman 0:993d6b65e255 70 led = !led;
mfurseman 0:993d6b65e255 71 wait(1);
mfurseman 0:993d6b65e255 72 }
mfurseman 0:993d6b65e255 73 }