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
}

Tags

2017-03-28 tip Revision History Files