Originally from Donal's blog article. http://mbed.org/users/donalm/code/BLE_Health_Thermometer_Blog/ Changed low freq. clock source from XTAL to IRC.

Dependents:   BLE_Health_Thermometer_IRC BLE_RCBController_micono_test BLE_konashi_PIO_test BLE_ADT7410_TMP102_Sample ... more

Fork of BLE_API_Native_blog by Donal Morrissey

Files at this revision

API Documentation at this revision

Comitter:
ktownsend
Date:
Thu Feb 20 11:12:32 2014 +0000
Parent:
12:d42122e07eb4
Child:
14:f3991f810e1b
Commit message:
Fixed Appearance in the GAP Service

Changed in this revision

GapAdvertisingData.cpp Show annotated file Show diff for this revision Revisions of this file
GapAdvertisingData.h Show annotated file Show diff for this revision Revisions of this file
hw/nRF51822n/nRF51Gap.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/GapAdvertisingData.cpp	Wed Feb 19 09:08:15 2014 +0000
+++ b/GapAdvertisingData.cpp	Thu Feb 20 11:12:32 2014 +0000
@@ -34,6 +34,7 @@
 {
     memset(_payload, 0, GAP_ADVERTISING_DATA_MAX_PAYLOAD);
     _payloadLen = 0;
+    _appearance = GENERIC_TAG;
 }
 
 /**************************************************************************/
@@ -119,6 +120,7 @@
 /**************************************************************************/
 ble_error_t GapAdvertisingData::addAppearance(Appearance appearance)
 {
+    _appearance = appearance;
     return addData(GapAdvertisingData::APPEARANCE, (uint8_t*)&appearance, 2);
 }
 
@@ -224,3 +226,15 @@
 {
     return _payloadLen;
 }
+
+/**************************************************************************/
+/*!
+    \brief Returns the 16-bit appearance value for this device
+    
+    \returns    The 16-bit appearance value
+*/
+/**************************************************************************/
+uint16_t GapAdvertisingData::getAppearance(void)
+{
+    return (uint16_t)_appearance;
+}
--- a/GapAdvertisingData.h	Wed Feb 19 09:08:15 2014 +0000
+++ b/GapAdvertisingData.h	Thu Feb 20 11:12:32 2014 +0000
@@ -195,16 +195,18 @@
     virtual ~GapAdvertisingData(void);
 
     ble_error_t addData(DataType, uint8_t *, uint8_t);
-    ble_error_t addAppearance(Appearance appearance = UNKNOWN);
+    ble_error_t addAppearance(Appearance appearance = GENERIC_TAG);
     ble_error_t addFlags(Flags flag = LE_GENERAL_DISCOVERABLE);
     ble_error_t addTxPower(int8_t txPower);
     void        clear(void);
     uint8_t *   getPayload(void);
     uint8_t     getPayloadLen(void);
+    uint16_t    getAppearance(void);
 
   private:
-    uint8_t _payload[GAP_ADVERTISING_DATA_MAX_PAYLOAD];
-    uint8_t _payloadLen;
+    uint8_t  _payload[GAP_ADVERTISING_DATA_MAX_PAYLOAD];
+    uint8_t  _payloadLen;
+    uint16_t _appearance;
 };
 
 #endif
--- a/hw/nRF51822n/nRF51Gap.cpp	Wed Feb 19 09:08:15 2014 +0000
+++ b/hw/nRF51822n/nRF51Gap.cpp	Thu Feb 20 11:12:32 2014 +0000
@@ -86,10 +86,13 @@
     //    }
     //}
     
-    /* ToDo: Send advertising data! */
+    /* Send advertising data! */
     ASSERT( ERROR_NONE == sd_ble_gap_adv_data_set(advData.getPayload(), advData.getPayloadLen(),
                                                   scanResponse.getPayload(), scanResponse.getPayloadLen()), BLE_ERROR_PARAM_OUT_OF_RANGE);
 
+	/* Make sure the GAP Service appearance value is aligned with the appearance from GapAdvertisingData */	
+	ASSERT( ERROR_NONE == sd_ble_gap_appearance_set(advData.getAppearance()), BLE_ERROR_PARAM_OUT_OF_RANGE);
+
     /* ToDo: Perform some checks on the payload, for example the Scan Response can't */
     /* contains a flags AD type, etc. */