Demo application of SNICInterface library for Murata TypeYD, which reports sensor data periodically to Xively cloud server . Hardware platform: mbed application board (https://mbed.org/cookbook/mbed-application-board), mbed LPC1768 (https://mbed.org/platforms/mbed-LPC1768/) and TypeYD.
Dependencies: C12832 LM75B MMA7660 SNICInterface libxively mbed-rtos mbed
Diff: main.cpp
- Revision:
- 14:6d58d3855feb
- Parent:
- 11:bdf601a405fc
- Child:
- 15:abc12b228291
--- a/main.cpp Fri Nov 08 16:57:17 2013 +0000
+++ b/main.cpp Mon May 26 06:28:29 2014 +0000
@@ -1,8 +1,8 @@
#include "mbed.h"
-#include "EthernetInterface.h"
+#include "SNIC_WifiInterface.h"
-#define XI_FEED_ID 128488 // set Xively Feed ID (numerical, no quoutes)
-#define XI_API_KEY "T4KXAH_dasgw1PWBPc3fdsfsdgsdy-dUc4ND0g" // set Xively API key (double-quoted string)
+#define XI_FEED_ID 1056160623 // set Xively Feed ID (numerical, no quoutes)
+#define XI_API_KEY "Wg7CfZDrj7VjIIpiYzdDrMow6wdENAOGjkIfQ0fUjJh6DAw2" // set Xively API key (double-quoted string)
#include "app_board_io.h"
@@ -19,30 +19,61 @@
#include "logo.h"
+#if 0
+#define DEMO_AP_SSID "HWD11_E8088BD5E3A8"
+#define DEMO_AP_SECURITY_TYPE e_SEC_WPA2_AES
+#define DEMO_AP_SECUTIRY_KEY "aArGrg303DG5HA9"
+#define DEMO_AP_SECUTIRY_KEY_LEN 15
+#else
+//#define DEMO_AP_SSID "muRata1"
+//#define DEMO_AP_SECURITY_TYPE e_SEC_WPA2_AES
+//#define DEMO_AP_SECUTIRY_KEY "12345678"
+//#define DEMO_AP_SECUTIRY_KEY_LEN 8
+
+#define DEMO_AP_SSID "Test"
+#define DEMO_AP_SECURITY_TYPE e_SEC_WPA2_AES
+#define DEMO_AP_SECUTIRY_KEY "eightspot"
+#define DEMO_AP_SECUTIRY_KEY_LEN 9
+#endif
+/** Wi-Fi SNIC UART Interface*/
+C_SNIC_WifiInterface mSNICwifi( p9, p10, NC, NC, p30 );
+Serial pc(USBTX, USBRX);
+
int main() {
+ pc.baud( 115200 );
+ printf("main\r\n");
lcd_print_xively_logo();
- EthernetInterface eth;
- int s = eth.init(); //Use DHCP
+ // Initialize Wi-Fi interface
+ int s = mSNICwifi.init();
- if( s != NULL )
+ lcd_printf("init();\r\n");
+
+ if( s != 0 )
{
lcd_printf( "Could not initialise. Will halt!\n" );
- exit( 0 );
+ return -1;
}
- s = eth.connect();
+ wait(0.5);
+ mSNICwifi.disconnect();
+ lcd_printf("disconnect();\r\n");
- if( s != NULL )
+ wait(0.5);
+ // Connect AP
+ s = mSNICwifi.connect( DEMO_AP_SSID
+ , strlen(DEMO_AP_SSID)
+ , DEMO_AP_SECURITY_TYPE
+ , DEMO_AP_SECUTIRY_KEY
+ , DEMO_AP_SECUTIRY_KEY_LEN );
+ lcd_printf("connect();\r\n");
+ if( s != 0 )
{
lcd_printf( "Could not connect. Will halt!\n" );
- exit( 0 );
+ return -1;
}
- else
- {
- lcd_printf( "IP: %s\n", eth.getIPAddress() );
- }
-
+ wait(0.5);
+
xi_feed_t feed;
memset( &feed, NULL, sizeof( xi_feed_t ) );
@@ -112,6 +143,6 @@
xi_feed_update( xi_context, &feed );
lcd_printf( "done...\n" );
- wait( 15.0 );
+ wait( 1.0 );
}
}
muRata
Murata TypeYD