ble

Dependencies:   HC_SR04_Ultrasonic_Library Servo mbed

Fork of FIP_REV1 by Robotique FIP

Files at this revision

API Documentation at this revision

Comitter:
julientiron
Date:
Thu Jul 09 13:33:36 2015 +0000
Parent:
3:829f081fde15
Commit message:
BLE

Changed in this revision

BLE_BlueNRG/btle/src/btle.cpp Show annotated file Show diff for this revision Revisions of this file
Servo.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
diff -r 829f081fde15 -r 69a35a56ac48 BLE_BlueNRG/btle/src/btle.cpp
--- a/BLE_BlueNRG/btle/src/btle.cpp	Tue May 19 20:42:25 2015 +0000
+++ b/BLE_BlueNRG/btle/src/btle.cpp	Thu Jul 09 13:33:36 2015 +0000
@@ -139,7 +139,7 @@
 {  
   tBleStatus ret;
   
-  const char local_name[] = {AD_TYPE_COMPLETE_LOCAL_NAME,'B','l','u','e','N','R','G', '1', '2'};
+  const char local_name[] = {AD_TYPE_COMPLETE_LOCAL_NAME,'F','I','P'};
   
   /* disable scan response */
   hci_le_set_scan_resp_data(0,NULL);
@@ -250,8 +250,11 @@
                                     
                                     BlueNRGGattServer::getInstance().handleEvent(GattServerEvents::GATT_EVENT_DATA_WRITTEN, evt->attr_handle);
                                     //Write the actual Data to the Attr Handle? (uint8_1[])evt->att_data contains the data
+                                    //handleUpdated = evt->attr_handle;
+                                    //dataUpdated =  evt->att_data;
                                     if ((p_char->getValuePtr() != NULL) && (p_char->getInitialLength() > 0)) {
-                                        BlueNRGGattServer::getInstance().updateValue(p_char->getHandle(), p_char->getValuePtr(), p_char->getInitialLength(), false /* localOnly */);
+                                        BlueNRGGattServer::getInstance().updateValue(p_char->getHandle(), evt->att_data, p_char->getInitialLength(), false /* localOnly */);
+                                        DEBUG("%d", p_char->getValuePtr());
                                     }
                           }                   
                         }
diff -r 829f081fde15 -r 69a35a56ac48 Servo.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Servo.lib	Thu Jul 09 13:33:36 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/Servo/#36b69a7ced07
diff -r 829f081fde15 -r 69a35a56ac48 main.cpp
--- a/main.cpp	Tue May 19 20:42:25 2015 +0000
+++ b/main.cpp	Thu Jul 09 13:33:36 2015 +0000
@@ -1,40 +1,40 @@
 #include "mbed.h"
 #include "ultrasonic.h"
- 
-DigitalOut myled(LED1);
- 
+#include "Servo.h"
 #include "debug.h"
 #include "btle.h"
 //#include "BlueNRGDevice.h"//User does not use any platform specific header file
 #include "BLEDevice.h"
 #include "UUID.h"
 #include "Utils.h"
- 
+
 BLEDevice dev;
- 
+DigitalOut myled(LED1);
+Servo servo1(D15);
+
 const static char  DEVICE_NAME[] = "FearInProgress";
 const uint8_t device_address[6] = { 0x07, 0x07, 0x07, 0x07, 0x07, 0x07 }; //Peripheral address
 //InterruptIn event_button(USER_BUTTON);
 volatile bool go_to_sleep = true;
 
-#define MAX_SERVICES_NOS 1                                                                                                                                   
+#define MAX_SERVICES_NOS 1
 
 
 static uint8_t mm[2] = {0x00, 0x00};
 static uint8_t upd[2] = {0x00, 0x00};
- 
-GattCharacteristic proxLevel(GattCharacteristic::UUID_ALERT_LEVEL_CHAR, mm, sizeof(mm), sizeof(mm), 
-                            GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY|GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ
-                            /*GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_INDICATE*/);
- 
-GattCharacteristic updateRate(GattCharacteristic::UUID_MEASUREMENT_INTERVAL_CHAR , upd, sizeof(upd), sizeof(upd), 
-                            GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE|
-                            GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE|GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ);                            
- 
+
+GattCharacteristic proxLevel(GattCharacteristic::UUID_ALERT_LEVEL_CHAR, mm, sizeof(mm), sizeof(mm),
+                             GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY|GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ
+                             /*GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_INDICATE*/);
+
+GattCharacteristic updateRate(GattCharacteristic::UUID_MEASUREMENT_INTERVAL_CHAR , upd, sizeof(upd), sizeof(upd),
+                              GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE|
+                              GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE|GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ);
+
 GattCharacteristic *proxChars[] = {&proxLevel, &updateRate };
 //UUID PROXSERVICE(GattService::UUID_IMMEDIATE_ALERT_SERVICE);
 GattService proxService(GattService::UUID_IMMEDIATE_ALERT_SERVICE, proxChars, sizeof(proxChars) / sizeof(GattCharacteristic *));
- 
+
 static const uint16_t uuid16_list[] = {GattService::UUID_IMMEDIATE_ALERT_SERVICE};
 
 void dist(int distance)
@@ -61,11 +61,16 @@
     DEBUG("Restarting the advertising process\n\r");
     dev.startAdvertising();
 }
- 
-void onWriteCallback(uint16_t attributeHandle) {
-    DEBUG("Write Callback!!\n\r");
+
+void onWriteCallback(uint16_t attributeHandle)
+{
+    if(attributeHandle == updateRate.getHandle()){
+    servo1.write(upd[0]);
     }
-    
+    DEBUG("Write Callback!! %d %d \n\r", attributeHandle, updateRate.getHandle());
+
+}
+
 void onConnectionCallback(uint16_t Handle_t) {
     //myled = 1; // LED is ON
     DEBUG("Connected BlueNRG!!\n\r");