ACKme
/
wiconnect-test-console
Test serial console demonstrating various API functions of WiConnect library.
tests/blocking/network/ScanNetworkTest.cpp
- Committer:
- dan_ackme
- Date:
- 2014-08-11
- Revision:
- 3:dddd476d5967
- Parent:
- 1:5137ec8f4c45
- Child:
- 12:3dd3a1be40c1
File content as of revision 3:dddd476d5967:
/* * Copyright 2014, ACKme Networks * All Rights Reserved. * * This is UNPUBLISHED PROPRIETARY SOURCE CODE of ACKme Networks; * the contents of this file may not be disclosed to third parties, copied * or duplicated in any form, in whole or in part, without the prior * written permission of ACKme Networks. */ #include "tests/Tests.h" #include "Wiconnect.h" static void printScanResults(const ScanResultList &scanResultList); /*************************************************************************************************/ WiconnectResult networkScanCommand(int argc, char **argv) { WiconnectResult result = WICONNECT_BAD_ARG; Wiconnect *wiconnect = Wiconnect::getInstance(); ScanResultList scanResultList(TEST_BUFFER_LENGTH, TEST_BUFFER); uint8_t channelList[16]; const char* ssid = NULL; uint8_t *channelListPtr = NULL; if(argc > 0) { if(strcmp(argv[0], "all") != 0) { char *ch_tok; char *chListPtr = argv[0]; uint8_t ch_count = 0; while((ch_tok = strtok(chListPtr, ",")) != NULL) { intmax_t x; if(!StringUtil::parseInt(ch_tok, &x, 1, 14)) { return WICONNECT_BAD_ARG; } channelList[ch_count++] = (uint8_t)x; chListPtr = NULL; } channelList[ch_count] = 0; channelListPtr = channelList; } --argc; ++argv; } if(argc > 0) { ssid = argv[0]; } if(!WICONNECT_FAILED(result, wiconnect->scan(scanResultList, channelListPtr, ssid))) { printScanResults(scanResultList); } return result; } /*************************************************************************************************/ static void printScanResults(const ScanResultList &scanResultList) { SsidStrBuffer ssidBuffer; MacAddressStrBuffer macBuffer; char rateBuffer[16]; int i = 1; LOG_INFO("Scan result count: %d", scanResultList.getCount()); for(const ScanResult *res = scanResultList.getListHead(); res != NULL; res = res->getNext(), ++i) { LOG_INFO("------------------------\r\n" "%d: %s\r\n" "\tChannel: %d\r\n" "\tSignal: %s\r\n" "\tSecurity: %s\r\n" "\tRate: %s\r\n" "\tBSSID: %s", i, Wiconnect::ssidToStr(res->getSsid(), ssidBuffer), res->getChannel(), Wiconnect::signalStrengthToStr(res->getSignalStrength()), Wiconnect::networkSecurityToStr(res->getSecurityType()), res->getRateStr(rateBuffer), Wiconnect::macAddressToStr(res->getMacAddress(), macBuffer)); } }