For MAX32630FTHR Demo Board: Controls LEDs on the demo board interfaced through BLE peripheral testing apps like LightBlue for iOS. Debug output on serial port.

Dependencies:   max32630fthr

Files at this revision

API Documentation at this revision

Comitter:
Lugs
Date:
Sat Nov 09 01:44:19 2019 +0000
Parent:
1:16c9c60e0b61
Commit message:
For MAX32630FTHR Demo Board:; Controls LEDs on the demo board using BLE GATT interfaced through BLE testing apps on phones (lightblue for iOS)

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
max32630fthr.lib Show annotated file Show diff for this revision Revisions of this file
shields/TARGET_ST_BLUENRG.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 16c9c60e0b61 -r efe8deed8f74 main.cpp
--- a/main.cpp	Wed Jun 20 12:00:27 2018 +0100
+++ b/main.cpp	Sat Nov 09 01:44:19 2019 +0000
@@ -28,6 +28,24 @@
 #include "ble/GattServer.h"
 #include "BLEProcess.h"
 
+#include "mbed.h"
+#include "max32630fthr.h"
+
+MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
+
+PwmOut PWM(P4_0);
+AnalogIn POT(AIN_0);
+DigitalOut rLED(LED1);
+DigitalOut gLED(LED2);
+DigitalOut bLED(LED3);
+DigitalIn Button(P2_3);
+
+DigitalOut dbled1(P5_6);
+DigitalOut dbled2(P5_5);
+DigitalOut dbled3(P5_4);
+DigitalOut dbled4(P5_3);
+
+
 using mbed::callback;
 
 /**
@@ -100,11 +118,6 @@
         _server->onConfirmationReceived(as_cb(&Self::when_confirmation_received));
 
         // print the handles
-        printf("clock service registered\r\n");
-        printf("service handle: %u\r\n", _clock_service.getHandle());
-        printf("\thour characteristic value handle %u\r\n", _hour_char.getValueHandle());
-        printf("\tminute characteristic value handle %u\r\n", _minute_char.getValueHandle());
-        printf("\tsecond characteristic value handle %u\r\n", _second_char.getValueHandle());
 
         _event_queue->call_every(1000 /* ms */, callback(this, &Self::increment_second));
     }
@@ -124,25 +137,26 @@
      */
     void when_data_written(const GattWriteCallbackParams *e)
     {
-        printf("data written:\r\n");
-        printf("\tconnection handle: %u\r\n", e->connHandle);
-        printf("\tattribute handle: %u", e->handle);
-        if (e->handle == _hour_char.getValueHandle()) {
-            printf(" (hour characteristic)\r\n");
-        } else if (e->handle == _minute_char.getValueHandle()) {
-            printf(" (minute characteristic)\r\n");
-        } else if (e->handle == _second_char.getValueHandle()) {
-            printf(" (second characteristic)\r\n");
-        } else {
-            printf("\r\n");
-        }
-        printf("\twrite operation: %u\r\n", e->writeOp);
-        printf("\toffset: %u\r\n", e->offset);
-        printf("\tlength: %u\r\n", e->len);
-        printf("\t data: ");
+        printf("data written from phone.\r\n");
 
         for (size_t i = 0; i < e->len; ++i) {
-            printf("%02X", e->data[i]);
+            printf("%02X:", e->data[i]);
+        }
+        
+        switch(e->data[0])
+        {
+            case 1:
+                dbled1 = !dbled1;
+                break;
+            case 2:
+                dbled2 = !dbled2;
+                break;
+            case 3:
+                dbled3 = !dbled3;
+                break;
+            case 4:
+                dbled4 = !dbled4;
+                break;
         }
 
         printf("\r\n");
@@ -153,18 +167,7 @@
      */
     void when_data_read(const GattReadCallbackParams *e)
     {
-        printf("data read:\r\n");
-        printf("\tconnection handle: %u\r\n", e->connHandle);
-        printf("\tattribute handle: %u", e->handle);
-        if (e->handle == _hour_char.getValueHandle()) {
-            printf(" (hour characteristic)\r\n");
-        } else if (e->handle == _minute_char.getValueHandle()) {
-            printf(" (minute characteristic)\r\n");
-        } else if (e->handle == _second_char.getValueHandle()) {
-            printf(" (second characteristic)\r\n");
-        } else {
-            printf("\r\n");
-        }
+        printf("Data was read.\r\n");
     }
 
     /**
@@ -393,6 +396,8 @@
 };
 
 int main() {
+    printf("\f---MAX32630FTHR BLE DEMO---\r\n");
+    
     BLE &ble_interface = BLE::Instance();
     events::EventQueue event_queue;
     ClockService demo_service;
diff -r 16c9c60e0b61 -r efe8deed8f74 max32630fthr.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/max32630fthr.lib	Sat Nov 09 01:44:19 2019 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/MaximIntegrated/code/max32630fthr/#8f6e6a800f2f
diff -r 16c9c60e0b61 -r efe8deed8f74 shields/TARGET_ST_BLUENRG.lib
--- a/shields/TARGET_ST_BLUENRG.lib	Wed Jun 20 12:00:27 2018 +0100
+++ b/shields/TARGET_ST_BLUENRG.lib	Sat Nov 09 01:44:19 2019 +0000
@@ -1,2 +1,1 @@
-
-https://github.com/ARMmbed/ble-x-nucleo-idb0xa1/#b630517008bbe47592927cc8e5dfcd2e5b9de968
\ No newline at end of file
+https://github.com/ARMmbed/ble-x-nucleo-idb0xa1/#b630517008bbe47592927cc8e5dfcd2e5b9de968