Murata TypeYD - FluentLogger example.

Dependencies:   FluentLogger SNICInterface mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
YuuichiAkagawa
Date:
Wed Dec 24 10:48:07 2014 +0000
Commit message:
Initial release

Changed in this revision

FluentLogger.lib Show annotated file Show diff for this revision Revisions of this file
SNICInterface.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 80f672a5e7e3 FluentLogger.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FluentLogger.lib	Wed Dec 24 10:48:07 2014 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/YuuichiAkagawa/code/FluentLogger/#6b1268731465
diff -r 000000000000 -r 80f672a5e7e3 SNICInterface.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SNICInterface.lib	Wed Dec 24 10:48:07 2014 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/murata/code/SNICInterface/#d80bbb12ffe6
diff -r 000000000000 -r 80f672a5e7e3 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Dec 24 10:48:07 2014 +0000
@@ -0,0 +1,94 @@
+/* SNIC-FluentLogger-example - fluent-logger-mbed sample
+ *  Copyright (C) 2014 Yuuichi Akagawa
+ *  muRata, SWITCH SCIENCE Wi-FI module TypeYD SNIC-UART.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "mbed.h"
+#include "SNIC_WifiInterface.h"
+#include "FluentLogger.h"
+
+/* Please set your WiFi settings */
+#define DEMO_AP_SSID                  "AP_SSID"
+#define DEMO_AP_SECURITY_TYPE         e_SEC_WPA2_AES
+#define DEMO_AP_SECUTIRY_KEY          "WPA2_PASSPHRASE"
+#define DEMO_AP_SECUTIRY_KEY_LEN      15
+
+/** Wi-Fi SNIC UART Interface*/
+#if defined(TARGET_LPC1768)
+C_SNIC_WifiInterface     mSNICwifi( p9, p10, NC, NC, p30 );
+#elif defined(TARGET_KL46Z)
+C_SNIC_WifiInterface     mSNICwifi( D1, D0, NC, NC, D3 );
+#elif defined(TARGET_RZ_A1H)
+C_SNIC_WifiInterface     mSNICwifi( P7_4, P7_5, NC, NC, P7_2 );
+#else
+#error Your platform is not supported.
+#endif
+
+/* fluentd server */
+FluentLogger logger("192.168.0.1");
+
+Serial pc(USBTX, USBRX);    /* for DEBUG_PRINT */
+
+int main()
+{
+    uMP mp(64); //Message body
+
+#ifdef _DEBUG
+    pc.baud( 9600 );
+#endif
+    // Initialize Wi-Fi interface
+    int ret = mSNICwifi.init();
+    if( ret != 0 ) {
+        DEBUG_PRINT( "Could not initialize. Will halt! rc=%d\n\r", ret );
+        return -1;
+    } else {
+        DEBUG_PRINT( "Initialized.\n\r");
+    }
+
+    wait(0.5);
+
+    ret = mSNICwifi.disconnect();
+    if( ret != 0 ) {
+        DEBUG_PRINT( "Disconnect failed rc=%d\r\n", ret);
+        return -1;
+    } else {
+        DEBUG_PRINT( "Disconnected.\n\r");
+    }
+    
+    wait(0.3);
+
+    // Connect AP
+    ret = mSNICwifi.connect( DEMO_AP_SSID
+                        , strlen(DEMO_AP_SSID)
+                        , DEMO_AP_SECURITY_TYPE
+                        , DEMO_AP_SECUTIRY_KEY
+                        , DEMO_AP_SECUTIRY_KEY_LEN );
+    if( ret != 0 ) {
+        DEBUG_PRINT( "Connect failed rc=%d\r\n", ret);
+        return -1;
+    } else {
+        DEBUG_PRINT( "Connected.\n\r");
+    }
+
+    //DHCP
+    mSNICwifi.setIPConfig( true );
+
+    wait(0.5);
+
+    while(1) {
+        //send to fluentd
+        logger.log("debug.mbed", "Hello Type YD"); //message body is simple string
+        wait_ms(3000);
+    }
+}
diff -r 000000000000 -r 80f672a5e7e3 mbed-rtos.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Wed Dec 24 10:48:07 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#13a25134ac60
diff -r 000000000000 -r 80f672a5e7e3 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Dec 24 10:48:07 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5
\ No newline at end of file