Host library for controlling a WiConnect enabled Wi-Fi module.
Dependents: wiconnect-ota_example wiconnect-web_setup_example wiconnect-test-console wiconnect-tcp_server_example ... more
Revision 35:15725177aa60, committed 2014-11-27
- Comitter:
- dan_ackme
- Date:
- Thu Nov 27 00:25:09 2014 -0800
- Parent:
- 34:2616445d0823
- Child:
- 36:a30cbf4bdb13
- Commit message:
- updated missing files from previous check-in
Changed in this revision
Wiconnect.cpp | Show annotated file Show diff for this revision Revisions of this file |
api/sdk.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/Wiconnect.cpp Wed Nov 26 23:46:00 2014 -0800 +++ b/Wiconnect.cpp Thu Nov 27 00:25:09 2014 -0800 @@ -80,7 +80,8 @@ internalBufferSize = internalBufferSize_;; nonBlocking = nonBlocking_; commandExecuting = false; - initialized = false; + initialized = false; + needUpdate = false; pinToGpioMapper = NULL; defaultTimeoutMs = WICONNECT_DEFAULT_TIMEOUT; @@ -174,6 +175,18 @@ if(result == WICONNECT_SUCCESS) { + if(WICONNECT_SUCCEEDED(result, getVersion())) + { + const uint32_t version = Wiconnect::wiconnectVersionToInt(this->internalBuffer); + if(version < WICONNECT_MINIMUM_VERSION) + { + needUpdate = true; + result = WICONNECT_FIRMWARE_OUTDATED; + } + } + } + if(result == WICONNECT_SUCCESS) + { sendCommand("set stream.auto_close 0"); } if(result == WICONNECT_SUCCESS && bringNetworkUp) @@ -207,6 +220,12 @@ bool Wiconnect::isInitialized() { return initialized; +} + +/*************************************************************************************************/ +bool Wiconnect::updateRequired() +{ + return needUpdate; } /*************************************************************************************************/ @@ -231,12 +250,12 @@ /*************************************************************************************************/ void Wiconnect::flush(int delayMs) { -// if(delayMs != 0) -// { -// serial.write("\r\n\r\n", 4, 0); -// } -// delayMs(delayMs); -// serial.flush(); + if(delayMs != 0) + { + serial.write("\r\n\r\n", 4, 0); + } + delayMs(delayMs); + serial.flush(); } /*************************************************************************************************/ @@ -329,7 +348,8 @@ "Not connected", // WICONNECT_NOT_CONNECTED "Underflow", // WICONNECT_UNDERFLOW "A monitor is not available", // WICONNECT_MONITOR_NOT_AVAILABLE - "Not opened for reading", // WICONNECT_NOT_OPENED_FOR_READING + "Not opened for reading", // WICONNECT_NOT_OPENED_FOR_READING + "WiFi firmware update required", // WICONNECT_FIRMWARE_OUTDATED }; if((int)wiconnectResult >= (int)WICONNECT_SUCCESS) @@ -342,7 +362,31 @@ return wiconnectErrorStrTable[wiconnectResult]; } } - + +/*************************************************************************************************/ +uint32_t Wiconnect::wiconnectVersionToInt(char *versionStr) +{ + char *idx = strchr(versionStr, ','); + if(idx == NULL) + { + return -1; + } + *idx = 0; + idx = versionStr; + while((idx = strchr(versionStr, '-')) != NULL) + { + versionStr = idx + 1; + } + + uint32_t ver; + + if(Wiconnect::fileVersionStrToInt(versionStr, &ver)) + { + return ver; + } + + return -1; +} /*************************************************************************************************/ void Wiconnect::setDebugLogger(LogFunc logFunc)
--- a/api/sdk.h Wed Nov 26 23:46:00 2014 -0800 +++ b/api/sdk.h Thu Nov 27 00:25:09 2014 -0800 @@ -38,6 +38,14 @@ namespace wiconnect { + +/** + * @ingroup api_core_macro + * @brief This is the minimum supported WiConnect version. If your + * WiFi module's firmware is out-dated, use the updateFirmware() + * API call to update your module's firmware. + */ +#define WICONNECT_MINIMUM_VERSION FILE_MAKE_VERSION(2, 0, 0, 11) /** * @ingroup api_core_macro