Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BSP_B-L475E-IOT01
Revision 39:8990b0ce7233, committed 2018-11-27
- Comitter:
- JunkoNakajima
- Date:
- Tue Nov 27 06:35:39 2018 +0000
- Parent:
- 38:4bdc241ba9a6
- Commit message:
- first version
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BSP_B-L475E-IOT01.lib Tue Nov 27 06:35:39 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/ST/code/BSP_B-L475E-IOT01/#0c70bc6d2dc0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os-treasuredata-rest.lib Tue Nov 27 06:35:39 2018 +0000 @@ -0,0 +1,1 @@ +https://github.com/BlackstoneEngineering/mbed-os-treasuredata-rest/#e9899898b5e7f2bc58f123825e67425ac1430a0b
--- a/mbed_app.json Wed Jul 26 14:47:11 2017 +0200
+++ b/mbed_app.json Tue Nov 27 06:35:39 2018 +0000
@@ -1,16 +1,34 @@
{
+ "macros": [ "MBED_ALL_STATS_ENABLED"],
+ "config": {
+ "wifi-shield": {
+ "help": "Options are internal, WIFI_ESP8266, WIFI_IDW0XX1",
+ "value": "WIFI_ISM43362"
+ },
+ "wifi-ssid": {
+ "help": "WiFi SSID",
+ "value": "\"SSID\""
+ },
+ "wifi-password": {
+ "help": "WiFi Password",
+ "value": "\"PASSWORD\""
+ },
+ "api-key":{
+ "help": "REST API Key for Treasure Data",
+ "value": "\"WRITE API KEY\""
+ },
+ "thread-stack-size": {
+ "value": 2000
+ }
+ },
"target_overrides": {
- "K64F": {
- "target.features_add": ["BLE"],
- "target.extra_labels_add": ["ST_BLUENRG"]
- },
- "NUCLEO_F401RE": {
- "target.features_add": ["BLE"],
- "target.extra_labels_add": ["ST_BLUENRG"]
- },
"DISCO_L475VG_IOT01A": {
"target.features_add": ["BLE"],
"target.extra_labels_add": ["ST_BLUENRG"]
- }
+ },
+ "*": {
+ "platform.stdio-convert-newlines": true
+ }
}
}
+
--- a/source/main.cpp Wed Jul 26 14:47:11 2017 +0200
+++ b/source/main.cpp Tue Nov 27 06:35:39 2018 +0000
@@ -16,18 +16,41 @@
#include <events/mbed_events.h>
#include <mbed.h>
+#include "mbed.h"
+#include "TCPSocket.h"
+#include "wifi-ism43362/ISM43362Interface.h"
+#include "treasure-data-rest.h"
#include "ble/BLE.h"
#include "LEDService.h"
+#define BUFF_SIZE 200
DigitalOut alivenessLED(LED1, 0);
DigitalOut actuatedLED(LED2, 0);
+ISM43362Interface net;
+LEDService *ledServicePtr;
const static char DEVICE_NAME[] = "LED";
static const uint16_t uuid16_list[] = {LEDService::LED_SERVICE_UUID};
+static EventQueue eventQueue(/* event count */ 10 * EVENTS_EVENT_SIZE);
+char payload_buff [BUFF_SIZE] = {0};
+int x = 0;
+TreasureData_RESTAPI* payload = new TreasureData_RESTAPI(&net,"iot_test","payload", MBED_CONF_APP_API_KEY);
-static EventQueue eventQueue(/* event count */ 10 * EVENTS_EVENT_SIZE);
+void ConnectToWifi(){
+ // Connect to Wifi
+ printf("\nConnecting to %s...\n", MBED_CONF_APP_WIFI_SSID);
+ int ret = net.connect(MBED_CONF_APP_WIFI_SSID, MBED_CONF_APP_WIFI_PASSWORD, NSAPI_SECURITY_WPA_WPA2);
+ if (ret != 0) {
+ printf("\nConnection error: %d\n", ret);
+ }
-LEDService *ledServicePtr;
+ printf("Success\n\n");
+ printf("MAC: %s\n", net.get_mac_address());
+ printf("IP: %s\n", net.get_ip_address());
+ printf("Netmask: %s\n", net.get_netmask());
+ printf("Gateway: %s\n", net.get_gateway());
+ printf("RSSI: %d\n\n", net.get_rssi());
+}
void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *params)
{
@@ -49,6 +72,13 @@
void onDataWrittenCallback(const GattWriteCallbackParams *params) {
if ((params->handle == ledServicePtr->getValueHandle()) && (params->len == 1)) {
actuatedLED = *(params->data);
+ // Construct strings to send
+ x = sprintf(payload_buff,"{\"payload\":\"%u\"}", *(params->data));
+ payload_buff[x]=0; // null terminate the string
+
+ // Send data to Treasure data
+ printf("\r\n Sending Payload: '%s'\r\n",payload_buff);
+ payload->sendData(payload_buff,strlen(payload_buff));
}
}
@@ -97,12 +127,15 @@
void scheduleBleEventsProcessing(BLE::OnEventsToProcessCallbackContext* context) {
BLE &ble = BLE::Instance();
eventQueue.call(Callback<void()>(&ble, &BLE::processEvents));
+
}
int main()
{
+ ConnectToWifi();
+
eventQueue.call_every(500, blinkCallback);
-
+
BLE &ble = BLE::Instance();
ble.onEventsToProcess(scheduleBleEventsProcessing);
ble.init(bleInitComplete);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wifi-ism43362.lib Tue Nov 27 06:35:39 2018 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/wifi-ism43362/#9ee7fb19814e46b6e90b1eaec26ef36b523ec024