Generic Pelion Device Management example for various Advantech modules.

This example is known to work great on the following platforms:

Example Functionality

This example showcases the following device functionality:

  • On timer button increment, simulate Pelion LWM2M button resource change

Use this example with Mbed CLI

1. Import the application into your desktop:

mbed import https://os.mbed.com/teams/Advantech/code/pelion-example-common
cd pelion-example-common

2. Download your developer certificate from pelion portal

3. Compile the program

mbed compile -t <toolchain> -m <TARGET_BOARD>

(supported toolchains : GCC_ARM / ARM / IAR)

4. Copy the binary file pelion-example-common.bin to your mbed device.

Committer:
chuanga
Date:
Tue Mar 12 13:48:39 2019 +0800
Revision:
0:43ff9e3bc244
copying sources from github repository

Who changed what in which revision?

UserRevisionLine numberNew contents of line
chuanga 0:43ff9e3bc244 1 /* SPWFSA04 Device
chuanga 0:43ff9e3bc244 2 * Copyright (c) 2015 ARM Limited
chuanga 0:43ff9e3bc244 3 *
chuanga 0:43ff9e3bc244 4 * Licensed under the Apache License, Version 2.0 (the "License");
chuanga 0:43ff9e3bc244 5 * you may not use this file except in compliance with the License.
chuanga 0:43ff9e3bc244 6 * You may obtain a copy of the License at
chuanga 0:43ff9e3bc244 7 *
chuanga 0:43ff9e3bc244 8 * http://www.apache.org/licenses/LICENSE-2.0
chuanga 0:43ff9e3bc244 9 *
chuanga 0:43ff9e3bc244 10 * Unless required by applicable law or agreed to in writing, software
chuanga 0:43ff9e3bc244 11 * distributed under the License is distributed on an "AS IS" BASIS,
chuanga 0:43ff9e3bc244 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
chuanga 0:43ff9e3bc244 13 * See the License for the specific language governing permissions and
chuanga 0:43ff9e3bc244 14 * limitations under the License.
chuanga 0:43ff9e3bc244 15 */
chuanga 0:43ff9e3bc244 16
chuanga 0:43ff9e3bc244 17 #include "SPWFSA04.h"
chuanga 0:43ff9e3bc244 18 #include "SpwfSAInterface.h"
chuanga 0:43ff9e3bc244 19 #include "mbed_debug.h"
chuanga 0:43ff9e3bc244 20
chuanga 0:43ff9e3bc244 21 #if MBED_CONF_IDW0XX1_EXPANSION_BOARD == IDW04A1
chuanga 0:43ff9e3bc244 22
chuanga 0:43ff9e3bc244 23 SPWFSA04::SPWFSA04(PinName tx, PinName rx,
chuanga 0:43ff9e3bc244 24 PinName rts, PinName cts,
chuanga 0:43ff9e3bc244 25 SpwfSAInterface &ifce, bool debug,
chuanga 0:43ff9e3bc244 26 PinName wakeup, PinName reset)
chuanga 0:43ff9e3bc244 27 : SPWFSAxx(tx, rx, rts, cts, ifce, debug, wakeup, reset) {
chuanga 0:43ff9e3bc244 28 }
chuanga 0:43ff9e3bc244 29
chuanga 0:43ff9e3bc244 30 bool SPWFSA04::open(const char *type, int* spwf_id, const char* addr, int port)
chuanga 0:43ff9e3bc244 31 {
chuanga 0:43ff9e3bc244 32 int socket_id;
chuanga 0:43ff9e3bc244 33 int value;
chuanga 0:43ff9e3bc244 34 int trials;
chuanga 0:43ff9e3bc244 35
chuanga 0:43ff9e3bc244 36 if(!_parser.send("AT+S.SOCKON=%s,%d,NULL,%s", addr, port, type))
chuanga 0:43ff9e3bc244 37 {
chuanga 0:43ff9e3bc244 38 debug_if(_dbg_on, "\r\nSPWF> `SPWFSA04::open`: error opening socket (%d)\r\n", __LINE__);
chuanga 0:43ff9e3bc244 39 return false;
chuanga 0:43ff9e3bc244 40 }
chuanga 0:43ff9e3bc244 41
chuanga 0:43ff9e3bc244 42 /* handle both response possibilities here before returning
chuanga 0:43ff9e3bc244 43 * otherwise module seems to remain in inconsistent state.
chuanga 0:43ff9e3bc244 44 */
chuanga 0:43ff9e3bc244 45
chuanga 0:43ff9e3bc244 46 if(!_parser.recv("AT-S.")) { // get prefix
chuanga 0:43ff9e3bc244 47 debug_if(_dbg_on, "\r\nSPWF> `SPWFSA04::open`: error opening socket (%d)\r\n", __LINE__);
chuanga 0:43ff9e3bc244 48 empty_rx_buffer();
chuanga 0:43ff9e3bc244 49 return false;
chuanga 0:43ff9e3bc244 50 }
chuanga 0:43ff9e3bc244 51
chuanga 0:43ff9e3bc244 52 /* wait for next character */
chuanga 0:43ff9e3bc244 53 trials = 0;
chuanga 0:43ff9e3bc244 54 while((value = _parser.getc()) < 0) {
chuanga 0:43ff9e3bc244 55 if(++trials >= SPWFXX_MAX_TRIALS) {
chuanga 0:43ff9e3bc244 56 debug("\r\nSPWF> `SPWFSA04::open`: error opening socket (%d)\r\n", __LINE__);
chuanga 0:43ff9e3bc244 57 empty_rx_buffer();
chuanga 0:43ff9e3bc244 58 return false;
chuanga 0:43ff9e3bc244 59 }
chuanga 0:43ff9e3bc244 60 }
chuanga 0:43ff9e3bc244 61
chuanga 0:43ff9e3bc244 62 switch(value) {
chuanga 0:43ff9e3bc244 63 case 'O':
chuanga 0:43ff9e3bc244 64 /* get next character */
chuanga 0:43ff9e3bc244 65 value = _parser.getc();
chuanga 0:43ff9e3bc244 66 if(value != 'n') {
chuanga 0:43ff9e3bc244 67 debug_if(_dbg_on, "\r\nSPWF> `SPWFSA04::open`: error opening socket (%d) (%d, \'%c\')\r\n",
chuanga 0:43ff9e3bc244 68 __LINE__, value, value);
chuanga 0:43ff9e3bc244 69 empty_rx_buffer();
chuanga 0:43ff9e3bc244 70 return false;
chuanga 0:43ff9e3bc244 71 }
chuanga 0:43ff9e3bc244 72
chuanga 0:43ff9e3bc244 73 /* get socket id */
chuanga 0:43ff9e3bc244 74 if(!(_parser.recv(":%*u.%*u.%*u.%*u:%d\n", &socket_id)
chuanga 0:43ff9e3bc244 75 && _recv_delim_lf()
chuanga 0:43ff9e3bc244 76 && _recv_ok())) {
chuanga 0:43ff9e3bc244 77 debug_if(_dbg_on, "\r\nSPWF> `SPWFSA04::open`: error opening socket (%d)\r\n", __LINE__);
chuanga 0:43ff9e3bc244 78 empty_rx_buffer();
chuanga 0:43ff9e3bc244 79 return false;
chuanga 0:43ff9e3bc244 80 }
chuanga 0:43ff9e3bc244 81 debug_if(_dbg_on, "AT^ AT-S.On:%s:%d\r\n", addr, socket_id);
chuanga 0:43ff9e3bc244 82
chuanga 0:43ff9e3bc244 83 *spwf_id = socket_id;
chuanga 0:43ff9e3bc244 84 return true;
chuanga 0:43ff9e3bc244 85 case 'E':
chuanga 0:43ff9e3bc244 86 int err_nr;
chuanga 0:43ff9e3bc244 87 if(_parser.recv("RROR:%d:%255[^\n]\n", &err_nr, _msg_buffer) && _recv_delim_lf()) {
chuanga 0:43ff9e3bc244 88 debug_if(_dbg_on, "AT^ AT-S.ERROR:%d:%s (%d)\r\n", err_nr, _msg_buffer, __LINE__);
chuanga 0:43ff9e3bc244 89 } else {
chuanga 0:43ff9e3bc244 90 debug_if(_dbg_on, "\r\nSPWF> `SPWFSA04::open`: error opening socket (%d)\r\n", __LINE__);
chuanga 0:43ff9e3bc244 91 empty_rx_buffer();
chuanga 0:43ff9e3bc244 92 }
chuanga 0:43ff9e3bc244 93 break;
chuanga 0:43ff9e3bc244 94 default:
chuanga 0:43ff9e3bc244 95 debug_if(_dbg_on, "\r\nSPWF> `SPWFSA04::open`: error opening socket (%d) (%d, \'%c\')\r\n",
chuanga 0:43ff9e3bc244 96 __LINE__, value, value);
chuanga 0:43ff9e3bc244 97 empty_rx_buffer();
chuanga 0:43ff9e3bc244 98 break;
chuanga 0:43ff9e3bc244 99 }
chuanga 0:43ff9e3bc244 100
chuanga 0:43ff9e3bc244 101 return false;
chuanga 0:43ff9e3bc244 102 }
chuanga 0:43ff9e3bc244 103
chuanga 0:43ff9e3bc244 104 int SPWFSA04::_read_in(char* buffer, int spwf_id, uint32_t amount) {
chuanga 0:43ff9e3bc244 105 int ret = -1;
chuanga 0:43ff9e3bc244 106 int received, cumulative;
chuanga 0:43ff9e3bc244 107
chuanga 0:43ff9e3bc244 108 MBED_ASSERT(buffer != NULL);
chuanga 0:43ff9e3bc244 109
chuanga 0:43ff9e3bc244 110 /* block asynchronous indications */
chuanga 0:43ff9e3bc244 111 if(!_winds_off()) {
chuanga 0:43ff9e3bc244 112 return -1;
chuanga 0:43ff9e3bc244 113 }
chuanga 0:43ff9e3bc244 114
chuanga 0:43ff9e3bc244 115 /* read in data */
chuanga 0:43ff9e3bc244 116 if(_parser.send("AT+S.SOCKR=%d,%d", spwf_id, (unsigned int)amount)) {
chuanga 0:43ff9e3bc244 117 if(!(_parser.recv("AT-S.Reading:%d:%d\n", &received, &cumulative) &&
chuanga 0:43ff9e3bc244 118 _recv_delim_lf())) {
chuanga 0:43ff9e3bc244 119 debug_if(_dbg_on, "\r\nSPWF> failed to receive AT-S.Reading (%s, %d)\r\n", __func__, __LINE__);
chuanga 0:43ff9e3bc244 120 empty_rx_buffer();
chuanga 0:43ff9e3bc244 121 } else {
chuanga 0:43ff9e3bc244 122 /* set high timeout */
chuanga 0:43ff9e3bc244 123 _parser.set_timeout(SPWF_READ_BIN_TIMEOUT);
chuanga 0:43ff9e3bc244 124 /* read in binary data */
chuanga 0:43ff9e3bc244 125 int read = _parser.read(buffer, amount);
chuanga 0:43ff9e3bc244 126 /* reset timeout value */
chuanga 0:43ff9e3bc244 127 _parser.set_timeout(_timeout);
chuanga 0:43ff9e3bc244 128 if(read > 0) {
chuanga 0:43ff9e3bc244 129 if(_recv_ok()) {
chuanga 0:43ff9e3bc244 130 ret = amount;
chuanga 0:43ff9e3bc244 131
chuanga 0:43ff9e3bc244 132 /* remove from pending sizes
chuanga 0:43ff9e3bc244 133 * (MUST be done before next async indications handling (e.g. `_winds_on()`)) */
chuanga 0:43ff9e3bc244 134 _remove_pending_pkt_size(spwf_id, amount);
chuanga 0:43ff9e3bc244 135 } else {
chuanga 0:43ff9e3bc244 136 debug_if(_dbg_on, "\r\nSPWF> failed to receive OK (%s, %d)\r\n", __func__, __LINE__);
chuanga 0:43ff9e3bc244 137 empty_rx_buffer();
chuanga 0:43ff9e3bc244 138 }
chuanga 0:43ff9e3bc244 139 } else {
chuanga 0:43ff9e3bc244 140 debug_if(_dbg_on, "\r\nSPWF> failed to read binary data (%s, %d)\r\n", __func__, __LINE__);
chuanga 0:43ff9e3bc244 141 empty_rx_buffer();
chuanga 0:43ff9e3bc244 142 }
chuanga 0:43ff9e3bc244 143 }
chuanga 0:43ff9e3bc244 144 } else {
chuanga 0:43ff9e3bc244 145 debug_if(_dbg_on, "%s(%d): failed to send SOCKR\r\n", __func__, __LINE__);
chuanga 0:43ff9e3bc244 146 }
chuanga 0:43ff9e3bc244 147
chuanga 0:43ff9e3bc244 148 debug_if(_dbg_on, "\r\nSPWF> %s():\t%d:%d\r\n", __func__, spwf_id, amount);
chuanga 0:43ff9e3bc244 149
chuanga 0:43ff9e3bc244 150 /* unblock asynchronous indications */
chuanga 0:43ff9e3bc244 151 _winds_on();
chuanga 0:43ff9e3bc244 152
chuanga 0:43ff9e3bc244 153 return ret;
chuanga 0:43ff9e3bc244 154 }
chuanga 0:43ff9e3bc244 155
chuanga 0:43ff9e3bc244 156 /* betzw - TODO: improve performance! */
chuanga 0:43ff9e3bc244 157 bool SPWFSA04::_recv_ap(nsapi_wifi_ap_t *ap)
chuanga 0:43ff9e3bc244 158 {
chuanga 0:43ff9e3bc244 159 bool ret;
chuanga 0:43ff9e3bc244 160 int curr;
chuanga 0:43ff9e3bc244 161 unsigned int channel;
chuanga 0:43ff9e3bc244 162 int trials;
chuanga 0:43ff9e3bc244 163
chuanga 0:43ff9e3bc244 164 ap->security = NSAPI_SECURITY_UNKNOWN;
chuanga 0:43ff9e3bc244 165
chuanga 0:43ff9e3bc244 166 /* determine list end */
chuanga 0:43ff9e3bc244 167 curr = _parser.getc();
chuanga 0:43ff9e3bc244 168 if(curr == 'A') { // assume end of list ("AT-S.OK")
chuanga 0:43ff9e3bc244 169 if(!(_parser.recv("T-S.OK\n") && _recv_delim_lf())) {
chuanga 0:43ff9e3bc244 170 empty_rx_buffer();
chuanga 0:43ff9e3bc244 171 }
chuanga 0:43ff9e3bc244 172 return false;
chuanga 0:43ff9e3bc244 173 }
chuanga 0:43ff9e3bc244 174
chuanga 0:43ff9e3bc244 175 /* run to 'horizontal tab' */
chuanga 0:43ff9e3bc244 176 trials = 0;
chuanga 0:43ff9e3bc244 177 while(_parser.getc() != '\x09') {
chuanga 0:43ff9e3bc244 178 if(trials++ > SPWFXX_MAX_TRIALS) {
chuanga 0:43ff9e3bc244 179 debug("\r\nSPWF> WARNING: might happen in case of RX buffer overflow! (%s, %d)\r\n", __func__, __LINE__);
chuanga 0:43ff9e3bc244 180 empty_rx_buffer();
chuanga 0:43ff9e3bc244 181 return false;
chuanga 0:43ff9e3bc244 182 }
chuanga 0:43ff9e3bc244 183 }
chuanga 0:43ff9e3bc244 184
chuanga 0:43ff9e3bc244 185 /* read in next line */
chuanga 0:43ff9e3bc244 186 ret = _parser.recv("%255[^\n]\n", _msg_buffer) && _recv_delim_lf();
chuanga 0:43ff9e3bc244 187
chuanga 0:43ff9e3bc244 188 /* parse line - first phase */
chuanga 0:43ff9e3bc244 189 if(ret) {
chuanga 0:43ff9e3bc244 190 int val = sscanf(_msg_buffer,
chuanga 0:43ff9e3bc244 191 " %*s %hhx:%hhx:%hhx:%hhx:%hhx:%hhx CHAN: %u RSSI: %hhd SSID: \'%*255[^\']\'",
chuanga 0:43ff9e3bc244 192 &ap->bssid[0], &ap->bssid[1], &ap->bssid[2], &ap->bssid[3], &ap->bssid[4], &ap->bssid[5],
chuanga 0:43ff9e3bc244 193 &channel, &ap->rssi);
chuanga 0:43ff9e3bc244 194 if(val < 8) {
chuanga 0:43ff9e3bc244 195 ret = false;
chuanga 0:43ff9e3bc244 196 }
chuanga 0:43ff9e3bc244 197 }
chuanga 0:43ff9e3bc244 198
chuanga 0:43ff9e3bc244 199 /* parse line - second phase */
chuanga 0:43ff9e3bc244 200 if(ret) { // ret == true
chuanga 0:43ff9e3bc244 201 char value;
chuanga 0:43ff9e3bc244 202 char *rest, *first, *last;
chuanga 0:43ff9e3bc244 203
chuanga 0:43ff9e3bc244 204 /* decide about position of `CAPS:` */
chuanga 0:43ff9e3bc244 205 first = strchr(_msg_buffer, '\'');
chuanga 0:43ff9e3bc244 206 if(first == NULL) {
chuanga 0:43ff9e3bc244 207 debug("\r\nSPWF> WARNING: might happen in case of RX buffer overflow! (%s, %d)\r\n", __func__, __LINE__);
chuanga 0:43ff9e3bc244 208 empty_rx_buffer();
chuanga 0:43ff9e3bc244 209 return false;
chuanga 0:43ff9e3bc244 210 }
chuanga 0:43ff9e3bc244 211 last = strrchr(_msg_buffer, '\'');
chuanga 0:43ff9e3bc244 212 if((last == NULL) || (last < (first+1))) {
chuanga 0:43ff9e3bc244 213 debug("\r\nSPWF> WARNING: might happen in case of RX buffer overflow! (%s, %d)\r\n", __func__, __LINE__);
chuanga 0:43ff9e3bc244 214 empty_rx_buffer();
chuanga 0:43ff9e3bc244 215 return false;
chuanga 0:43ff9e3bc244 216 }
chuanga 0:43ff9e3bc244 217 rest = strstr(last, "CAPS:");
chuanga 0:43ff9e3bc244 218 if(rest == NULL) {
chuanga 0:43ff9e3bc244 219 debug("\r\nSPWF> WARNING: might happen in case of RX buffer overflow! (%s, %d)\r\n", __func__, __LINE__);
chuanga 0:43ff9e3bc244 220 empty_rx_buffer();
chuanga 0:43ff9e3bc244 221 return false;
chuanga 0:43ff9e3bc244 222 }
chuanga 0:43ff9e3bc244 223
chuanga 0:43ff9e3bc244 224 /* substitute '\'' with '\0' */
chuanga 0:43ff9e3bc244 225 *last = '\0';
chuanga 0:43ff9e3bc244 226
chuanga 0:43ff9e3bc244 227 /* copy values */
chuanga 0:43ff9e3bc244 228 memcpy(&ap->ssid, first+1, sizeof(ap->ssid)-1);
chuanga 0:43ff9e3bc244 229 ap->ssid[sizeof(ap->ssid)-1] = '\0';
chuanga 0:43ff9e3bc244 230 ap->channel = channel;
chuanga 0:43ff9e3bc244 231
chuanga 0:43ff9e3bc244 232 /* skip `CAPS: 0421 ` */
chuanga 0:43ff9e3bc244 233 if(strlen(rest) < 11) {
chuanga 0:43ff9e3bc244 234 debug("\r\nSPWF> WARNING: might happen in case of RX buffer overflow! (%s, %d)\r\n", __func__, __LINE__);
chuanga 0:43ff9e3bc244 235 empty_rx_buffer();
chuanga 0:43ff9e3bc244 236 return false;
chuanga 0:43ff9e3bc244 237 }
chuanga 0:43ff9e3bc244 238 rest += 11;
chuanga 0:43ff9e3bc244 239
chuanga 0:43ff9e3bc244 240 /* get next character */
chuanga 0:43ff9e3bc244 241 value = *rest++;
chuanga 0:43ff9e3bc244 242 if(value != 'W') { // no security
chuanga 0:43ff9e3bc244 243 ap->security = NSAPI_SECURITY_NONE;
chuanga 0:43ff9e3bc244 244 return true;
chuanga 0:43ff9e3bc244 245 }
chuanga 0:43ff9e3bc244 246
chuanga 0:43ff9e3bc244 247 /* determine security */
chuanga 0:43ff9e3bc244 248 {
chuanga 0:43ff9e3bc244 249 char buffer[10];
chuanga 0:43ff9e3bc244 250
chuanga 0:43ff9e3bc244 251 if(!(sscanf(rest, "%s%*[\x20]", (char*)&buffer) > 0)) { // '\0x20' == <space>
chuanga 0:43ff9e3bc244 252 return true;
chuanga 0:43ff9e3bc244 253 } else if(strncmp("EP", buffer, 10) == 0) {
chuanga 0:43ff9e3bc244 254 ap->security = NSAPI_SECURITY_WEP;
chuanga 0:43ff9e3bc244 255 return true;
chuanga 0:43ff9e3bc244 256 } else if(strncmp("PA2", buffer, 10) == 0) {
chuanga 0:43ff9e3bc244 257 ap->security = NSAPI_SECURITY_WPA2;
chuanga 0:43ff9e3bc244 258 return true;
chuanga 0:43ff9e3bc244 259 } else if(strncmp("PA", buffer, 10) != 0) {
chuanga 0:43ff9e3bc244 260 return true;
chuanga 0:43ff9e3bc244 261 }
chuanga 0:43ff9e3bc244 262
chuanga 0:43ff9e3bc244 263 /* got a "WPA", check for "WPA2" */
chuanga 0:43ff9e3bc244 264 rest += strlen(buffer);
chuanga 0:43ff9e3bc244 265 value = *rest++;
chuanga 0:43ff9e3bc244 266 if(value == '\0') { // no further protocol
chuanga 0:43ff9e3bc244 267 ap->security = NSAPI_SECURITY_WPA;
chuanga 0:43ff9e3bc244 268 return true;
chuanga 0:43ff9e3bc244 269 } else { // assume "WPA2"
chuanga 0:43ff9e3bc244 270 ap->security = NSAPI_SECURITY_WPA_WPA2;
chuanga 0:43ff9e3bc244 271 return true;
chuanga 0:43ff9e3bc244 272 }
chuanga 0:43ff9e3bc244 273 }
chuanga 0:43ff9e3bc244 274 } else { // ret == false
chuanga 0:43ff9e3bc244 275 debug("\r\nSPWF> WARNING: might happen in case of RX buffer overflow! (%s, %d)\r\n", __func__, __LINE__);
chuanga 0:43ff9e3bc244 276 empty_rx_buffer();
chuanga 0:43ff9e3bc244 277 }
chuanga 0:43ff9e3bc244 278
chuanga 0:43ff9e3bc244 279 return ret;
chuanga 0:43ff9e3bc244 280 }
chuanga 0:43ff9e3bc244 281
chuanga 0:43ff9e3bc244 282 nsapi_size_or_error_t SPWFSA04::scan(WiFiAccessPoint *res, unsigned limit)
chuanga 0:43ff9e3bc244 283 {
chuanga 0:43ff9e3bc244 284 unsigned int cnt = 0, found;
chuanga 0:43ff9e3bc244 285 nsapi_wifi_ap_t ap;
chuanga 0:43ff9e3bc244 286
chuanga 0:43ff9e3bc244 287 if (!_parser.send("AT+S.SCAN=s,")) {
chuanga 0:43ff9e3bc244 288 return NSAPI_ERROR_DEVICE_ERROR;
chuanga 0:43ff9e3bc244 289 }
chuanga 0:43ff9e3bc244 290
chuanga 0:43ff9e3bc244 291 if(!(_parser.recv("AT-S.Parsing Networks:%u\n", &found) && _recv_delim_lf())) {
chuanga 0:43ff9e3bc244 292 debug_if(_dbg_on, "SPWF> error start network scanning\r\n");
chuanga 0:43ff9e3bc244 293 empty_rx_buffer();
chuanga 0:43ff9e3bc244 294 return NSAPI_ERROR_DEVICE_ERROR;
chuanga 0:43ff9e3bc244 295 }
chuanga 0:43ff9e3bc244 296
chuanga 0:43ff9e3bc244 297 debug_if(_dbg_on, "AT^ AT-S.Parsing Networks:%u\r\n", found);
chuanga 0:43ff9e3bc244 298
chuanga 0:43ff9e3bc244 299 if(found > 0) {
chuanga 0:43ff9e3bc244 300 while (_recv_ap(&ap)) {
chuanga 0:43ff9e3bc244 301 if (cnt < limit) {
chuanga 0:43ff9e3bc244 302 res[cnt] = WiFiAccessPoint(ap);
chuanga 0:43ff9e3bc244 303 }
chuanga 0:43ff9e3bc244 304
chuanga 0:43ff9e3bc244 305 if (!((limit != 0) && ((cnt + 1) > limit))) {
chuanga 0:43ff9e3bc244 306 cnt++;
chuanga 0:43ff9e3bc244 307 }
chuanga 0:43ff9e3bc244 308 }
chuanga 0:43ff9e3bc244 309 } else {
chuanga 0:43ff9e3bc244 310 if(!_recv_ok()) {
chuanga 0:43ff9e3bc244 311 empty_rx_buffer();
chuanga 0:43ff9e3bc244 312 }
chuanga 0:43ff9e3bc244 313 }
chuanga 0:43ff9e3bc244 314
chuanga 0:43ff9e3bc244 315 return cnt;
chuanga 0:43ff9e3bc244 316 }
chuanga 0:43ff9e3bc244 317
chuanga 0:43ff9e3bc244 318 #endif // MBED_CONF_IDW0XX1_EXPANSION_BOARD