From: Heejin Kim Date: Sat, 23 Sep 2017 00:25:56 +0000 (+0900) Subject: apps/easysetup: Remove unused example X-Git-Tag: 1.1_Public_Release~136^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=51dcfc1eaebccdefd2600905c1a3d9215f9da366;p=rtos%2Ftinyara.git apps/easysetup: Remove unused example Instead of the 'easysetup' example, you can use a 'st_things' example for easysetup. --- diff --git a/apps/examples/easysetup/Kconfig b/apps/examples/easysetup/Kconfig deleted file mode 100644 index e119fb5..0000000 --- a/apps/examples/easysetup/Kconfig +++ /dev/null @@ -1,21 +0,0 @@ -# -# For a description of the syntax of this configuration file, -# see misc/tools/kconfig-language.txt. -# - -config EXAMPLES_EASYSETUP - bool "Easysetup example" - depends on NETUTILS_WEBSERVER - depends on NETUTILS_JSON - depends on NETUTILS_WIFI - depends on NET_SECURITY_TLS - default n - -if EXAMPLES_EASYSETUP - -config EXAMPLES_EASYSETUP_PROGNAME - string "Program name" - default "easetup example" - depends on BUILD_KERNEL - -endif # EXAMPLES_EASYSETUP diff --git a/apps/examples/easysetup/Make.defs b/apps/examples/easysetup/Make.defs deleted file mode 100644 index 62850c6..0000000 --- a/apps/examples/easysetup/Make.defs +++ /dev/null @@ -1,21 +0,0 @@ -########################################################################### -# -# Copyright 2017 Samsung Electronics All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, -# either express or implied. See the License for the specific -# language governing permissions and limitations under the License. -# -########################################################################### - -ifeq ($(CONFIG_EXAMPLES_EASYSETUP),y) -CONFIGURED_APPS += examples/easysetup -endif diff --git a/apps/examples/easysetup/Makefile b/apps/examples/easysetup/Makefile deleted file mode 100644 index fa41460..0000000 --- a/apps/examples/easysetup/Makefile +++ /dev/null @@ -1,141 +0,0 @@ -############################################################################ -# apps/examples/hello/Makefile -# -# Copyright (C) 2008, 2010-2013 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name NuttX nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - --include $(TOPDIR)/.config --include $(TOPDIR)/Make.defs -include $(APPDIR)/Make.defs - -# built-in application info - -APPNAME = easysetup -FUNCNAME = easysetup_main -THREADEXEC = TASH_EXECMD_ASYNC - -# easysetup example - -ASRCS = -CSRCS = wifi_api.c -MAINSRC = easysetup_main.c - -AOBJS = $(ASRCS:.S=$(OBJEXT)) -COBJS = $(CSRCS:.c=$(OBJEXT)) -MAINOBJ = $(MAINSRC:.c=$(OBJEXT)) - -SRCS = $(ASRCS) $(CSRCS) $(MAINSRC) -OBJS = $(AOBJS) $(COBJS) - -ifneq ($(CONFIG_BUILD_KERNEL),y) - OBJS += $(MAINOBJ) -endif - -ifeq ($(CONFIG_WINDOWS_NATIVE),y) - BIN = ..\..\libapps$(LIBEXT) -else -ifeq ($(WINTOOL),y) - BIN = ..\\..\\libapps$(LIBEXT) -else - BIN = ../../libapps$(LIBEXT) -endif -endif - -ifeq ($(WINTOOL),y) - INSTALL_DIR = "${shell cygpath -w $(BIN_DIR)}" -else - INSTALL_DIR = $(BIN_DIR) -endif - -CONFIG_EXAMPLES_EASYSETUP_PROGNAME ?= easysetup$(EXEEXT) -PROGNAME = $(CONFIG_EXAMPLES_EASYSETUP_PROGNAME) - - -ROOTDEPPATH = --dep-path . - -# Common build - -VPATH = - -all: .built -.PHONY: clean depend distclean preconfig - -$(AOBJS): %$(OBJEXT): %.S - $(call ASSEMBLE, $<, $@) - -$(COBJS) $(MAINOBJ): %$(OBJEXT): %.c - $(call COMPILE, $<, $@) - -.built: $(OBJS) - $(call ARCHIVE, $(BIN), $(OBJS)) - @touch .built - -ifeq ($(CONFIG_BUILD_KERNEL),y) -$(BIN_DIR)$(DELIM)$(PROGNAME): $(OBJS) $(MAINOBJ) - @echo "LD: $(PROGNAME)" - $(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $(INSTALL_DIR)$(DELIM)$(PROGNAME) $(ARCHCRT0OBJ) $(MAINOBJ) $(LDLIBS) - $(Q) $(NM) -u $(INSTALL_DIR)$(DELIM)$(PROGNAME) - -install: $(BIN_DIR)$(DELIM)$(PROGNAME) - -else -install: - -endif - -ifeq ($(CONFIG_BUILTIN_APPS)$(CONFIG_EXAMPLES_EASYSETUP),yy) -$(BUILTIN_REGISTRY)$(DELIM)$(FUNCNAME).bdat: $(DEPCONFIG) Makefile - $(Q) $(call REGISTER,$(APPNAME),$(FUNCNAME),$(THREADEXEC),$(PRIORITY),$(STACKSIZE)) - -context: $(BUILTIN_REGISTRY)$(DELIM)$(FUNCNAME).bdat - -else -context: - -endif - -.depend: Makefile $(SRCS) - @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep - @touch $@ - -depend: .depend - -clean: - $(call DELFILE, .built) - $(call CLEAN) - -distclean: clean - $(call DELFILE, Make.dep) - $(call DELFILE, .depend) - --include Make.dep -preconfig: diff --git a/apps/examples/easysetup/controller_cert/test_ca_cert.pem b/apps/examples/easysetup/controller_cert/test_ca_cert.pem deleted file mode 100755 index 24e1252..0000000 --- a/apps/examples/easysetup/controller_cert/test_ca_cert.pem +++ /dev/null @@ -1,22 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDkDCCAngCCQDNBYyeTQ0JVjANBgkqhkiG9w0BAQsFADCBijELMAkGA1UEBhMC -S1IxETAPBgNVBAgMCEt5ZW9uZ0dpMQ4wDAYDVQQHDAVTdXdvbjEQMA4GA1UECgwH -U2Ftc3VuZzELMAkGA1UECwwCREExETAPBgNVBAMMCEFSVElLMDUxMSYwJAYJKoZI -hvcNAQkBFhdoaDA2MTkuY2hvaUBzYW1zdW5nLmNvbTAeFw0xNjA5MDQwNjMyMDJa -Fw0xNzA5MDQwNjMyMDJaMIGKMQswCQYDVQQGEwJLUjERMA8GA1UECAwIS3llb25n -R2kxDjAMBgNVBAcMBVN1d29uMRAwDgYDVQQKDAdTYW1zdW5nMQswCQYDVQQLDAJE -QTERMA8GA1UEAwwIQVJUSUswNTExJjAkBgkqhkiG9w0BCQEWF2hoMDYxOS5jaG9p -QHNhbXN1bmcuY29tMIIBIDANBgkqhkiG9w0BAQEFAAOCAQ0AMIIBCAKCAQEApQic -nEB1U7LV+EjNhe8Nw7kiqPtkigAC8+lad0kJ+phZ9yRZ/1+/Qp+Ngod8LcR1Cath -szXskEhFkodqLynwYrb7nDLSsFDU10oiMgHxO+PyGt76IBzpGEc8OG9Ha4O82ARa -glZQ/8kuHt5auDnsBbqYrhznzYMzVbbrrJnG4lirh0hJYJLr8/Rtvh1u1N2aeyz3 -XAmO27N7DZCtLXFtQgfd2TbZ4uvX3mGkgQUru9mgr3V6hf0cFTXs8iJ/IVR8UE37 -pkZTzZdvnLqoWLdlM/lgtzmsaDF7tlj7NyHf9gil7NVAUPAunY/HG5P1tcnookJi -lL+NwiaLgbPcozoRjwIBAzANBgkqhkiG9w0BAQsFAAOCAQEAEAF0GbZf7YZlztVU -mA2yGMOdt/gc0sCBJJZefxXgCI5poNC0H0CDwkqwZS9Tpe+rA1vwE9Be69INNP1d -/tX0Z7Xqf22CWGoDeQdiHl4OfumY4cLHrz1BwosHLgCuuIUbjTXtmjxA8T5VFfNO -P/Y8cDfLCbbvzhOq/qRvNayAk7oNsAzPZOZR3X4967fuYdUk1Y9qgW3FF4asv8KR -lCTiKkSnEOmQSYLYGj1xtgxEJbSWNmld+Bujxso8ZkQnxk/gKjn3qv4Wcpuin+3n -fwWb0zmYmGCWGt3ZgqtzrGJQqn2bEUhFHzsPzINDdLlyI/Y3meOoCc+uGVxegT7d -ODC9Ww== ------END CERTIFICATE----- diff --git a/apps/examples/easysetup/controller_cert/test_client_cert.pem b/apps/examples/easysetup/controller_cert/test_client_cert.pem deleted file mode 100755 index c934c03..0000000 --- a/apps/examples/easysetup/controller_cert/test_client_cert.pem +++ /dev/null @@ -1,21 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDijCCAnKgAwIBAgIBATANBgkqhkiG9w0BAQsFADCBijELMAkGA1UEBhMCS1Ix -ETAPBgNVBAgTCEt5ZW9uZ0dpMQ4wDAYDVQQHEwVTdXdvbjEQMA4GA1UEChMHU2Ft -c3VuZzELMAkGA1UECxMCREExETAPBgNVBAMTCEFSVElLMDUxMSYwJAYJKoZIhvcN -AQkBFhdoaDA2MTkuY2hvaUBzYW1zdW5nLmNvbTAeFw0xNjAxMDEwMDAwMDBaFw0z -NjEyMzEyMzU5NTlaMDkxFTATBgNVBAMTDEFSVElLMDUxX2RldjETMBEGA1UEChMK -U2Ftc3VuZyBEQTELMAkGA1UEBhMCS1IwggEgMA0GCSqGSIb3DQEBAQUAA4IBDQAw -ggEIAoIBAQCiZCHPHNtJbEQB+NWLjSD+KkZNKfSCPKQpfWvcxATWD/NrqLGtK6Gl -rfuaunJuTnGTVI2QAjSAHYyDyYSjz5+A6U9b9ikX9n9aeUcMLM+YiGoxTgosjozl -pZ/Xj9DBBBrpVKE2TpJeQZwHyEisnHzLoIpRUk9HoshIvM1VhST/+ljmdWEUGoJO -a0Bjnu+9cIieyFmJFgxOcewtpAuzIMoEWzf2XICNauQmleTVNc3TkGdI7xSOxswW -23qW1r8B71+N7jXRZqMmll5zOx72csl4yN2BIQ8N3D9jepLxMVPmNNdwsB0vl6tE -8XBYDsqrJiM5btv1WhVKCQB85YJ4uPDRAgEDo00wSzAJBgNVHRMEAjAAMB0GA1Ud -DgQWBBQugjgQS6yL1j8vCRd+pG3A/paiwDAfBgNVHSMEGDAWgBRm83GkU3388NoR -Y3hQMpXH8VpoZzANBgkqhkiG9w0BAQsFAAOCAQEAiDnO5R/NlRZd+XpHHO/oYBee -XPIP4EZFOTt/N0Kcu36byaGhY9BPDoiy/S9wIRxOPIfFsehJTDC4qAxUHQneW14o -xzeZIM1OFCiV/9xWkQLdZwG6nfJZgOmb0KGMsZWyBxFr7v9MwVtuIVr9O4om57ej -fMJLz64j/mj+jRK4acqZVisZfQv0nZUANOQZWPjjlvGeMnWjKqRJ0Cc0rp3u3DiL -yuNE7DJI3+xzloQhcjkv8H7oQAUVPhVxCGGumjly+PQiiclVqOQn6tQcr8CqSvUK -z14Rpa7jNeIOD10MyVkvJQ28QH4w0kSvEhqN28ISIY1E2cvvHXuvGLfNulm69g== ------END CERTIFICATE----- \ No newline at end of file diff --git a/apps/examples/easysetup/controller_cert/test_client_key.pem b/apps/examples/easysetup/controller_cert/test_client_key.pem deleted file mode 100755 index 4139ef5..0000000 --- a/apps/examples/easysetup/controller_cert/test_client_key.pem +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEowIBAQKCAQEAomQhzxzbSWxEAfjVi40g/ipGTSn0gjykKX1r3MQE1g/za6ix -rSuhpa37mrpybk5xk1SNkAI0gB2Mg8mEo8+fgOlPW/YpF/Z/WnlHDCzPmIhqMU4K -LI6M5aWf14/QwQQa6VShNk6SXkGcB8hIrJx8y6CKUVJPR6LISLzNVYUk//pY5nVh -FBqCTmtAY57vvXCInshZiRYMTnHsLaQLsyDKBFs39lyAjWrkJpXk1TXN05BnSO8U -jsbMFtt6lta/Ae9fje410WajJpZeczse9nLJeMjdgSEPDdw/Y3qS8TFT5jTXcLAd -L5erRPFwWA7KqyYjOW7b9VoVSgkAfOWCeLjw0QIBAwKCAQBsQsE0veeGSC1WpeOy -XhX+xtmIxqMBfcLGU5092AM5X/edGyEeHRZuc/0R0aGe3vZiOF5gAXhVaQhX263C -impV8N+SpBtlTv+Rpi9dczUQWvF2NAbIXwiZGRU6X+CArWdGOGt5ibbpgRKv2tsd -vaiHwFw2Nt+FFzAwfd45A23/+ytdQpBCA1X20cPdLOWUg/c1uAXN9aXmO9HSSeK+ -WHtsx9X3NuQApNbp9mIZNlj7tBcOl5q6qn29kPUsOeuGJtXqvc/0j1qmdt6ncC8a -Hv9AOU3An6oKmQhol5axtzbhRtXW0NGPI1IZuP3RR/SyDZm3etJXAd42aVOftlag -YYlLAoGBAM+ssDLcoRq3xuO43gpwS/pZogtrK+Zc1uTIyeXot6WjlMtVdE7+34KX -0DbuAAOOhiihENX5kQt6P04R3EQ5vsJMEK92pOL20lpZabtCtGVQyNgYRFUmZo3U -bp1C56xEOktNcUaUBRmbj9wlBu8A0tV46PCe3S/2qFTftzTjXclVAoGBAMgt4VXU -dGakabbe/YzuXpt0kkVo+a0YQUypa1Gs5Gs9mquuFduNlB8v1BrBZETLfBwR+tZ9 -NgQAQrzCo5l+9lxhwM5r6rg2EbYeqR0Mj+VHqhDH7TrXkCTyKJOjttVQEEthBZxE -3ZaCzBd5G+yfPuctTa/T+hgBwq4tnMukyNmNAoGBAIpzICHoa2clL0J7PrGgMqbm -bAecx+7oj0MwhplFz8PCYzI4+DSp6lcP4CSeqq0JrsXAteP7tgem1N62ktgmfywy -tcpPGJdPNubmRnzXIu412zq62DjERF6NnxOB78gtfDIzoNm4A2ZntT1uBJ9V4eOl -8KBp6MqkcDiVJM3s6TDjAoGBAIVz646Nou8YRnnp/l30PxJNttjwpnNlgN3GR4vI -mEd+Zx0euT0JDWof4ryA7YMyUr1hUeRTeVgALH3XF7up+ZLr1d7ynHrOtnlpxhNd -tUOFHAsv83yPtW32xbfCeeOKtYeWA72DPmRXMrpQvUhqKe9ziR/iprqr1x7JEzJt -2zuzAoGBAKnko1QDL8KNoh6u4PvpuuC1tmkN447rCimdFcKKdpZOd+oaC+ibXfe9 -hvvkazwyxnr+91/sLiT6aKzypTJN2NNo+t7MNzioO07rriXKt8CAcFjqw1KqJDwk -F0c3cPlFgyDOkuJrWP2ikFtoTH4am82U70vojZv4OG4eEqWv0/C9 ------END RSA PRIVATE KEY----- - diff --git a/apps/examples/easysetup/easysetup_main.c b/apps/examples/easysetup/easysetup_main.c deleted file mode 100644 index 6e8b128..0000000 --- a/apps/examples/easysetup/easysetup_main.c +++ /dev/null @@ -1,564 +0,0 @@ -/**************************************************************************** - * examples/eaysetup/easysetup.c - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "wifi_api.h" - -/**************************************************************************** - * Definitions - ****************************************************************************/ -#define WPA_MAX_SSID_LEN (4 * 32 + 1) -#define MODE_STRING_MAX 100 - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ -struct ap_info_t { - char ssid[32]; - char security[32]; - char pwd[64]; -}; - -const char *soft_ap_ssid = "IoT_SoftAP10"; -const char *soft_ap_passphase = "12345678"; -const char *soft_ap_security = "wpa2_aes"; -static int soft_ap_channel = 1; -static struct ap_info_t ap_info; -sem_t get_netinfo; -sem_t finish_scan; -sem_t get_ctrl; -static int g_stop_easysetup = 0; -const char *root_uri = "/"; -const char *network_uri = "/network"; -const char *control_uri = "/control"; -static struct http_server_t *https_server = NULL; -static const char g_httpcontype[] = "Content-type"; -static const char g_httpconhtml[] = "text/html"; -static const char g_httpcontsize[] = "Content-Length"; -static const char g_httpconnect[] = "Connection"; -static const char g_httpcnlost[] = "close"; -static struct timeval rt; - -#ifdef CONFIG_HW_RSA -#include "mbedtls/sss_key.h" -#include "mbedtls/see_api.h" - -#define EASY_CA_KEY_INDEX 1 -#define EASY_DEV_KEY_INDEX 2 -#define EASY_CA_CERT_INDEX 1 -#define EASY_DEV_CERT_INDEX 2 - -#else -static const char ca_crt_rsa[] = - "-----BEGIN CERTIFICATE-----\r\n" - "MIIDhzCCAm+gAwIBAgIBADANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER\r\n" - "MA8GA1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwHhcN\r\n" - "MTEwMjEyMTQ0NDAwWhcNMjEwMjEyMTQ0NDAwWjA7MQswCQYDVQQGEwJOTDERMA8G\r\n" - "A1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwggEiMA0G\r\n" - "CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDA3zf8F7vglp0/ht6WMn1EpRagzSHx\r\n" - "mdTs6st8GFgIlKXsm8WL3xoemTiZhx57wI053zhdcHgH057Zk+i5clHFzqMwUqny\r\n" - "50BwFMtEonILwuVA+T7lpg6z+exKY8C4KQB0nFc7qKUEkHHxvYPZP9al4jwqj+8n\r\n" - "YMPGn8u67GB9t+aEMr5P+1gmIgNb1LTV+/Xjli5wwOQuvfwu7uJBVcA0Ln0kcmnL\r\n" - "R7EUQIN9Z/SG9jGr8XmksrUuEvmEF/Bibyc+E1ixVA0hmnM3oTDPb5Lc9un8rNsu\r\n" - "KNF+AksjoBXyOGVkCeoMbo4bF6BxyLObyavpw/LPh5aPgAIynplYb6LVAgMBAAGj\r\n" - "gZUwgZIwDAYDVR0TBAUwAwEB/zAdBgNVHQ4EFgQUtFrkpbPe0lL2udWmlQ/rPrzH\r\n" - "/f8wYwYDVR0jBFwwWoAUtFrkpbPe0lL2udWmlQ/rPrzH/f+hP6Q9MDsxCzAJBgNV\r\n" - "BAYTAk5MMREwDwYDVQQKEwhQb2xhclNTTDEZMBcGA1UEAxMQUG9sYXJTU0wgVGVz\r\n" - "dCBDQYIBADANBgkqhkiG9w0BAQUFAAOCAQEAuP1U2ABUkIslsCfdlc2i94QHHYeJ\r\n" - "SsR4EdgHtdciUI5I62J6Mom+Y0dT/7a+8S6MVMCZP6C5NyNyXw1GWY/YR82XTJ8H\r\n" - "DBJiCTok5DbZ6SzaONBzdWHXwWwmi5vg1dxn7YxrM9d0IjxM27WNKs4sDQhZBQkF\r\n" - "pjmfs2cb4oPl4Y9T9meTx/lvdkRYEug61Jfn6cA+qHpyPYdTH+UshITnmp5/Ztkf\r\n" - "m/UTSLBNFNHesiTZeH31NcxYGdHSme9Nc/gfidRa0FLOCfWxRlFqAI47zG9jAQCZ\r\n" - "7Z2mCGDNMhjQc+BYcdnl0lPXjdDK6V0qCg1dVewhUBcW5gZKzV7e9+DpVA==\r\n" - "-----END CERTIFICATE-----\r\n"; - -static const char srv_crt_rsa[] = - "-----BEGIN CERTIFICATE-----\r\n" - "MIIDNzCCAh+gAwIBAgIBAjANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER\r\n" - "MA8GA1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwHhcN\r\n" - "MTEwMjEyMTQ0NDA2WhcNMjEwMjEyMTQ0NDA2WjA0MQswCQYDVQQGEwJOTDERMA8G\r\n" - "A1UEChMIUG9sYXJTU0wxEjAQBgNVBAMTCWxvY2FsaG9zdDCCASIwDQYJKoZIhvcN\r\n" - "AQEBBQADggEPADCCAQoCggEBAMFNo93nzR3RBNdJcriZrA545Do8Ss86ExbQWuTN\r\n" - "owCIp+4ea5anUrSQ7y1yej4kmvy2NKwk9XfgJmSMnLAofaHa6ozmyRyWvP7BBFKz\r\n" - "NtSj+uGxdtiQwWG0ZlI2oiZTqqt0Xgd9GYLbKtgfoNkNHC1JZvdbJXNG6AuKT2kM\r\n" - "tQCQ4dqCEGZ9rlQri2V5kaHiYcPNQEkI7mgM8YuG0ka/0LiqEQMef1aoGh5EGA8P\r\n" - "hYvai0Re4hjGYi/HZo36Xdh98yeJKQHFkA4/J/EwyEoO79bex8cna8cFPXrEAjya\r\n" - "HT4P6DSYW8tzS1KW2BGiLICIaTla0w+w3lkvEcf36hIBMJcCAwEAAaNNMEswCQYD\r\n" - "VR0TBAIwADAdBgNVHQ4EFgQUpQXoZLjc32APUBJNYKhkr02LQ5MwHwYDVR0jBBgw\r\n" - "FoAUtFrkpbPe0lL2udWmlQ/rPrzH/f8wDQYJKoZIhvcNAQEFBQADggEBAJxnXClY\r\n" - "oHkbp70cqBrsGXLybA74czbO5RdLEgFs7rHVS9r+c293luS/KdliLScZqAzYVylw\r\n" - "UfRWvKMoWhHYKp3dEIS4xTXk6/5zXxhv9Rw8SGc8qn6vITHk1S1mPevtekgasY5Y\r\n" - "iWQuM3h4YVlRH3HHEMAD1TnAexfXHHDFQGe+Bd1iAbz1/sH9H8l4StwX6egvTK3M\r\n" - "wXRwkKkvjKaEDA9ATbZx0mI8LGsxSuCqe9r9dyjmttd47J1p1Rulz3CLzaRcVIuS\r\n" - "RRQfaD8neM9c1S/iJ/amTVqJxA1KOdOS5780WhPfSArA+g4qAmSjelc3p4wWpha8\r\n" - "zhuYwjVuX6JHG0c=\r\n" - "-----END CERTIFICATE-----\r\n"; - -static const char srv_key_rsa[] = - "-----BEGIN RSA PRIVATE KEY-----\r\n" - "MIIEpAIBAAKCAQEAwU2j3efNHdEE10lyuJmsDnjkOjxKzzoTFtBa5M2jAIin7h5r\r\n" - "lqdStJDvLXJ6PiSa/LY0rCT1d+AmZIycsCh9odrqjObJHJa8/sEEUrM21KP64bF2\r\n" - "2JDBYbRmUjaiJlOqq3ReB30Zgtsq2B+g2Q0cLUlm91slc0boC4pPaQy1AJDh2oIQ\r\n" - "Zn2uVCuLZXmRoeJhw81ASQjuaAzxi4bSRr/QuKoRAx5/VqgaHkQYDw+Fi9qLRF7i\r\n" - "GMZiL8dmjfpd2H3zJ4kpAcWQDj8n8TDISg7v1t7HxydrxwU9esQCPJodPg/oNJhb\r\n" - "y3NLUpbYEaIsgIhpOVrTD7DeWS8Rx/fqEgEwlwIDAQABAoIBAQCXR0S8EIHFGORZ\r\n" - "++AtOg6eENxD+xVs0f1IeGz57Tjo3QnXX7VBZNdj+p1ECvhCE/G7XnkgU5hLZX+G\r\n" - "Z0jkz/tqJOI0vRSdLBbipHnWouyBQ4e/A1yIJdlBtqXxJ1KE/ituHRbNc4j4kL8Z\r\n" - "/r6pvwnTI0PSx2Eqs048YdS92LT6qAv4flbNDxMn2uY7s4ycS4Q8w1JXnCeaAnYm\r\n" - "WYI5wxO+bvRELR2Mcz5DmVnL8jRyml6l6582bSv5oufReFIbyPZbQWlXgYnpu6He\r\n" - "GTc7E1zKYQGG/9+DQUl/1vQuCPqQwny0tQoX2w5tdYpdMdVm+zkLtbajzdTviJJa\r\n" - "TWzL6lt5AoGBAN86+SVeJDcmQJcv4Eq6UhtRr4QGMiQMz0Sod6ettYxYzMgxtw28\r\n" - "CIrgpozCc+UaZJLo7UxvC6an85r1b2nKPCLQFaggJ0H4Q0J/sZOhBIXaoBzWxveK\r\n" - "nupceKdVxGsFi8CDy86DBfiyFivfBj+47BbaQzPBj7C4rK7UlLjab2rDAoGBAN2u\r\n" - "AM2gchoFiu4v1HFL8D7lweEpi6ZnMJjnEu/dEgGQJFjwdpLnPbsj4c75odQ4Gz8g\r\n" - "sw9lao9VVzbusoRE/JGI4aTdO0pATXyG7eG1Qu+5Yc1YGXcCrliA2xM9xx+d7f+s\r\n" - "mPzN+WIEg5GJDYZDjAzHG5BNvi/FfM1C9dOtjv2dAoGAF0t5KmwbjWHBhcVqO4Ic\r\n" - "BVvN3BIlc1ue2YRXEDlxY5b0r8N4XceMgKmW18OHApZxfl8uPDauWZLXOgl4uepv\r\n" - "whZC3EuWrSyyICNhLY21Ah7hbIEBPF3L3ZsOwC+UErL+dXWLdB56Jgy3gZaBeW7b\r\n" - "vDrEnocJbqCm7IukhXHOBK8CgYEAwqdHB0hqyNSzIOGY7v9abzB6pUdA3BZiQvEs\r\n" - "3LjHVd4HPJ2x0N8CgrBIWOE0q8+0hSMmeE96WW/7jD3fPWwCR5zlXknxBQsfv0gP\r\n" - "3BC5PR0Qdypz+d+9zfMf625kyit4T/hzwhDveZUzHnk1Cf+IG7Q+TOEnLnWAWBED\r\n" - "ISOWmrUCgYAFEmRxgwAc/u+D6t0syCwAYh6POtscq9Y0i9GyWk89NzgC4NdwwbBH\r\n" - "4AgahOxIxXx2gxJnq3yfkJfIjwf0s2DyP0kY2y6Ua1OeomPeY9mrIS4tCuDQ6LrE\r\n" - "TB6l9VGoxJL4fyHnZb8L5gGvnB1bbD8cL6YPaDiOhcRseC9vBiEuVg==\r\n" - "-----END RSA PRIVATE KEY-----\r\n"; -#endif /* CONFIG_HW_RSA */ - -void print_laptime(void) -{ - struct timeval ct; - gettimeofday(&ct, NULL); - - while (ct.tv_usec < rt.tv_usec) { - ct.tv_usec += 1000000; - ct.tv_sec-- ; - } - - printf("%d sec %d msecs\n", - ct.tv_sec - rt.tv_sec, - (ct.tv_usec - rt.tv_usec)/1000); - rt.tv_sec = ct.tv_sec; - rt.tv_usec = ct.tv_usec; - -} - -static void http_get_cb(struct http_client_t *client, struct http_req_message *msg) -{ - struct http_keyvalue_list_t response_headers; - const char *rsp_msg = "This is a root page"; - char contlen[6] = {0,}; - - http_keyvalue_list_init(&response_headers); - - http_keyvalue_list_add(&response_headers, g_httpcontype, g_httpconhtml); - sprintf(contlen, "%d", strlen(rsp_msg)); - http_keyvalue_list_add(&response_headers, g_httpcontsize, contlen); - http_keyvalue_list_add(&response_headers, g_httpconnect, g_httpcnlost); - - printf(">get_root\n"); - http_send_response(client, 200, rsp_msg, &response_headers); - http_keyvalue_list_release(&response_headers); -} - -static void http_post_cb(struct http_client_t *client, struct http_req_message *msg) -{ - cJSON *tmp; - static bool valid_info = false; - - if (msg->entity != NULL) { - cJSON *request_json = cJSON_Parse(msg->entity); - valid_info = true; - if (request_json != NULL) { - memset(&ap_info, 0, sizeof(struct ap_info_t)); - - tmp = cJSON_GetObjectItem(request_json, "ssid"); - - if (tmp != NULL) { - printf("ssid %s\n", tmp->valuestring); - memcpy(ap_info.ssid, tmp->valuestring, strlen(tmp->valuestring)); - } else { - valid_info = false; - } - - tmp = cJSON_GetObjectItem(request_json, "password"); - if (tmp != NULL) { - printf("password %s\n", tmp->valuestring); - memcpy(ap_info.pwd, tmp->valuestring, strlen(tmp->valuestring)); - } else { - valid_info = false; - } - - tmp = cJSON_GetObjectItem(request_json, "security"); - if (tmp != NULL) { - printf("security %s\n", tmp->valuestring); - if (wifi_securitymode_check(tmp->valuestring) != 0) { - - valid_info = false; - printf("wrong argunets\n"); - } else { - memcpy(ap_info.security, tmp->valuestring, strlen(tmp->valuestring)); - } - } else { - valid_info = false; - } - } else { - valid_info = false; - } - - cJSON_Delete(request_json); - - if (msg->encoding == HTTP_CHUNKED_ENCODING && msg->entity[0] != '\0') { - return; - } - } - - http_send_response(client, 200, NULL, NULL); - - if (valid_info) { - sem_post(&get_netinfo); - valid_info = false; - } else { - printf("AP information is not valid\n"); - } -} - -static void http_post_ctrl_cb(struct http_client_t *client, struct http_req_message *msg) -{ - cJSON *tmp; - int stop_val = 0; - - if (msg->entity != NULL) { - cJSON *request_json = cJSON_Parse(msg->entity); - if (request_json != NULL) { - printf(">>>> post /control \n"); - memset(&ap_info, 0, sizeof(struct ap_info_t)); - - tmp = cJSON_GetObjectItem(request_json, "stop"); - if (tmp != NULL) { - printf("stop %d \n", tmp->valueint); - stop_val = tmp->valueint; - } else { - stop_val = 0; - } - } - cJSON_Delete(request_json); - - if (msg->encoding == HTTP_CHUNKED_ENCODING && msg->entity[0] != '\0') { - g_stop_easysetup = stop_val; - return; - } - } - - http_send_response(client, 200, NULL, NULL); - sem_post(&get_ctrl); -} - -static int start_webserver(void) -{ - int https_port = 443; - struct ssl_config_t ssl_config; - - https_server = http_server_init(https_port); - if (https_server == NULL) { - printf("Error: Cannot allocate server structure!!\n"); - return -1; - } - -#if defined(CONFIG_HW_RSA) - int ret; - - see_init(); - - /* Setup post key */ - /* THIS CODE SHOULD BE REMOVED AFTER USING SSS KEY AND CERT */ - if ((ret = see_setup_key(sss_da_rsa_ca, sizeof(sss_da_rsa_ca), - SECURE_STORAGE_TYPE_KEY_RSA, EASY_CA_KEY_INDEX)) != 0) { - printf("Error: see_setup_key ca 0x%x\n\n", ret); - return -1; - } - - if ((ret = see_setup_key(sss_da_rsa_dev, sizeof(sss_da_rsa_dev), - SECURE_STORAGE_TYPE_KEY_RSA, EASY_DEV_KEY_INDEX)) != 0) { - printf("Error: see_setup_key dev 0x%x\n\n", ret); - return -1; - } - - if ((ret = see_set_certificate(sss_ca_crt, sizeof(sss_ca_crt), - EASY_CA_CERT_INDEX, CERT_PEM)) != 0) { - printf("Error: set_cert fail %d\n", ret); - return -1; - } - - if ((ret = see_set_certificate(sss_dev_crt, sizeof(sss_dev_crt), - EASY_DEV_CERT_INDEX, CERT_PEM)) != 0) { - printf("Error: set_cert fail %d\n", ret); - return -1; - } - - ssl_config.ca_key_index = EASY_CA_KEY_INDEX; - ssl_config.dev_key_index = EASY_DEV_KEY_INDEX; - ssl_config.ca_cert_index = EASY_CA_CERT_INDEX; - ssl_config.dev_cert_index = EASY_DEV_CERT_INDEX; - ssl_config.auth_mode = MBEDTLS_SSL_VERIFY_REQUIRED; -#else - ssl_config.root_ca = (char *)ca_crt_rsa; - ssl_config.root_ca_len = sizeof(ca_crt_rsa); - ssl_config.dev_cert = (char *)srv_crt_rsa; - ssl_config.dev_cert_len = sizeof(srv_crt_rsa); - ssl_config.private_key = (char *)srv_key_rsa; - ssl_config.private_key_len = sizeof(srv_key_rsa); - ssl_config.auth_mode = MBEDTLS_SSL_VERIFY_REQUIRED; -#endif /* CONFIG_HW_RSA */ - - if (http_tls_init(https_server, &ssl_config) != 0) { - printf("ssl config Error\n"); - return -1; - } - - http_server_register_cb(https_server, HTTP_METHOD_GET, root_uri, http_get_cb); - http_server_register_cb(https_server, HTTP_METHOD_POST, network_uri, http_post_cb); - http_server_register_cb(https_server, HTTP_METHOD_POST, control_uri, http_post_ctrl_cb); - - http_server_start(https_server); - - return 0; -} - -static int stop_webserver(void) -{ - http_server_deregister_cb(https_server, HTTP_METHOD_GET, root_uri); - http_server_deregister_cb(https_server, HTTP_METHOD_POST, network_uri); - http_server_deregister_cb(https_server, HTTP_METHOD_POST, control_uri); - http_server_stop(https_server); - http_server_release(&https_server); - -#if defined(CONFIG_HW_RSA) - see_free(); -#endif - return 0; -} -/* function is used from multiple places so dont rely on local static vars in this file */ -static void getSecurityModeString(slsi_security_config_t *sec, uint8_t count, char* modestring) -{ - memset(modestring, 0, MODE_STRING_MAX); - char *pos = modestring; - int x = 0; - - if (count == 0) { - strncat(pos, "[NONE]", 6); - } else { - for (x = 0; x < count; x++) { - strncat(pos, "[", 1); - pos += 1; - if (sec->secmode == SLSI_SEC_MODE_WEP) { - strncat(pos, "WEP", 3); - pos += 3; - } else if (sec->secmode == SLSI_SEC_MODE_WEP_SHARED) { - strncat(pos, "WEP_SHARED", 10); - pos += 10; - } else if (sec->secmode == (SLSI_SEC_MODE_WEP | SLSI_SEC_MODE_WEP_SHARED)) { - strncat(pos, "WEP_UNKNOWN", 11); - pos += 11; - } else if (sec->secmode == SLSI_SEC_MODE_WPA_TKIP) { - strncat(pos, "WPA-PSK+TKIP", 12); - pos += 12; - } else if (sec->secmode == SLSI_SEC_MODE_WPA_CCMP) { - strncat(pos, "WPA-PSK+AES", 11); - pos += 11; - } else if (sec->secmode == SLSI_SEC_MODE_WPA_MIXED) { - strncat(pos, "WPA-PSK+AES+TKIP", 16); - pos += 16; - } else if (sec->secmode == SLSI_SEC_MODE_WPA2_TKIP) { - strncat(pos, "WPA2-PSK+TKIP", 13); - pos += 13; - } else if (sec->secmode == SLSI_SEC_MODE_WPA2_CCMP) { - strncat(pos, "WPA2-PSK+AES", 12); - pos += 12; - } else if (sec->secmode == SLSI_SEC_MODE_WPA2_MIXED) { - strncat(pos, "WPA2-PSK+AES+TKIP", 17); - pos += 17; - } else if (sec->secmode == SLSI_SEC_MODE_EAP) { - strncat(pos, "WPA-EAP", 7); - pos += 7; - } - - strncat(pos, "]", 1); - pos += 1; - sec++; //go to next structure - } - } -} - -static void print_scan_result(slsi_scan_info_t *list) -{ - int count = 0; - slsi_scan_info_t *current_element = list; - printf("Scan Result - networks:\n"); - printf(" %-20.20s %-8.8s %-40.40s %-6.6s %s\n", "BSSID", "RSSI", "SECURITY", "CH", "SSID"); - - while (current_element) { - char ssid[WPA_MAX_SSID_LEN]; - char modestring[MODE_STRING_MAX]; - count++; - getSecurityModeString(current_element->sec_modes, current_element->num_sec_modes, modestring); - printf_encode(ssid, WPA_MAX_SSID_LEN, current_element->ssid, current_element->ssid_len); - printf(" %3.3d) %-20.20s %-8.8d %-40.40s %-6.6d %.32s \n", - count, current_element->bssid, current_element->rssi, modestring, - current_element->channel, ssid); - current_element = current_element->next; - } -} - -static int8_t scan_result_handler(slsi_reason_t* reason) -{ - if (reason->reason_code != 0) { - printf("Scan failed reason: %d, locally_generated: %d\n", reason->reason_code, reason->locally_generated); - } else { - slsi_scan_info_t *scan_list_head; - WiFiGetScanResults(&scan_list_head); - print_scan_result(scan_list_head); - WiFiFreeScanResults(&scan_list_head); - sem_post(&finish_scan); - } - - return 0; -} - -#ifdef CONFIG_BUILD_KERNEL -int main(int argc, FAR char *argv[]) -#else -int easysetup_main(int argc, char **argv) -#endif -{ - int easysetup_cnt = 0; -_START_: - sem_init(&get_netinfo, 0, 0); - sem_init(&finish_scan, 0, 0); - sem_init(&get_ctrl, 0, 0); - - gettimeofday(&rt, NULL); - printf("=======================================\n"); - printf("EASYSETUP start [%d] ::", easysetup_cnt); - print_laptime(); - if (wifi_start_ap((uint8_t *)soft_ap_ssid, (char *)soft_ap_security, (char *)soft_ap_passphase, soft_ap_channel) != 0) { - printf("Error start softap\n"); - return 0; - } - - printf("Start SoftAP ::"); - print_laptime(); - -#ifdef CONFIG_SLSI_WIFI_SANITY - dhcpserver_start(); - printf("Start DHCP Server Start ::"); - print_laptime(); -#endif - - if (start_webserver() != 0) { - printf("webserver start fail\n"); - } - - printf("Start Webserver ::"); - print_laptime(); - - sem_wait(&get_netinfo); - printf("Get AP information ::"); - print_laptime(); - WiFiRegisterScanCallback(&scan_result_handler); - WiFiScanNetwork(); - sem_wait(&finish_scan); - printf("Scan finish ::"); - print_laptime(); - - stop_webserver(); - printf("Stop Webserver ::"); - print_laptime(); - -#ifdef CONFIG_SLSI_WIFI_SANITY - stop_dhcp(SLSI_WIFI_SOFT_AP_IF); - printf("Stop DHCP Server ::"); - print_laptime(); -#endif - - if (wifi_start_station() < 0) { - printf("start station error \n"); - sem_destroy(&get_netinfo); - sem_destroy(&finish_scan); - return 0; - } - - while (wifi_join((uint8_t *)ap_info.ssid, ap_info.security, ap_info.pwd) != 0) { - printf("Retry to Join\n"); - sleep(1); - } - - while (get_wifiState() == WIFI_DISCONNECTED) { - printf("wait connecting to AP\n"); - usleep(300000); - } - - printf("AP join ::"); - print_laptime(); - -#ifdef CONFIG_SLSI_WIFI_SANITY - while (dhcpc_start() != 0) { - printf("Get IP address Fail\n"); - } -#endif - - printf("DHCP Client Start ::"); - print_laptime(); - g_stop_easysetup = 0; - if (start_webserver() != 0) { - printf("webserver start fail\n"); - return -1; - } - - printf("Start Webserver ::\n"); - print_laptime(); - - sem_wait(&get_ctrl); - - sleep(1); - - printf("Stop\n"); - sem_destroy(&get_netinfo); - sem_destroy(&finish_scan); - sem_destroy(&get_ctrl); - stop_webserver(); -#ifdef CONFIG_SLSI_WIFI_SANITY - stop_dhcp(SLSI_WIFI_STATION_IF); -#endif - - easysetup_cnt++; - - printf("=======================================\n"); - if (g_stop_easysetup == 2) { - goto _START_; - } - - if (WiFiStop() != 0) { - return -1; - } - - return 0; -} diff --git a/apps/examples/easysetup/wifi_api.c b/apps/examples/easysetup/wifi_api.c deleted file mode 100644 index a1af7f5..0000000 --- a/apps/examples/easysetup/wifi_api.c +++ /dev/null @@ -1,349 +0,0 @@ -/* ************************************************************************** - * @file apps/example/easysetup/wifi_api.c - ****************************************************************************/ -#include -#include -#include -#include -#include -#include - -#ifdef CONFIG_NET_LWIP -#include -#include -#endif -#include "wifi_api.h" - -#ifndef BIT -#define BIT(x) (1 << (x)) -#endif - -#define SLSI_WIFI_SECURITY_OPEN "open" -#define SLSI_WIFI_SECURITY_WEP_OPEN "wep" -#define SLSI_WIFI_SECURITY_WEP_SHARED "wep_shared" -#define SLSI_WIFI_SECURITY_WPA_MIXED "wpa_mixed" -#define SLSI_WIFI_SECURITY_WPA_TKIP "wpa_tkip" -#define SLSI_WIFI_SECURITY_WPA_AES "wpa_aes" -#define SLSI_WIFI_SECURITY_WPA2_MIXED "wpa2_mixed" -#define SLSI_WIFI_SECURITY_WPA2_TKIP "wpa2_tkip" -#define SLSI_WIFI_SECURITY_WPA2_AES "wpa2_aes" - -#ifdef CONFIG_SLSI_WIFI_SANITY -static struct netif *gnet_if; -#endif -static int g_wifi_state; - -int wifi_securitymode_check(char *sec_type) -{ - int ret = -1; - - if (strncmp(SLSI_WIFI_SECURITY_OPEN, - sec_type, sizeof(SLSI_WIFI_SECURITY_OPEN)) == 0) { - ret = 0; - } else if (strncmp(SLSI_WIFI_SECURITY_WEP_OPEN, - sec_type, sizeof(SLSI_WIFI_SECURITY_WEP_OPEN)) == 0) { - ret = 0; - } else if (strncmp(SLSI_WIFI_SECURITY_WEP_SHARED, - sec_type, sizeof(SLSI_WIFI_SECURITY_WEP_SHARED)) == 0) { - ret = 0; - } else if (strncmp(SLSI_WIFI_SECURITY_WPA_MIXED, - sec_type, sizeof(SLSI_WIFI_SECURITY_WPA_MIXED)) == 0) { - ret = 0; - } else if (strncmp(SLSI_WIFI_SECURITY_WPA_TKIP, - sec_type, sizeof(SLSI_WIFI_SECURITY_WPA_TKIP)) == 0) { - ret = 0; - } else if (strncmp(SLSI_WIFI_SECURITY_WPA_AES, - sec_type, sizeof(SLSI_WIFI_SECURITY_WPA_AES)) == 0) { - ret = 0; - } else if (strncmp(SLSI_WIFI_SECURITY_WPA2_MIXED, - sec_type, sizeof(SLSI_WIFI_SECURITY_WPA2_MIXED)) == 0) { - ret = 0; - } else if (strncmp(SLSI_WIFI_SECURITY_WPA2_TKIP, - sec_type, sizeof(SLSI_WIFI_SECURITY_WPA2_TKIP)) == 0) { - ret = 0; - } else if (strncmp(SLSI_WIFI_SECURITY_WPA2_AES, - sec_type, sizeof(SLSI_WIFI_SECURITY_WPA2_AES)) == 0) { - ret = 0; - } - - return ret; - -} - -static slsi_security_config_t *get_security_config_(char *sec_type, char *psk) -{ - slsi_security_config_t *ret = NULL; - if (strncmp(SLSI_WIFI_SECURITY_OPEN, - sec_type, sizeof(SLSI_WIFI_SECURITY_OPEN)) != 0) { - ret = (slsi_security_config_t *)zalloc(sizeof(slsi_security_config_t)); - if (ret) { - if (strncmp(SLSI_WIFI_SECURITY_WEP_OPEN, - sec_type, sizeof(SLSI_WIFI_SECURITY_WEP_OPEN)) == 0) { - ret->secmode = SLSI_SEC_MODE_WEP; - } else if (strncmp(SLSI_WIFI_SECURITY_WEP_SHARED, - sec_type, sizeof(SLSI_WIFI_SECURITY_WEP_SHARED)) == 0) { - ret->secmode = SLSI_SEC_MODE_WEP_SHARED; - } else if (strncmp(SLSI_WIFI_SECURITY_WPA_MIXED, - sec_type, sizeof(SLSI_WIFI_SECURITY_WPA_MIXED)) == 0) { - ret->secmode = SLSI_SEC_MODE_WPA_MIXED; - } else if (strncmp(SLSI_WIFI_SECURITY_WPA_TKIP, - sec_type, sizeof(SLSI_WIFI_SECURITY_WPA_TKIP)) == 0) { - ret->secmode = SLSI_SEC_MODE_WPA_TKIP; - } else if (strncmp(SLSI_WIFI_SECURITY_WPA_AES, - sec_type, sizeof(SLSI_WIFI_SECURITY_WPA_AES)) == 0) { - ret->secmode = SLSI_SEC_MODE_WPA_CCMP; - } else if (strncmp(SLSI_WIFI_SECURITY_WPA2_MIXED, - sec_type, sizeof(SLSI_WIFI_SECURITY_WPA2_MIXED)) == 0) { - ret->secmode = SLSI_SEC_MODE_WPA2_MIXED; - } else if (strncmp(SLSI_WIFI_SECURITY_WPA2_TKIP, - sec_type, sizeof(SLSI_WIFI_SECURITY_WPA2_TKIP)) == 0) { - ret->secmode = SLSI_SEC_MODE_WPA2_TKIP; - } else if (strncmp(SLSI_WIFI_SECURITY_WPA2_AES, - sec_type, sizeof(SLSI_WIFI_SECURITY_WPA2_AES)) == 0) { - ret->secmode = SLSI_SEC_MODE_WPA2_CCMP; - } - } - - /* store the passphrase */ - if (psk) { - memcpy(ret->passphrase, psk, strlen(psk)); - } else { - free(ret); - ret = NULL; - } - } - - return ret; -} - -static void linkUpHandler(slsi_reason_t* reason) -{ - g_wifi_state = WIFI_CONNECTED; - printf("Connected to network\n"); -} - -static void linkDownHandler(slsi_reason_t* reason) -{ - if (reason) { - printf("Disconnected from network reason_code: %d %s\n", reason->reason_code, - reason->locally_generated ? "(locally_generated)" : ""); - } else { - printf("Disconnected from network\n"); - } -} - -int get_wifiState(void) -{ - return g_wifi_state; -} - -int wifi_start_station(void) -{ - int result = -1; - printf("Starting STA mode...\n"); - - g_wifi_state = WIFI_DISCONNECTED; - - if (WiFiStart(SLSI_WIFI_STATION_IF, NULL) == SLSI_STATUS_SUCCESS) { - result = 0; - if (!WiFiRegisterLinkCallback(&linkUpHandler, &linkDownHandler)) { - printf("Link call back handles registered - per default!\n"); - } else { - printf("Link call back handles registered - status failed !\n"); - } - } else { - printf("WiFiStart STA mode failed !\n"); - } - - return result; -} - -int wifi_start_ap(uint8_t *ssid, char *security, char *passwd, int ch) -{ - slsi_ap_config_t *app_settings = zalloc(sizeof(slsi_ap_config_t)); - - if (app_settings == NULL) { - return -1; - } - g_wifi_state = WIFI_DISCONNECTED; - - memcpy(app_settings->ssid, ssid, strlen((char *)ssid)); - app_settings->ssid_len = strlen((char *)ssid); - app_settings->beacon_period = 100; - app_settings->DTIM = 2; - app_settings->channel = ch; - app_settings->phy_mode = 1; - app_settings->security = get_security_config_(security, passwd); - - /*activate hostapd*/ - printf("Starting AP mode...\n"); - if (WiFiStart(SLSI_WIFI_SOFT_AP_IF, app_settings) == SLSI_STATUS_SUCCESS) { - if (!WiFiRegisterLinkCallback(&linkUpHandler, &linkDownHandler)) { - printf("Link call back handles registered - per default!\n"); - } else { - printf("Link call back handles registered - status failed !\n"); - } - } else { - printf("WiFiStart AP mode failed !\n"); - return -1; - } - return 0; -} - -int wifi_join(uint8_t *ssid, char *security, char *passwd) -{ - slsi_security_config_t *security_config; - - uint8_t ssid_len = strlen((char *)ssid); - - security_config = get_security_config_(security, passwd); - printf("Joining selected network...\n"); - - if (WiFiNetworkJoin(ssid, ssid_len, NULL, security_config) != 0) { - printf("SLSI_WiFiNetworkJoin start failed!\n"); - if (security_config) { - free(security_config); - security_config = NULL; - } - return -1; - } else { - printf("WiFiNetworkJoin start success!\n"); - if (security_config) { - free(security_config); - security_config = NULL; - } - } - return 0; -} - -int wifi_leave(void) -{ - int result = -1; - - printf("Leaving selected network...\n"); - if (WiFiNetworkLeave()) { - printf("WiFiNetworkLeave failed!\n"); - } else { - result = 0; - } - - return result; -} - -#ifdef CONFIG_SLSI_WIFI_SANITY -int dhcpc_start(void) -{ - gnet_if = netif_find(CTRL_IFNAME); - - if (gnet_if == NULL) { - return -1; - } - - if (gnet_if->dhcp != NULL) { - gnet_if->dhcp = NULL; - } - - printf(" netic hwaddr_len %d\n" - " netic hwaddr %x%x%x%x%x%x\n" - " netic mtu %d\n" - " netic flags %x\n", - gnet_if->hwaddr_len, - gnet_if->hwaddr[0], gnet_if->hwaddr[1], gnet_if->hwaddr[2], - gnet_if->hwaddr[3], gnet_if->hwaddr[4], gnet_if->hwaddr[5], - gnet_if->mtu, gnet_if->flags); - - err_t res = dhcp_start(gnet_if); - - if (res) { - printf("slsi_start_dhcp dhcp_start result %d\n", res); - return -1; - } - - printf("slsi_start_dhcp start success state %d result %d\n", - gnet_if->dhcp->state, res); - - int32_t timeleft = 5000000; - - while (gnet_if->dhcp->state != DHCP_BOUND) { - usleep(10000); - timeleft -= 10000; - if (timeleft <= 0) { - break; - } - } - - if (gnet_if->dhcp->state == DHCP_BOUND) { - printf("DHCP Client - got IP address %u.%u.%u.%u\n", - (unsigned char) ((htonl(gnet_if->ip_addr.addr) >> 24) & 0xff), - (unsigned char) ((htonl(gnet_if->ip_addr.addr) >> 16) & 0xff), - (unsigned char) ((htonl(gnet_if->ip_addr.addr) >> 8) & 0xff), - (unsigned char) ((htonl(gnet_if->ip_addr.addr) >> 0) & 0xff)); - } else { - if (timeleft <= 0) { - printf("DHCP Client - Timeout fail to get ip address\n"); - return -1; - } - } - - return 0; -} - -int dhcpserver_start(void) -{ - ip_addr_t ipaddr, netmask, gateway; - - gnet_if = netif_find(CTRL_IFNAME); - - if (gnet_if == NULL) { - return -1; - } - - // Setting static IP as 192.168.47.1 in AP mode - ipaddr.addr = 0x012FA8C0; - netmask.addr = 0x00FFFFFF; - gateway.addr = 0x012FA8C0; - netif_set_addr(gnet_if, &ipaddr, &netmask, &gateway); - netif_set_up(gnet_if); - - if (dhcps_start(gnet_if) != ERR_OK) { - printf("DHCP Server - started Fail\n"); - return -1; - } - - printf("DHCP Server - started Success\n"); - - return 0; -} - -int stop_dhcp(int interface) -{ - ip_addr_t ipaddr; - - if (gnet_if == NULL) { - printf("stop_dhcp - nothing to stop\n"); - return 0; - } - - if (interface == SLSI_WIFI_STATION_IF) { - if (gnet_if->dhcp != NULL) { - dhcp_stop(gnet_if); - printf("dhcp client stop!!"); - } else { - return -1; - } - } else if (interface == SLSI_WIFI_SOFT_AP_IF) { - if (gnet_if->dhcps_pcb != NULL) { - dhcps_stop(gnet_if); - printf("dhcp server stop!!"); - - ipaddr.addr = 0; - netif_set_ipaddr(gnet_if, &ipaddr); - } else { - return -1; - } - } - - gnet_if = NULL; - return 0; -} -#endif diff --git a/apps/examples/easysetup/wifi_api.h b/apps/examples/easysetup/wifi_api.h deleted file mode 100644 index f8266d6..0000000 --- a/apps/examples/easysetup/wifi_api.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef _WIFI_API_H_ -#define _WIFI_API_H_ -#include - -enum wifi_state { - WIFI_CONNECTED, - WIFI_DISCONNECTED, -}; - -int get_wifiState(void); -int wifi_start_station(void); -int wifi_start_ap(uint8_t *ssid, char *security, char *password, int ch); -int wifi_join(uint8_t *ssid, char *security, char *passwd); -int wifi_leave(void); -#ifdef CONFIG_SLSI_WIFI_SANITY -int dhcpc_start(void); -int dhcpserver_start(void); -int stop_dhcp(int interface); -#endif -int wifi_securitymode_check(char *sec_type); -#endif