diff --git a/connectivity/drivers/wifi/CMakeLists.txt b/connectivity/drivers/wifi/CMakeLists.txt index 1715a75..5a7bd97 100644 --- a/connectivity/drivers/wifi/CMakeLists.txt +++ b/connectivity/drivers/wifi/CMakeLists.txt @@ -1,6 +1,8 @@ -# Copyright (c) 2020 ARM Limited. All rights reserved. +# Copyright (c) 2020-2021 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +add_subdirectory(TARGET_WICED EXCLUDE_FROM_ALL) + add_subdirectory(esp8266-driver) target_link_libraries(mbed-wifi diff --git a/connectivity/drivers/wifi/TARGET_WICED/CMakeLists.txt b/connectivity/drivers/wifi/TARGET_WICED/CMakeLists.txt new file mode 100644 index 0000000..c6f83e6 --- /dev/null +++ b/connectivity/drivers/wifi/TARGET_WICED/CMakeLists.txt @@ -0,0 +1,22 @@ +# Copyright (c) 2020-2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +add_library(mbed-wiced INTERFACE) + +if(${MBED_TOOLCHAIN} STREQUAL "ARM") + set(LIB_WICED_DRIVERS TOOLCHAIN_ARMC6/TARGET_WIO_EMW3166/libwiced_drivers.ar) +elseif(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM") + set(LIB_WICED_DRIVERS TOOLCHAIN_GCC_ARM/TARGET_WIO_EMW3166/libwiced_drivers.a) +endif() + +target_link_libraries(mbed-wiced INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/${LIB_WICED_DRIVERS}) + +target_include_directories(mbed-wiced + INTERFACE + wiced_interface +) + +target_sources(mbed-wiced + INTERFACE + wiced_interface/default_wifi_interface.cpp +) diff --git a/connectivity/drivers/wifi/TARGET_WICED/LICENSE-permissive-binary-license-1.0.txt b/connectivity/drivers/wifi/TARGET_WICED/LICENSE-permissive-binary-license-1.0.txt new file mode 100644 index 0000000..2d90698 --- /dev/null +++ b/connectivity/drivers/wifi/TARGET_WICED/LICENSE-permissive-binary-license-1.0.txt @@ -0,0 +1,49 @@ +Permissive Binary License + +Version 1.0, September 2018 + +Redistribution. Redistribution and use in binary form, without +modification, are permitted provided that the following conditions are +met: + +1) Redistributions must reproduce the above copyright notice and the + following disclaimer in the documentation and/or other materials + provided with the distribution. + +2) Unless to the extent explicitly permitted by law, no reverse + engineering, decompilation, or disassembly of this software is + permitted. + +3) Redistribution as part of a software development kit must include the + accompanying file named �DEPENDENCIES� and any dependencies listed in + that file. + +4) Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +Limited patent license. The copyright holders (and contributors) grant a +worldwide, non-exclusive, no-charge, royalty-free patent license to +make, have made, use, offer to sell, sell, import, and otherwise +transfer this software, where such license applies only to those patent +claims licensable by the copyright holders (and contributors) that are +necessarily infringed by this software. This patent license shall not +apply to any combinations that include this software. No hardware is +licensed hereunder. + +If you institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the software +itself infringes your patent(s), then your rights granted under this +license shall terminate as of the date such litigation is filed. + +DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS." 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 +HOLDERS 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. \ No newline at end of file diff --git a/connectivity/drivers/wifi/TARGET_WICED/README.md b/connectivity/drivers/wifi/TARGET_WICED/README.md new file mode 100644 index 0000000..a2b4b1c --- /dev/null +++ b/connectivity/drivers/wifi/TARGET_WICED/README.md @@ -0,0 +1 @@ +This directory tree contains binaries build from Cypress WICED SDK modified for Mbed OS and released under Permissive Binary License. diff --git a/connectivity/drivers/wifi/TARGET_WICED/TOOLCHAIN_ARMC6/TARGET_WIO_EMW3166/libwiced_drivers.ar b/connectivity/drivers/wifi/TARGET_WICED/TOOLCHAIN_ARMC6/TARGET_WIO_EMW3166/libwiced_drivers.ar new file mode 100644 index 0000000..e382dae --- /dev/null +++ b/connectivity/drivers/wifi/TARGET_WICED/TOOLCHAIN_ARMC6/TARGET_WIO_EMW3166/libwiced_drivers.ar Binary files differ diff --git a/connectivity/drivers/wifi/TARGET_WICED/TOOLCHAIN_GCC_ARM/TARGET_WIO_EMW3166/libwiced_drivers.a b/connectivity/drivers/wifi/TARGET_WICED/TOOLCHAIN_GCC_ARM/TARGET_WIO_EMW3166/libwiced_drivers.a new file mode 100644 index 0000000..d825a36 --- /dev/null +++ b/connectivity/drivers/wifi/TARGET_WICED/TOOLCHAIN_GCC_ARM/TARGET_WIO_EMW3166/libwiced_drivers.a Binary files differ diff --git a/connectivity/drivers/wifi/TARGET_WICED/TOOLCHAIN_IAR/TARGET_WIO_EMW3166/libwiced_drivers.a b/connectivity/drivers/wifi/TARGET_WICED/TOOLCHAIN_IAR/TARGET_WIO_EMW3166/libwiced_drivers.a new file mode 100644 index 0000000..fce6b9e --- /dev/null +++ b/connectivity/drivers/wifi/TARGET_WICED/TOOLCHAIN_IAR/TARGET_WIO_EMW3166/libwiced_drivers.a Binary files differ diff --git a/connectivity/drivers/wifi/TARGET_WICED/wiced_interface/WicedInterface.h b/connectivity/drivers/wifi/TARGET_WICED/wiced_interface/WicedInterface.h new file mode 100644 index 0000000..b027e45 --- /dev/null +++ b/connectivity/drivers/wifi/TARGET_WICED/wiced_interface/WicedInterface.h @@ -0,0 +1,118 @@ +/* Wiced implementation of NetworkInterfaceAPI + * Copyright (c) 2017 ARM Limited + * SPDX-License-Identifier: Apache-2.0 + * + * 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. + */ + +#ifndef WICED_INTERFACE_H +#define WICED_INTERFACE_H + +#if defined(MBED_CONF_NSAPI_PRESENT) + +#include "mbed.h" +#include "EthernetInterface.h" +#include "netsocket/OnboardNetworkStack.h" +#include "wiced_emac.h" + + +/** WicedInterface class + * Implementation of the NetworkStack for the Wiced + */ +class WicedInterface : public WiFiInterface, public EMACInterface +{ +public: + + WicedInterface( + EMAC &emac = WICED_EMAC::get_instance(), + OnboardNetworkStack &stack = OnboardNetworkStack::get_default_instance()); + + /** Start the interface + * + * Attempts to connect to a WiFi network. Requires ssid and passphrase to be set. + * If passphrase is invalid, NSAPI_ERROR_AUTH_ERROR is returned. + * + * @return 0 on success, negative error code on failure + */ + nsapi_error_t connect(); + + /** Start the interface + * + * Attempts to connect to a WiFi network. + * + * @param ssid Name of the network to connect to + * @param pass Security passphrase to connect to the network + * @param security Type of encryption for connection (Default: NSAPI_SECURITY_NONE) + * @param channel This parameter is not supported, setting it to anything else than 0 will result in NSAPI_ERROR_UNSUPPORTED + * @return 0 on success, or error code on failure + */ + nsapi_error_t connect(const char *ssid, const char *pass, nsapi_security_t security = NSAPI_SECURITY_NONE, uint8_t channel = 0); + + /** Stop the interface + * @return 0 on success, negative on failure + */ + nsapi_error_t disconnect(); + + /** Set the WiFi network credentials + * + * @param ssid Name of the network to connect to + * @param pass Security passphrase to connect to the network + * @param security Type of encryption for connection + * (defaults to NSAPI_SECURITY_NONE) + * @return 0 on success, or error code on failure + */ + nsapi_error_t set_credentials(const char *ssid, const char *pass, nsapi_security_t security = NSAPI_SECURITY_NONE); + + /** Set the WiFi network channel - NOT SUPPORTED + * + * This function is not supported and will return NSAPI_ERROR_UNSUPPORTED + * + * @param channel Channel on which the connection is to be made, or 0 for any (Default: 0) + * @return Not supported, returns NSAPI_ERROR_UNSUPPORTED + */ + nsapi_error_t set_channel(uint8_t channel) { + if (channel != 0) { + return NSAPI_ERROR_UNSUPPORTED; + } + + return 0; + } + + /** Gets the current radio signal strength for active connection + * + * @return Connection strength in dBm (negative value) + */ + int8_t get_rssi(); + + /** Scan for available networks + * + * This function will block. + * + * @param ap Pointer to allocated array to store discovered AP + * @param count Size of allocated @a res array, or 0 to only count available AP + * @param timeout Timeout in milliseconds; 0 for no timeout (Default: 0) + * @return Number of entries in @a, or if @a count was 0 number of available networks, negative on error + * see @a nsapi_error + */ + int scan(WiFiAccessPoint *res, unsigned count); + +private: + + char _ssid[33]; /* The longest possible name (defined in 802.11) +1 for the \0 */ + char _pass[64]; /* The longest allowed passphrase + 1 */ + nsapi_security_t _security; +}; + +#endif + +#endif diff --git a/connectivity/drivers/wifi/TARGET_WICED/wiced_interface/default_wifi_interface.cpp b/connectivity/drivers/wifi/TARGET_WICED/wiced_interface/default_wifi_interface.cpp new file mode 100644 index 0000000..190b3ad --- /dev/null +++ b/connectivity/drivers/wifi/TARGET_WICED/wiced_interface/default_wifi_interface.cpp @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2018, Arm Limited and affiliates. + * SPDX-License-Identifier: Apache-2.0 + * + * 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. + */ + +#if defined(MBED_CONF_NSAPI_PRESENT) + +#include "WicedInterface.h" + +WiFiInterface *WiFiInterface::get_target_default_instance() +{ + static WicedInterface wifi; + return &wifi; +} + +#endif diff --git a/connectivity/drivers/wifi/TARGET_WICED/wiced_interface/wiced_emac.h b/connectivity/drivers/wifi/TARGET_WICED/wiced_interface/wiced_emac.h new file mode 100644 index 0000000..5a6c21d --- /dev/null +++ b/connectivity/drivers/wifi/TARGET_WICED/wiced_interface/wiced_emac.h @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2018 ARM Limited + * SPDX-License-Identifier: Apache-2.0 + * + * 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. + */ + +#ifndef WICED_EMAC_H_ +#define WICED_EMAC_H_ + +#include "EMAC.h" +#include "EMACInterface.h" +#include "WiFiInterface.h" + +#include "rtos/Mutex.h" + +class WICED_EMAC : public EMAC { +public: + WICED_EMAC(); + + static WICED_EMAC &get_instance(); + + /** + * Return maximum transmission unit + * + * @return MTU in bytes + */ + virtual uint32_t get_mtu_size() const; + + /** + * Gets memory buffer alignment preference + * + * Gets preferred memory buffer alignment of the Emac device. IP stack may or may not + * align link out memory buffer chains using the alignment. + * + * @return Memory alignment requirement in bytes + */ + virtual uint32_t get_align_preference() const; + + /** + * Return interface name + * + * @param name Pointer to where the name should be written + * @param size Maximum number of character to copy + */ + virtual void get_ifname(char *name, uint8_t size) const; + + /** + * Returns size of the underlying interface HW address size. + * + * @return HW address size in bytes + */ + virtual uint8_t get_hwaddr_size() const; + + /** + * Return interface-supplied HW address + * + * Copies HW address to provided memory, @param addr has to be of correct size see @a get_hwaddr_size + * + * HW address need not be provided if this interface does not have its own HW + * address configuration; stack will choose address from central system + * configuration if the function returns false and does not write to addr. + * + * @param addr HW address for underlying interface + * @return true if HW address is available + */ + virtual bool get_hwaddr(uint8_t *addr) const; + + /** + * Set HW address for interface + * + * Provided address has to be of correct size, see @a get_hwaddr_size + * + * Called to set the MAC address to actually use - if @a get_hwaddr is provided + * the stack would normally use that, but it could be overridden, eg for test + * purposes. + * + * @param addr Address to be set + */ + virtual void set_hwaddr(const uint8_t *addr); + + /** + * Sends the packet over the link + * + * That can not be called from an interrupt context. + * + * @param buf Packet to be send + * @return True if the packet was send successfully, False otherwise + */ + virtual bool link_out(emac_mem_buf_t *buf); + + /** + * Initializes the HW + * + * @return True on success, False in case of an error. + */ + virtual bool power_up(); + + /** + * Deinitializes the HW + * + */ + virtual void power_down(); + + /** + * Sets a callback that needs to be called for packets received for that interface + * + * @param input_cb Function to be register as a callback + */ + virtual void set_link_input_cb(emac_link_input_cb_t input_cb); + + /** + * Sets a callback that needs to be called on link status changes for given interface + * + * @param state_cb Function to be register as a callback + */ + virtual void set_link_state_cb(emac_link_state_change_cb_t state_cb); + + /** Add device to a multicast group + * + * @param address A multicast group hardware address + */ + virtual void add_multicast_group(const uint8_t *address); + + /** Remove device from a multicast group + * + * @param address A multicast group hardware address + */ + virtual void remove_multicast_group(const uint8_t *address); + + /** Request reception of all multicast packets + * + * @param all True to receive all multicasts + * False to receive only multicasts addressed to specified groups + */ + virtual void set_all_multicast(bool all); + + /** Sets memory manager that is used to handle memory buffers + * + * @param mem_mngr Pointer to memory manager + */ + virtual void set_memory_manager(EMACMemoryManager &mem_mngr); + + emac_link_input_cb_t emac_link_input_cb; /**< Callback for incoming data */ + emac_link_state_change_cb_t emac_link_state_cb; + EMACMemoryManager *memory_manager; + +}; + +#endif /* WICED_EMAC_H_ */ diff --git a/targets/CMakeLists.txt b/targets/CMakeLists.txt index 608dae6..8683c25 100644 --- a/targets/CMakeLists.txt +++ b/targets/CMakeLists.txt @@ -35,7 +35,3 @@ elseif("TOSHIBA" IN_LIST MBED_TARGET_LABELS) add_subdirectory(TARGET_TOSHIBA) endif() - -if("WICED" IN_LIST MBED_TARGET_LABELS) - add_subdirectory(TARGET_WICED) -endif() diff --git a/targets/TARGET_WICED/CMakeLists.txt b/targets/TARGET_WICED/CMakeLists.txt deleted file mode 100644 index c6f83e6..0000000 --- a/targets/TARGET_WICED/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright (c) 2020-2021 ARM Limited. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -add_library(mbed-wiced INTERFACE) - -if(${MBED_TOOLCHAIN} STREQUAL "ARM") - set(LIB_WICED_DRIVERS TOOLCHAIN_ARMC6/TARGET_WIO_EMW3166/libwiced_drivers.ar) -elseif(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM") - set(LIB_WICED_DRIVERS TOOLCHAIN_GCC_ARM/TARGET_WIO_EMW3166/libwiced_drivers.a) -endif() - -target_link_libraries(mbed-wiced INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/${LIB_WICED_DRIVERS}) - -target_include_directories(mbed-wiced - INTERFACE - wiced_interface -) - -target_sources(mbed-wiced - INTERFACE - wiced_interface/default_wifi_interface.cpp -) diff --git a/targets/TARGET_WICED/LICENSE-permissive-binary-license-1.0.txt b/targets/TARGET_WICED/LICENSE-permissive-binary-license-1.0.txt deleted file mode 100644 index 2d90698..0000000 --- a/targets/TARGET_WICED/LICENSE-permissive-binary-license-1.0.txt +++ /dev/null @@ -1,49 +0,0 @@ -Permissive Binary License - -Version 1.0, September 2018 - -Redistribution. Redistribution and use in binary form, without -modification, are permitted provided that the following conditions are -met: - -1) Redistributions must reproduce the above copyright notice and the - following disclaimer in the documentation and/or other materials - provided with the distribution. - -2) Unless to the extent explicitly permitted by law, no reverse - engineering, decompilation, or disassembly of this software is - permitted. - -3) Redistribution as part of a software development kit must include the - accompanying file named �DEPENDENCIES� and any dependencies listed in - that file. - -4) Neither the name of the copyright holder nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -Limited patent license. The copyright holders (and contributors) grant a -worldwide, non-exclusive, no-charge, royalty-free patent license to -make, have made, use, offer to sell, sell, import, and otherwise -transfer this software, where such license applies only to those patent -claims licensable by the copyright holders (and contributors) that are -necessarily infringed by this software. This patent license shall not -apply to any combinations that include this software. No hardware is -licensed hereunder. - -If you institute patent litigation against any entity (including a -cross-claim or counterclaim in a lawsuit) alleging that the software -itself infringes your patent(s), then your rights granted under this -license shall terminate as of the date such litigation is filed. - -DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -CONTRIBUTORS "AS IS." 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 -HOLDERS 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. \ No newline at end of file diff --git a/targets/TARGET_WICED/README.md b/targets/TARGET_WICED/README.md deleted file mode 100644 index a2b4b1c..0000000 --- a/targets/TARGET_WICED/README.md +++ /dev/null @@ -1 +0,0 @@ -This directory tree contains binaries build from Cypress WICED SDK modified for Mbed OS and released under Permissive Binary License. diff --git a/targets/TARGET_WICED/TOOLCHAIN_ARMC6/TARGET_WIO_EMW3166/libwiced_drivers.ar b/targets/TARGET_WICED/TOOLCHAIN_ARMC6/TARGET_WIO_EMW3166/libwiced_drivers.ar deleted file mode 100644 index e382dae..0000000 --- a/targets/TARGET_WICED/TOOLCHAIN_ARMC6/TARGET_WIO_EMW3166/libwiced_drivers.ar +++ /dev/null Binary files differ diff --git a/targets/TARGET_WICED/TOOLCHAIN_GCC_ARM/TARGET_WIO_EMW3166/libwiced_drivers.a b/targets/TARGET_WICED/TOOLCHAIN_GCC_ARM/TARGET_WIO_EMW3166/libwiced_drivers.a deleted file mode 100644 index d825a36..0000000 --- a/targets/TARGET_WICED/TOOLCHAIN_GCC_ARM/TARGET_WIO_EMW3166/libwiced_drivers.a +++ /dev/null Binary files differ diff --git a/targets/TARGET_WICED/TOOLCHAIN_IAR/TARGET_WIO_EMW3166/libwiced_drivers.a b/targets/TARGET_WICED/TOOLCHAIN_IAR/TARGET_WIO_EMW3166/libwiced_drivers.a deleted file mode 100644 index fce6b9e..0000000 --- a/targets/TARGET_WICED/TOOLCHAIN_IAR/TARGET_WIO_EMW3166/libwiced_drivers.a +++ /dev/null Binary files differ diff --git a/targets/TARGET_WICED/wiced_interface/WicedInterface.h b/targets/TARGET_WICED/wiced_interface/WicedInterface.h deleted file mode 100644 index b027e45..0000000 --- a/targets/TARGET_WICED/wiced_interface/WicedInterface.h +++ /dev/null @@ -1,118 +0,0 @@ -/* Wiced implementation of NetworkInterfaceAPI - * Copyright (c) 2017 ARM Limited - * SPDX-License-Identifier: Apache-2.0 - * - * 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. - */ - -#ifndef WICED_INTERFACE_H -#define WICED_INTERFACE_H - -#if defined(MBED_CONF_NSAPI_PRESENT) - -#include "mbed.h" -#include "EthernetInterface.h" -#include "netsocket/OnboardNetworkStack.h" -#include "wiced_emac.h" - - -/** WicedInterface class - * Implementation of the NetworkStack for the Wiced - */ -class WicedInterface : public WiFiInterface, public EMACInterface -{ -public: - - WicedInterface( - EMAC &emac = WICED_EMAC::get_instance(), - OnboardNetworkStack &stack = OnboardNetworkStack::get_default_instance()); - - /** Start the interface - * - * Attempts to connect to a WiFi network. Requires ssid and passphrase to be set. - * If passphrase is invalid, NSAPI_ERROR_AUTH_ERROR is returned. - * - * @return 0 on success, negative error code on failure - */ - nsapi_error_t connect(); - - /** Start the interface - * - * Attempts to connect to a WiFi network. - * - * @param ssid Name of the network to connect to - * @param pass Security passphrase to connect to the network - * @param security Type of encryption for connection (Default: NSAPI_SECURITY_NONE) - * @param channel This parameter is not supported, setting it to anything else than 0 will result in NSAPI_ERROR_UNSUPPORTED - * @return 0 on success, or error code on failure - */ - nsapi_error_t connect(const char *ssid, const char *pass, nsapi_security_t security = NSAPI_SECURITY_NONE, uint8_t channel = 0); - - /** Stop the interface - * @return 0 on success, negative on failure - */ - nsapi_error_t disconnect(); - - /** Set the WiFi network credentials - * - * @param ssid Name of the network to connect to - * @param pass Security passphrase to connect to the network - * @param security Type of encryption for connection - * (defaults to NSAPI_SECURITY_NONE) - * @return 0 on success, or error code on failure - */ - nsapi_error_t set_credentials(const char *ssid, const char *pass, nsapi_security_t security = NSAPI_SECURITY_NONE); - - /** Set the WiFi network channel - NOT SUPPORTED - * - * This function is not supported and will return NSAPI_ERROR_UNSUPPORTED - * - * @param channel Channel on which the connection is to be made, or 0 for any (Default: 0) - * @return Not supported, returns NSAPI_ERROR_UNSUPPORTED - */ - nsapi_error_t set_channel(uint8_t channel) { - if (channel != 0) { - return NSAPI_ERROR_UNSUPPORTED; - } - - return 0; - } - - /** Gets the current radio signal strength for active connection - * - * @return Connection strength in dBm (negative value) - */ - int8_t get_rssi(); - - /** Scan for available networks - * - * This function will block. - * - * @param ap Pointer to allocated array to store discovered AP - * @param count Size of allocated @a res array, or 0 to only count available AP - * @param timeout Timeout in milliseconds; 0 for no timeout (Default: 0) - * @return Number of entries in @a, or if @a count was 0 number of available networks, negative on error - * see @a nsapi_error - */ - int scan(WiFiAccessPoint *res, unsigned count); - -private: - - char _ssid[33]; /* The longest possible name (defined in 802.11) +1 for the \0 */ - char _pass[64]; /* The longest allowed passphrase + 1 */ - nsapi_security_t _security; -}; - -#endif - -#endif diff --git a/targets/TARGET_WICED/wiced_interface/default_wifi_interface.cpp b/targets/TARGET_WICED/wiced_interface/default_wifi_interface.cpp deleted file mode 100644 index 190b3ad..0000000 --- a/targets/TARGET_WICED/wiced_interface/default_wifi_interface.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2018, Arm Limited and affiliates. - * SPDX-License-Identifier: Apache-2.0 - * - * 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. - */ - -#if defined(MBED_CONF_NSAPI_PRESENT) - -#include "WicedInterface.h" - -WiFiInterface *WiFiInterface::get_target_default_instance() -{ - static WicedInterface wifi; - return &wifi; -} - -#endif diff --git a/targets/TARGET_WICED/wiced_interface/wiced_emac.h b/targets/TARGET_WICED/wiced_interface/wiced_emac.h deleted file mode 100644 index 5a6c21d..0000000 --- a/targets/TARGET_WICED/wiced_interface/wiced_emac.h +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright (c) 2018 ARM Limited - * SPDX-License-Identifier: Apache-2.0 - * - * 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. - */ - -#ifndef WICED_EMAC_H_ -#define WICED_EMAC_H_ - -#include "EMAC.h" -#include "EMACInterface.h" -#include "WiFiInterface.h" - -#include "rtos/Mutex.h" - -class WICED_EMAC : public EMAC { -public: - WICED_EMAC(); - - static WICED_EMAC &get_instance(); - - /** - * Return maximum transmission unit - * - * @return MTU in bytes - */ - virtual uint32_t get_mtu_size() const; - - /** - * Gets memory buffer alignment preference - * - * Gets preferred memory buffer alignment of the Emac device. IP stack may or may not - * align link out memory buffer chains using the alignment. - * - * @return Memory alignment requirement in bytes - */ - virtual uint32_t get_align_preference() const; - - /** - * Return interface name - * - * @param name Pointer to where the name should be written - * @param size Maximum number of character to copy - */ - virtual void get_ifname(char *name, uint8_t size) const; - - /** - * Returns size of the underlying interface HW address size. - * - * @return HW address size in bytes - */ - virtual uint8_t get_hwaddr_size() const; - - /** - * Return interface-supplied HW address - * - * Copies HW address to provided memory, @param addr has to be of correct size see @a get_hwaddr_size - * - * HW address need not be provided if this interface does not have its own HW - * address configuration; stack will choose address from central system - * configuration if the function returns false and does not write to addr. - * - * @param addr HW address for underlying interface - * @return true if HW address is available - */ - virtual bool get_hwaddr(uint8_t *addr) const; - - /** - * Set HW address for interface - * - * Provided address has to be of correct size, see @a get_hwaddr_size - * - * Called to set the MAC address to actually use - if @a get_hwaddr is provided - * the stack would normally use that, but it could be overridden, eg for test - * purposes. - * - * @param addr Address to be set - */ - virtual void set_hwaddr(const uint8_t *addr); - - /** - * Sends the packet over the link - * - * That can not be called from an interrupt context. - * - * @param buf Packet to be send - * @return True if the packet was send successfully, False otherwise - */ - virtual bool link_out(emac_mem_buf_t *buf); - - /** - * Initializes the HW - * - * @return True on success, False in case of an error. - */ - virtual bool power_up(); - - /** - * Deinitializes the HW - * - */ - virtual void power_down(); - - /** - * Sets a callback that needs to be called for packets received for that interface - * - * @param input_cb Function to be register as a callback - */ - virtual void set_link_input_cb(emac_link_input_cb_t input_cb); - - /** - * Sets a callback that needs to be called on link status changes for given interface - * - * @param state_cb Function to be register as a callback - */ - virtual void set_link_state_cb(emac_link_state_change_cb_t state_cb); - - /** Add device to a multicast group - * - * @param address A multicast group hardware address - */ - virtual void add_multicast_group(const uint8_t *address); - - /** Remove device from a multicast group - * - * @param address A multicast group hardware address - */ - virtual void remove_multicast_group(const uint8_t *address); - - /** Request reception of all multicast packets - * - * @param all True to receive all multicasts - * False to receive only multicasts addressed to specified groups - */ - virtual void set_all_multicast(bool all); - - /** Sets memory manager that is used to handle memory buffers - * - * @param mem_mngr Pointer to memory manager - */ - virtual void set_memory_manager(EMACMemoryManager &mem_mngr); - - emac_link_input_cb_t emac_link_input_cb; /**< Callback for incoming data */ - emac_link_state_change_cb_t emac_link_state_cb; - EMACMemoryManager *memory_manager; - -}; - -#endif /* WICED_EMAC_H_ */ diff --git a/tools/cmake/README.md b/tools/cmake/README.md index dc1240f..cc80b5f 100644 --- a/tools/cmake/README.md +++ b/tools/cmake/README.md @@ -34,7 +34,6 @@ - Silicon Labs targets - STM targets - Toshiba targets -- WICED targets ### Supported toolchains