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
WiconnectSettings.cpp
00001 /** 00002 * ACKme WiConnect Host Library is licensed under the BSD licence: 00003 * 00004 * Copyright (c)2014 ACKme Networks. 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without modification, 00008 * are permitted provided that the following conditions are met: 00009 * 00010 * 1. Redistributions of source code must retain the above copyright notice, 00011 * this list of conditions and the following disclaimer. 00012 * 2. Redistributions in binary form must reproduce the above copyright notice, 00013 * this list of conditions and the following disclaimer in the documentation 00014 * and/or other materials provided with the distribution. 00015 * 3. The name of the author may not be used to endorse or promote products 00016 * derived from this software without specific prior written permission. 00017 * 00018 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS AND ANY EXPRESS OR IMPLIED 00019 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00020 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 00021 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00022 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00023 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00024 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00025 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00026 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 00027 * OF SUCH DAMAGE. 00028 */ 00029 00030 #include "Wiconnect.h" 00031 #include "internal/common.h" 00032 00033 00034 00035 /*************************************************************************************************/ 00036 WiconnectResult Wiconnect::setSetting(const char *settingStr, uint32_t value) 00037 { 00038 WiconnectResult result; 00039 00040 _CHECK_OTHER_COMMAND_EXECUTING(); 00041 00042 result = sendCommand("set %s %u", settingStr, value); 00043 00044 _CHECK_CLEANUP_COMMAND(); 00045 00046 return result; 00047 } 00048 00049 /*************************************************************************************************/ 00050 WiconnectResult Wiconnect::setSetting(const char *settingStr, const char *value) 00051 { 00052 WiconnectResult result; 00053 00054 _CHECK_OTHER_COMMAND_EXECUTING(); 00055 00056 result = sendCommand("set %s %s", settingStr, value); 00057 00058 _CHECK_CLEANUP_COMMAND(); 00059 00060 return result; 00061 } 00062 00063 /*************************************************************************************************/ 00064 WiconnectResult Wiconnect::getSetting(const char *settingStr, uint32_t *valuePtr) 00065 { 00066 WiconnectResult result = WICONNECT_ERROR; 00067 00068 00069 _CHECK_OTHER_COMMAND_EXECUTING(); 00070 00071 if(WICONNECT_SUCCEEDED(result, sendCommand("get %s", settingStr))) 00072 { 00073 result = responseToUint32(valuePtr); 00074 } 00075 00076 _CHECK_CLEANUP_COMMAND(); 00077 00078 return result; 00079 } 00080 00081 /*************************************************************************************************/ 00082 WiconnectResult Wiconnect::getSetting(const char *settingStr, char **valuePtr) 00083 { 00084 WiconnectResult result = WICONNECT_ERROR; 00085 00086 00087 _CHECK_OTHER_COMMAND_EXECUTING(); 00088 00089 if(WICONNECT_SUCCEEDED(result, sendCommand("get %s", settingStr))) 00090 { 00091 *valuePtr = internalBuffer; 00092 } 00093 00094 _CHECK_CLEANUP_COMMAND(); 00095 00096 return result; 00097 } 00098 00099 /*************************************************************************************************/ 00100 WiconnectResult Wiconnect::getSetting(const char *settingStr, char *valueBuffer, uint16_t valueBufferLen) 00101 { 00102 WiconnectResult result = WICONNECT_ERROR; 00103 00104 00105 _CHECK_OTHER_COMMAND_EXECUTING(); 00106 00107 result = sendCommand(valueBuffer, valueBufferLen, "get %s", settingStr); 00108 00109 _CHECK_CLEANUP_COMMAND(); 00110 00111 return result; 00112 } 00113 00114 /*************************************************************************************************/ 00115 WiconnectResult Wiconnect::saveSettings() 00116 { 00117 WiconnectResult result = WICONNECT_ERROR; 00118 00119 00120 _CHECK_OTHER_COMMAND_EXECUTING(); 00121 00122 result = sendCommand("save"); 00123 00124 _CHECK_CLEANUP_COMMAND(); 00125 00126 return result; 00127 }
Generated on Tue Jul 12 2022 17:35:59 by 1.7.2