PGO6

Dependencies:   MQTT

Committer:
s0130594
Date:
Thu Nov 14 15:07:12 2019 +0100
Revision:
6:754d3e8f9ae9
Parent:
5:2ce5049b9c14
Added MQTT functionality

Who changed what in which revision?

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