Mbed Cloud Example Project - LPC546xx (Completed Version)

Fork of mbed-cloud-example-lpc546xx by Clark Jarvis

Revision:
10:f30cd412e968
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Bonus_Code_Additions_Accel.txt	Thu Oct 11 18:59:07 2018 +0000
@@ -0,0 +1,34 @@
+Bonus Lab Steps
+
+Add the X-Value of the onboard Acceleromter
+Requires importing the MMA8652 library into project
+https://os.mbed.com/components/MMA8652-Accelerometer/
+
+
+// Include MMA8652 header file
+#include "MMA8652.h"
+
+
+// Create an instantiation of the accelerometer
+MMA8652 acc(P3_23, P3_24);
+
+// Add an empty callback to support the observability of the GET request
+void accel_callback(const M2MBase& object, const NoticationDeliveryStatus status){}
+
+// Add Mbed Cloud Client Resource
+MbedCloudClientResource *accel = mbedClient.create_resource("3313/0/5702", "accel_resource"); // Accelerometer / Instance / X Value
+accel->set_value("0");
+accel->methods(M2MMethod::GET);
+accel->observable(true);
+accel->attach_notification_callback(accel_callback);
+    
+    
+// Add local variables to main() to handle storing accelerometer data
+float acc_data[3];
+char buffer[10];
+
+
+// Add code to main while loop to periodically read and set accelerometer data
+acc.ReadXYZ(acc_data);
+int size = snprintf(buffer,10,"%1.4f",acc_data[0]);
+accel->set_value(buffer);
\ No newline at end of file