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