Modified version of easy-connect for W5500 Ethernet components

Dependents:   http-webserver-example mbed-os-example-sockets

Fork of easy-connect by Sergei G

Committer:
Bongjun
Date:
Mon Aug 13 08:59:16 2018 +0000
Revision:
7:15287721e11b
Parent:
1:5af739d06652
moved to init mac and dhcp functions into W5500Interface

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Bongjun 1:5af739d06652 1 /*
Bongjun 1:5af739d06652 2 * FILE: easy-connect.h
Bongjun 1:5af739d06652 3 *
Bongjun 1:5af739d06652 4 * Copyright (c) 2015 - 2017 ARM Limited. All rights reserved.
Bongjun 1:5af739d06652 5 * SPDX-License-Identifier: Apache-2.0
Bongjun 1:5af739d06652 6 * Licensed under the Apache License, Version 2.0 (the License); you may
Bongjun 1:5af739d06652 7 * not use this file except in compliance with the License.
Bongjun 1:5af739d06652 8 * You may obtain a copy of the License at
Bongjun 1:5af739d06652 9 *
Bongjun 1:5af739d06652 10 * http://www.apache.org/licenses/LICENSE-2.0
Bongjun 1:5af739d06652 11 *
Bongjun 1:5af739d06652 12 * Unless required by applicable law or agreed to in writing, software
Bongjun 1:5af739d06652 13 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
Bongjun 1:5af739d06652 14 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Bongjun 1:5af739d06652 15 * See the License for the specific language governing permissions and
Bongjun 1:5af739d06652 16 * limitations under the License.
Bongjun 1:5af739d06652 17 */
Bongjun 1:5af739d06652 18 #ifndef __EASY_CONNECT_H__
Bongjun 1:5af739d06652 19 #define __EASY_CONNECT_H__
Bongjun 1:5af739d06652 20
Bongjun 1:5af739d06652 21 #include "mbed.h"
Bongjun 1:5af739d06652 22
Bongjun 1:5af739d06652 23 #define ETHERNET 1
Bongjun 1:5af739d06652 24 #define ETHERNET_W5500 2
Bongjun 1:5af739d06652 25 #define WIFI_ESP8266 11
Bongjun 1:5af739d06652 26 #define WIFI_ODIN 12
Bongjun 1:5af739d06652 27 #define WIFI_RTW 13
Bongjun 1:5af739d06652 28 #define WIFI_IDW0XX1 14
Bongjun 1:5af739d06652 29 #define WIFI_WIZFI310 15
Bongjun 1:5af739d06652 30 #define WIFI_ISM43362 16
Bongjun 1:5af739d06652 31 #define MESH_LOWPAN_ND 101
Bongjun 1:5af739d06652 32 #define MESH_THREAD 102
Bongjun 1:5af739d06652 33 #define CELLULAR_ONBOARD 201
Bongjun 1:5af739d06652 34 #define CELLULAR 202
Bongjun 1:5af739d06652 35 #define CELLULAR_WNC14A2A 203
Bongjun 1:5af739d06652 36
Bongjun 1:5af739d06652 37 /* Define supersets for WiFi and Mesh */
Bongjun 1:5af739d06652 38
Bongjun 1:5af739d06652 39 #if MBED_CONF_APP_NETWORK_INTERFACE == WIFI_ESP8266
Bongjun 1:5af739d06652 40 #define EASY_CONNECT_WIFI
Bongjun 1:5af739d06652 41
Bongjun 1:5af739d06652 42 #elif MBED_CONF_APP_NETWORK_INTERFACE == WIFI_ODIN
Bongjun 1:5af739d06652 43 #define EASY_CONNECT_WIFI
Bongjun 1:5af739d06652 44
Bongjun 1:5af739d06652 45 #elif MBED_CONF_APP_NETWORK_INTERFACE == WIFI_RTW
Bongjun 1:5af739d06652 46 #define EASY_CONNECT_WIFI
Bongjun 1:5af739d06652 47
Bongjun 1:5af739d06652 48 #elif MBED_CONF_APP_NETWORK_INTERFACE == WIFI_IDW0XX1
Bongjun 1:5af739d06652 49 #define EASY_CONNECT_WIFI
Bongjun 1:5af739d06652 50
Bongjun 1:5af739d06652 51 #elif MBED_CONF_APP_NETWORK_INTERFACE == WIFI_WIZFI310
Bongjun 1:5af739d06652 52 #define EASY_CONNECT_WIFI
Bongjun 1:5af739d06652 53
Bongjun 1:5af739d06652 54 #elif MBED_CONF_APP_NETWORK_INTERFACE == WIFI_ISM43362
Bongjun 1:5af739d06652 55 #define EASY_CONNECT_WIFI
Bongjun 1:5af739d06652 56
Bongjun 1:5af739d06652 57 #elif MBED_CONF_APP_NETWORK_INTERFACE == MESH_LOWPAN_ND
Bongjun 1:5af739d06652 58 #define EASY_CONNECT_MESH
Bongjun 1:5af739d06652 59
Bongjun 1:5af739d06652 60 #elif MBED_CONF_APP_NETWORK_INTERFACE == MESH_THREAD
Bongjun 1:5af739d06652 61 #define EASY_CONNECT_MESH
Bongjun 1:5af739d06652 62 #endif // MBED_CONF_APP_NETWORK_INTERFACE
Bongjun 1:5af739d06652 63
Bongjun 1:5af739d06652 64 #if defined(EASY_CONNECT_MESH)
Bongjun 1:5af739d06652 65
Bongjun 1:5af739d06652 66 // Define macros for radio type
Bongjun 1:5af739d06652 67 #define ATMEL 1
Bongjun 1:5af739d06652 68 #define MCR20 2
Bongjun 1:5af739d06652 69 #define SPIRIT1 3
Bongjun 1:5af739d06652 70 #define EFR32 4
Bongjun 1:5af739d06652 71
Bongjun 1:5af739d06652 72 // This is address to mbed Device Connector (hard-coded IP due to DNS might not be there)
Bongjun 1:5af739d06652 73 #define MBED_SERVER_ADDRESS "coaps://[2607:f0d0:2601:52::20]:5684"
Bongjun 1:5af739d06652 74
Bongjun 1:5af739d06652 75 #else
Bongjun 1:5af739d06652 76 // This is address to mbed Device Connector
Bongjun 1:5af739d06652 77 #define MBED_SERVER_ADDRESS "coap://api.connector.mbed.com:5684"
Bongjun 1:5af739d06652 78
Bongjun 1:5af739d06652 79 #endif // (EASY_CONNECT_MESH)
Bongjun 1:5af739d06652 80
Bongjun 1:5af739d06652 81 /* \brief print_MAC - print_MAC - helper function to print out MAC address
Bongjun 1:5af739d06652 82 * in: network_interface - pointer to network i/f
Bongjun 1:5af739d06652 83 * bool log-messages print out logs or not
Bongjun 1:5af739d06652 84 * MAC address is print, if it can be acquired & log_messages is true.
Bongjun 1:5af739d06652 85 *
Bongjun 1:5af739d06652 86 */
Bongjun 1:5af739d06652 87 void print_MAC(NetworkInterface* network_interface, bool log_messages);
Bongjun 1:5af739d06652 88
Bongjun 1:5af739d06652 89
Bongjun 1:5af739d06652 90 /* \brief easy_connect - easy_connect function to connect the pre-defined network bearer,
Bongjun 1:5af739d06652 91 * config done via mbed_app.json (see README.md for details).
Bongjun 1:5af739d06652 92 * IN: bool log_messages print out diagnostics or not.
Bongjun 1:5af739d06652 93 */
Bongjun 1:5af739d06652 94 NetworkInterface* easy_connect(bool log_messages = false);
Bongjun 1:5af739d06652 95
Bongjun 1:5af739d06652 96 /* \brief easy_connect - easy_connect function to connect the pre-defined network bearer,
Bongjun 1:5af739d06652 97 * config done via mbed_app.json (see README.md for details).
Bongjun 1:5af739d06652 98 * IN: bool log_messages print out diagnostics or not.
Bongjun 1:5af739d06652 99 * char* WiFiSSID WiFi SSID - by default NULL, but if it's NULL
Bongjun 1:5af739d06652 100 * then MBED_CONF_APP_WIFI_SSID will be used
Bongjun 1:5af739d06652 101 * char* WiFiPassword WiFi Password - by default NULL, but if it's NULL
Bongjun 1:5af739d06652 102 * then MBED_CONF_APP_WIFI_PASSWORD will be used
Bongjun 1:5af739d06652 103 */
Bongjun 1:5af739d06652 104 NetworkInterface* easy_connect(bool log_messages,
Bongjun 1:5af739d06652 105 char* WiFiSSID,
Bongjun 1:5af739d06652 106 char* WiFiPassword);
Bongjun 1:5af739d06652 107
Bongjun 1:5af739d06652 108 /* \brief easy_get_netif - easy_connect function to get pointer to network interface w/o connect it.
Bongjun 1:5af739d06652 109 You might need this for example getting the WiFi interface, then doing a scan
Bongjun 1:5af739d06652 110 and then connecting to one of the SSIDs found with a password end user supplies.
Bongjun 1:5af739d06652 111 * IN: bool log_messages print out diagnostics or not.
Bongjun 1:5af739d06652 112 */
Bongjun 1:5af739d06652 113
Bongjun 1:5af739d06652 114 NetworkInterface* easy_get_netif(bool log_messages);
Bongjun 1:5af739d06652 115 /* \brief easy_get_wifi - easy_connect function to get pointer to Wifi interface
Bongjun 1:5af739d06652 116 * without connecting to it. You would want this 1st so that
Bongjun 1:5af739d06652 117 * you can scan the APNs, choose the right one and then connect.
Bongjun 1:5af739d06652 118 *
Bongjun 1:5af739d06652 119 * IN: bool log_messages print out diagnostics or not.
Bongjun 1:5af739d06652 120 */
Bongjun 1:5af739d06652 121 WiFiInterface* easy_get_wifi(bool log_messages);
Bongjun 1:5af739d06652 122
Bongjun 1:5af739d06652 123 #endif // __EASY_CONNECT_H__