ST
/
example-IDW01M1-mbed-Cloud-connect
Generic example for any board with IDMW0xM1 shield
Diff: main.cpp
- Revision:
- 42:cddcdf68386d
- Parent:
- 40:17cd01e5f1fa
- Child:
- 44:1d5e5eb2d2fb
diff -r ab6810e0e25d -r cddcdf68386d main.cpp --- a/main.cpp Mon May 07 09:58:35 2018 +0200 +++ b/main.cpp Mon May 07 10:05:40 2018 +0200 @@ -26,9 +26,6 @@ // This is great because things such as network operations are illegal in ISR, so updating a resource in a button's fall() function is not allowed EventQueue eventQueue; -// Instanziate Wi-Fi device -SpwfSAInterface wifi(MBED_CONF_APP_WIFI_TX, MBED_CONF_APP_WIFI_RX); - // Storage implementation definition, currently using SDBlockDevice (SPI flash, DataFlash, and internal flash are also available) SDBlockDevice sd(SPI_MOSI, SPI_MISO, SPI_SCK, SPI_CS); FATFileSystem fs("sd", &sd); @@ -65,7 +62,9 @@ void blink_callback(MbedCloudClientResource *resource, const uint8_t *buffer, uint16_t size) { printf("POST received. Going to blink LED pattern: %s\n", pattern_res->get_value().c_str()); - static DigitalOut augmentedLed(LED1); // LED that is used for blinking the pattern + static DigitalOut augmentedLed(NC); // LED that is used for blinking the pattern + // betzw - NOTE: `LED1` conflicts with SPI clock, + // therefore switching of blinking using `NC` // Parse the pattern string, and toggle the LED in that pattern string s = std::string(pattern_res->get_value().c_str()); @@ -104,10 +103,11 @@ int main(void) { printf("Starting Simple Mbed Cloud Client example\n"); - printf("Connecting to the network using Ethernet...\n"); + printf("Connecting to the network using WiFi...\n"); // Connect to the internet (DHCP is expected to be on) - nsapi_error_t status = wifi.connect(); + static SpwfSAInterface wifi(MBED_CONF_APP_WIFI_TX, MBED_CONF_APP_WIFI_RX); + nsapi_error_t status = wifi.connect(MBED_CONF_APP_WIFI_SSID, MBED_CONF_APP_WIFI_PASSWORD, NSAPI_SECURITY_WPA_WPA2); if (status != 0) { printf("Connecting to the network failed %d!\n", status);