Mbed Cloud example program for workshop in W27 2018.

Dependencies:   MMA7660 LM75B

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers easy-connect.h Source File

easy-connect.h

00001 /*
00002  * FILE: easy-connect.h
00003  *
00004  * Copyright (c) 2015 - 2017 ARM Limited. All rights reserved.
00005  * SPDX-License-Identifier: Apache-2.0
00006  * Licensed under the Apache License, Version 2.0 (the License); you may
00007  * not use this file except in compliance with the License.
00008  * You may obtain a copy of the License at
00009  *
00010  * http://www.apache.org/licenses/LICENSE-2.0
00011  *
00012  * Unless required by applicable law or agreed to in writing, software
00013  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
00014  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015  * See the License for the specific language governing permissions and
00016  * limitations under the License.
00017  */
00018 #ifndef __EASY_CONNECT_H__
00019 #define __EASY_CONNECT_H__
00020 
00021 #include "mbed.h"
00022 
00023 #define ETHERNET          1
00024 #define WIFI_ESP8266      11
00025 #define WIFI_ODIN         12
00026 #define WIFI_RTW          13
00027 #define WIFI_IDW0XX1      14
00028 #define WIFI_WIZFI310     15
00029 #define WIFI_ISM43362     16
00030 #define MESH_LOWPAN_ND    101
00031 #define MESH_THREAD       102
00032 #define CELLULAR_ONBOARD  201
00033 #define CELLULAR          202
00034 #define CELLULAR_WNC14A2A 203
00035 
00036 /* Define supersets for WiFi and Mesh */
00037 
00038 #if MBED_CONF_APP_NETWORK_INTERFACE == WIFI_ESP8266
00039 #define EASY_CONNECT_WIFI
00040 
00041 #elif MBED_CONF_APP_NETWORK_INTERFACE == WIFI_ODIN
00042 #define EASY_CONNECT_WIFI
00043 
00044 #elif MBED_CONF_APP_NETWORK_INTERFACE == WIFI_RTW
00045 #define EASY_CONNECT_WIFI
00046 
00047 #elif MBED_CONF_APP_NETWORK_INTERFACE == WIFI_IDW0XX1
00048 #define EASY_CONNECT_WIFI
00049 
00050 #elif MBED_CONF_APP_NETWORK_INTERFACE == WIFI_WIZFI310
00051 #define EASY_CONNECT_WIFI
00052 
00053 #elif MBED_CONF_APP_NETWORK_INTERFACE == WIFI_ISM43362
00054 #define EASY_CONNECT_WIFI
00055 
00056 #elif MBED_CONF_APP_NETWORK_INTERFACE == MESH_LOWPAN_ND
00057 #define EASY_CONNECT_MESH
00058 
00059 #elif MBED_CONF_APP_NETWORK_INTERFACE == MESH_THREAD
00060 #define EASY_CONNECT_MESH
00061 #endif // MBED_CONF_APP_NETWORK_INTERFACE
00062 
00063 #if defined(EASY_CONNECT_MESH)
00064 
00065 // Define macros for radio type
00066 #define ATMEL   1
00067 #define MCR20   2
00068 #define SPIRIT1 3
00069 #define EFR32   4
00070 
00071 // This is address to mbed Device Connector (hard-coded IP due to DNS might not be there)
00072 #define MBED_SERVER_ADDRESS "coaps://[2607:f0d0:2601:52::20]:5684"
00073 
00074 #else
00075 // This is address to mbed Device Connector
00076 #define MBED_SERVER_ADDRESS "coap://api.connector.mbed.com:5684"
00077 
00078 #endif // (EASY_CONNECT_MESH)
00079 
00080 /* \brief print_MAC - print_MAC  - helper function to print out MAC address
00081  * in: network_interface - pointer to network i/f
00082  *     bool log-messages   print out logs or not
00083  * MAC address is print, if it can be acquired & log_messages is true.
00084  *
00085  */
00086 void print_MAC(NetworkInterface* network_interface, bool log_messages);
00087 
00088 
00089 /* \brief easy_connect - easy_connect function to connect the pre-defined network bearer,
00090  *                       config done via mbed_app.json (see README.md for details).
00091  * IN: bool  log_messages  print out diagnostics or not.
00092  */
00093 NetworkInterface* easy_connect(bool log_messages = false);
00094 
00095 /* \brief easy_connect - easy_connect function to connect the pre-defined network bearer,
00096  *                       config done via mbed_app.json (see README.md for details).
00097  * IN: bool  log_messages  print out diagnostics or not.
00098  *     char* WiFiSSID      WiFi SSID - by default NULL, but if it's NULL
00099  *                         then MBED_CONF_APP_WIFI_SSID will be used
00100  *     char* WiFiPassword  WiFi Password - by default NULL, but if it's NULL
00101  *                         then MBED_CONF_APP_WIFI_PASSWORD will be used
00102  */
00103 NetworkInterface* easy_connect(bool log_messages,
00104                                char* WiFiSSID,
00105                                char* WiFiPassword);
00106 
00107 /* \brief easy_get_netif - easy_connect function to get pointer to network interface w/o connect it.
00108                            You might need this for example getting the WiFi interface, then doing a scan
00109                            and then connecting to one of the SSIDs found with a password end user supplies.
00110  * IN: bool  log_messages  print out diagnostics or not.
00111  */
00112 
00113 NetworkInterface* easy_get_netif(bool log_messages);
00114 /* \brief easy_get_wifi - easy_connect function to get pointer to Wifi interface 
00115  *                        without connecting to it. You would want this 1st so that
00116  *                        you can scan the APNs, choose the right one and then connect.
00117  *
00118  * IN: bool  log_messages  print out diagnostics or not.
00119  */
00120 WiFiInterface* easy_get_wifi(bool log_messages);
00121 
00122 #endif // __EASY_CONNECT_H__