The easy-connect library for GR-PEACH.

Dependencies:   LWIPBP3595Interface_STA_for_mbed-os

Dependents:   GR-PEACH_HVC-P2_sample_client GR-PEACH_HVC-P2_IoTPlatform_http GR-PEACH_IoT_Platform_HTTP_sample

Specifying connectivity method

Add the following to your mbed_app.json file:

mbed_app.json

{
    "config": {
        "network-interface":{
            "help": "Options are ETHERNET, WIFI_ESP8266, WIFI_BP3595",
            "value": "ETHERNET"
        }
    }
}

To specify MAC address, add fllowing function to main.cpp. (When using Wifi, setting of MAC address is not necessary.)

Specify MAC address

// set mac address
void mbed_mac_address(char *mac) {
    mac[0] = 0x00;
    mac[1] = 0x02;
    mac[2] = 0xF7;
    mac[3] = 0xF0;
    mac[4] = 0x00;
    mac[5] = 0x00;
}


Wifi settings

If you choose BP3595, you'll also need to add the WiFi SSID, password and security type:

mbed_app.json

{
    "config": {
        "network-interface":{
            "help": "Options are ETHERNET, WIFI_ESP8266, WIFI_BP3595",
            "value": "WIFI_BP3595"
        },
        "wifi-ssid": {
            "help": "WiFi SSID",
            "value": "\"SSID\""
        },
        "wifi-password": {
            "help": "WIFI Password",
            "value": "\"Password\""
        },
        "wifi-security":{
            "help": "Options are NSAPI_SECURITY_WEP, NSAPI_SECURITY_WPA, NSAPI_SECURITY_WPA2, NSAPI_SECURITY_WPA_WPA2",
            "value": "NSAPI_SECURITY_WPA_WPA2"
        }
    }
}


Using Easy Connect from your application

Easy Connect has just one function which will either return a NetworkInterface-pointer or NULL:

main.cpp

#include "easy-connect.h"
 
int main(int, char**) {
    NetworkInterface* network = easy_connect(true); /* has 1 argument, enable_logging (pass in true to log to serial port) */
    if (!network) {
        printf("Connecting to the network failed... See serial output.\r\n");
        return 1;
    }
 
    // Rest of your program
}

Files at this revision

API Documentation at this revision

Comitter:
dkato
Date:
Tue Mar 28 09:52:02 2017 +0000
Parent:
1:adf177867e43
Commit message:
Update library

Changed in this revision

LWIPBP3595Interface_STA_for_mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
diff -r adf177867e43 -r 34fe4f11941d LWIPBP3595Interface_STA_for_mbed-os.lib
--- a/LWIPBP3595Interface_STA_for_mbed-os.lib	Tue Mar 14 05:41:15 2017 +0000
+++ b/LWIPBP3595Interface_STA_for_mbed-os.lib	Tue Mar 28 09:52:02 2017 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/users/dkato/code/LWIPBP3595Interface_STA_for_mbed-os/#7f296a8b4b11
+https://developer.mbed.org/users/dkato/code/LWIPBP3595Interface_STA_for_mbed-os/#6bd475023468