__interrupt void Timer_B (void) { // Check whether button is still pressed. If so, Smart Config // should be performed. if(!(switchIsPressed())) { // Button is still pressed, so Smart Config should be done runSmartConfig = 1; if(currentCC3000State() & CC3000_IP_ALLOC) { // Since accept and the server is blocking, // we will indicate in non-volatile FRAM that // Smart Config should be run at startup. SetFTCflag(); // Clear Smart Config profile stored flag until connection established. To use the default SSID for connection, press S1 and then the reset button. *SmartConfigProfilestored = 0xFF; restartMSP430(); } } // Restore Switch Interrupt RestoreSwitch(); StopDebounceTimer(); }
void CC3000_UsynchCallback(long lEventType, char * data, unsigned char length) { if (lEventType == HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE) { ulSmartConfigFinished = 1; } if (lEventType == HCI_EVNT_WLAN_UNSOL_INIT) { setCC3000MachineState(CC3000_INIT); } if (lEventType == HCI_EVNT_WLAN_UNSOL_CONNECT) { setCC3000MachineState(CC3000_ASSOC); } if (lEventType == HCI_EVNT_WLAN_UNSOL_DISCONNECT) { if(currentCC3000State() & CC3000_SERVER_INIT) { // We're waiting for a client to connect. However, // because we just received the disconnect event, we're stuck // because of the blocking nature of accept. We restart the MSP430 // so the CC3000 will wait to associate again. // terminalPrint("Restarting MSP430...\r\n"); restartMSP430(); } unsetCC3000MachineState(CC3000_ASSOC); } if (lEventType == HCI_EVNT_WLAN_UNSOL_DHCP) { setCC3000MachineState(CC3000_IP_ALLOC); } }
//***************************************************************************** // //! \brief returns a pointer to the RX buffer at the specific position //! //! \param pos is the location in the RX buffer to which pointer will point //! //! \return a pointer to the RX UART buffer // //***************************************************************************** void runUARTTerminal() { char validPos = 0; char * ftcPrefixptr; if(uartRXByte(bytesInUart()-1) != '\b' && uartRXByte(bytesInUart()-1) != 0x7F) { sendByte(uartRXByte(bytesInUart()-1)); } else { // Do backspace only if it doesn't erase '>' // Note that the backspace is itself in the buffer if(bytesInUart() > 1) { // Echo Backspace and remove latest byte sendByte(uartRXByte(bytesInUart()-1)); // Erase Backspace from buffer removeLastByteinBuf(); // Erase last character removeLastByteinBuf(); } else { // Erase Backspace from buffer removeLastByteinBuf(); } } switch(uartRXByte(bytesInUart()-1)) { case '\r': case '\n': // Erase \r or \n from buffer removeLastByteinBuf(); // Skip all non characters validPos = 0; while(uartRXByte(validPos) < 'A' && validPos <= bytesInUart() ) validPos++; // Process Command if(validPos <= bytesInUart()) { sendString("\n"); // help command if(checkCommand(uartRXBytePointer(validPos),"help") == 1) { printCommandList(); } else if(checkCommand(uartRXBytePointer(validPos),"assoc") == 1) { // Disable RX interrupt so it does not interfere // with GUI's command UCA1IE &= ~UCRXIE; validPos += strlen("assoc"); while(uartRXByte(validPos) < 'A' && validPos <= bytesInUart()) validPos++; *ptrSSIDInd = FLASH_FLAG_SET; memset((char *)ptrSSID, 0, MAX_SSID_LEN); memcpy(ptrSSID,uartRXBytePointer(validPos),MAX_SSID_LEN); sendString("OK\r\n"); // If server is running, accept is blocking us. We can // therefore just restart the MSP430. Since the SSID indicator // has been set, at startup it will attempt to associate to the // AP requested by the user. if(currentCC3000State() & CC3000_SERVER_INIT) { terminalPrint("Restarting MSP430...\r\n"); restartMSP430(); } else { // Associate command ConnectUsingSSID((char *)ptrSSID, (unsigned char *)ptrPASSPHRASE, (long)ptrSECURITY); //ConnectUsingSSID((char *)ptrSSID, (unsigned char *)ptrPASSPHRASE, (unsigned long)ptrSECURITY); } UCA1IE |= UCRXIE; // Enable RX interrupt } else if(checkCommand(uartRXBytePointer(validPos),"stat") == 1) { #ifdef SENSOR_APP_VERSION terminalPrint("Sensor App Version: "); terminalPrint(SENSOR_APP_VERSION); terminalPrint("\r\n"); #endif //#ifndef CC3000_TINY_DRIVER // printConnectionInfo(getCC3000Info()); //#endif } else if(checkCommand(uartRXBytePointer(validPos),"prfx") == 1) { // parameter sent with prfx should be 3 letters // that are the prefix. If they're not, we issue an error validPos += strlen("prfx"); while(uartRXByte(validPos) < 'A' && validPos <= bytesInUart() ) validPos++; if(validPos <= bytesInUart()) { // Verify letters if(isUppercaseChar(uartRXByte(validPos)) && isUppercaseChar(uartRXByte(validPos+1)) && isUppercaseChar(uartRXByte(validPos+2))) { // Wait for 3 characters from UART ftcPrefixptr = (char *)(&aucCC3000_prefix[0]); *ftcPrefixptr = uartRXByte(validPos); ftcPrefixptr = (char *)(&aucCC3000_prefix[1]); *ftcPrefixptr = uartRXByte(validPos+1); ftcPrefixptr = (char *)(&aucCC3000_prefix[2]); *ftcPrefixptr = uartRXByte(validPos+2); // Send new prefix to CC3000 wlan_smart_config_set_prefix((char *)aucCC3000_prefix); char prfStr[4]; prfStr[0] = aucCC3000_prefix[0]; prfStr[1] = aucCC3000_prefix[1]; prfStr[2] = aucCC3000_prefix[2]; prfStr[3] = '\0'; //turnLedOff(CC3000_UNUSED1_IND); sendString("\r\nSmart Config Prefix changed to: "); sendString (prfStr); sendString("\r\n"); } else { sendString("Prefix Error"); } } else { sendString("Prefix Error"); } } else { sendString("Invalid or incomplete command. Type help for command list"); } } // Send '>' sendString("\r\n> "); resetUARTBuffer(); break; } }