Pour Mike le faible

Dependencies:   BLE_API BMP085 mbed nRF51822

Fork of nRF51822_SimpleControls by RedBearLab

Files at this revision

API Documentation at this revision

Comitter:
tarchoun78
Date:
Wed Dec 09 15:21:33 2015 +0000
Parent:
2:bbcdd23ba9ba
Commit message:
Pour MIKE le faible

Changed in this revision

BMP085.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 bbcdd23ba9ba -r d55e6b560480 BMP085.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BMP085.lib	Wed Dec 09 15:21:33 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/okini3939/code/BMP085/#5e2b1f3c0a6a
diff -r bbcdd23ba9ba -r d55e6b560480 main.cpp
--- a/main.cpp	Mon Jul 27 06:51:28 2015 +0000
+++ b/main.cpp	Wed Dec 09 15:21:33 2015 +0000
@@ -21,6 +21,7 @@
 #include "ble/BLE.h"
 #include "Servo.h"
 #include "GattCallbackParamTypes.h"
+#include "BMP085.h"
 
 #define BLE_UUID_TXRX_SERVICE            0x0000 /**< The UUID of the Nordic UART Service. */
 #define BLE_UUID_TX_CHARACTERISTIC       0x0002 /**< The UUID of the TX Characteristic. */
@@ -83,6 +84,7 @@
     uint8_t buf[TXRX_BUF_LEN];
     uint16_t bytesRead, index;
     
+    
     if (Handler->handle == txCharacteristic.getValueAttribute().getHandle()) 
     {
         ble.readCharacteristicValue(txCharacteristic.getValueAttribute().getHandle(), buf, &bytesRead);
@@ -94,8 +96,25 @@
             
         if(buf[0] == 0x01)
         {
-            if(buf[1] == 0x01)
-                LED_SET = 1;
+            if(buf[1] == 0x01){
+                while(buf[1] == 0x01){
+                    // on relit ce qui est envoyé pour être sur qu'on veut toujours faire clignoter la LED VIOLETTE
+                    ble.readCharacteristicValue(txCharacteristic.getValueAttribute().getHandle(), buf, &bytesRead);
+                    memset(txPayload, 0, TXRX_BUF_LEN);
+                    memcpy(txPayload, buf, TXRX_BUF_LEN);       
+        
+                    for(index=0; index<bytesRead; index++)
+                        pc.putc(buf[index]);
+                    // Pour ne pas refaire clignoter alors que l'ordre a été donnée d'arreter
+                    if(buf[1] == 0x01){
+                        LED_SET = 1;
+                        wait_ms(100);
+                        LED_SET = 0; 
+                        wait_ms(100); 
+                        }
+                    else;
+                    }
+                }
             else
                 LED_SET = 0;    
         }
@@ -184,6 +203,8 @@
 
 int main(void)
 {   
+    BMP085 barometre(D4,D5);
+    float temp,press;
     Ticker ticker;
     ticker.attach_us(m_status_check_handle, 200000);
     
@@ -200,7 +221,7 @@
     ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED);
     ble.setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
     ble.accumulateAdvertisingPayload(GapAdvertisingData::SHORTENED_LOCAL_NAME,
-                                    (const uint8_t *)"Biscuit", sizeof("Biscuit") - 1);
+                                    (const uint8_t *)"MALOU", sizeof("MALOU") - 1);
     ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_128BIT_SERVICE_IDS,
                                     (const uint8_t *)uart_base_uuid_rev, sizeof(uart_base_uuid));
     // 100ms; in multiples of 0.625ms. 
@@ -215,6 +236,10 @@
     while(1)
     {
         ble.waitForEvent(); 
+        barometre.update ();
+        temp = barometre.get_temperature();
+        press = barometre.get_pressure() ;
+        printf("Temperature = %f C et Pression = %f Pa",temp,press);
     }
 }