Openwear requires RC oscillator to be used

Fork of nRF51822 by Nordic Semiconductor

Files at this revision

API Documentation at this revision

Comitter:
Rohit Grover
Date:
Mon Jul 07 13:43:31 2014 +0100
Parent:
36:bd0186ce644a
Child:
38:dc4d0edf9bb9
Commit message:
changes required to upgrade to V7 of the soft-device

Changed in this revision

btle/btle.cpp Show annotated file Show diff for this revision Revisions of this file
nRF51Gap.cpp Show annotated file Show diff for this revision Revisions of this file
nordic/app_common/app_timer.cpp Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/app_common/app_button.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/app_common/app_error.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/app_common/app_fifo.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/app_common/app_gpiote.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/app_common/app_scheduler.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/app_common/app_timer.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/app_common/app_trace.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/app_common/app_uart.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/app_common/app_util.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/app_common/crc16.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/app_common/hal_transport.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/app_common/hci_mem_pool.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/app_common/hci_mem_pool_internal.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/app_common/hci_slip.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/app_common/hci_transport.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/app_common/pstorage.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/ble_advdata.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/ble_advdata_parser.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/ble_bondmngr.h Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/ble_central_bondmngr.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/ble_conn_params.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/ble_date_time.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/ble_debug_assert_handler.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/ble_dtm.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/ble_error_log.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/ble_flash.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/ble_racp.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/ble_radio_notification.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/ble_sensorsim.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/ble_services/ble_ans_c.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/ble_services/ble_bas.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/ble_services/ble_bps.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/ble_services/ble_cscs.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/ble_services/ble_dfu.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/ble_services/ble_dis.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/ble_services/ble_gls.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/ble_services/ble_gls_db.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/ble_services/ble_hids.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/ble_services/ble_hrs.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/ble_services/ble_hts.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/ble_services/ble_ias.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/ble_services/ble_ias_c.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/ble_services/ble_lls.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/ble_services/ble_rscs.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/ble_services/ble_sc_ctrlpt.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/ble_services/ble_sensor_location.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/ble_services/ble_srv_common.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/ble_services/ble_tps.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/device_manager/device_manager.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/rpc/ble_rpc_cmd_decoder.h Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/rpc/ble_rpc_cmd_decoder_gap.h Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/rpc/ble_rpc_cmd_decoder_gatts.h Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/rpc/ble_rpc_cmd_encoder.h Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/rpc/ble_rpc_defines.h Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/rpc/ble_rpc_event_decoder.h Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/rpc/ble_rpc_event_decoder_gap.h Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/rpc/ble_rpc_event_decoder_gatts.h Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/rpc/ble_rpc_event_encoder.h Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/rpc/ble_rpc_event_encoder_gap.h Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/rpc/ble_rpc_event_encoder_gatts.h Show diff for this revision Revisions of this file
nordic/nrf-sdk/ble/rpc/ble_rpc_pkt_receiver.h Show diff for this revision Revisions of this file
nordic/nrf-sdk/nordic_common.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/nrf_assert.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/nrf_ecb.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/nrf_gpio.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/nrf_nvmc.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/nrf_temp.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/s110/ble.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/s110/ble_err.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/s110/ble_gap.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/s110/ble_gatt.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/s110/ble_gattc.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/s110/ble_gatts.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/s110/ble_l2cap.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/s110/ble_ranges.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/s110/ble_types.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/s110/nrf_mbr.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/s110/nrf_sdm.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/s110/nrf_soc.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/s110/nrf_svc.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/s110/softdevice_assert.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/sd_common/ant_stack_handler_types.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/sd_common/app_util_platform.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/sd_common/ble_stack_handler_types.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/sd_common/softdevice_handler.h Show annotated file Show diff for this revision Revisions of this file
nordic/nrf-sdk/system_nrf51.h Show annotated file Show diff for this revision Revisions of this file
nordic/softdevice_handler.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/btle/btle.cpp	Thu Jul 03 10:01:02 2014 +0100
+++ b/btle/btle.cpp	Mon Jul 07 13:43:31 2014 +0100
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 #include "common/common.h"
+#include "nordic_common.h"
 
 #include "app_timer.h"
 #include "btle.h"
@@ -21,14 +22,15 @@
 #include "ble_stack_handler_types.h"
 #include "ble_radio_notification.h"
 #include "ble_flash.h"
+#if NEED_BOND_MANAGER
 #include "ble_bondmngr.h"
+#endif
 #include "ble_conn_params.h"
 
 #include "btle_gap.h"
 #include "btle_advertising.h"
 #include "custom/custom_helper.h"
 
-#include "nordic_common.h"
 #include "softdevice_handler.h"
 #include "pstorage.h"
 
--- a/nRF51Gap.cpp	Thu Jul 03 10:01:02 2014 +0100
+++ b/nRF51Gap.cpp	Mon Jul 07 13:43:31 2014 +0100
@@ -279,8 +279,9 @@
     memcpy(dev_addr.addr, address, 6);
 
     ASSERT_INT(ERROR_NONE,
-               sd_ble_gap_address_set(&dev_addr),
+               sd_ble_gap_address_set(BLE_GAP_ADDR_CYCLE_MODE_NONE, &dev_addr),
                BLE_ERROR_PARAM_OUT_OF_RANGE);
 
+
     return BLE_ERROR_NONE;
 }
--- a/nordic/app_common/app_timer.cpp	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/app_common/app_timer.cpp	Mon Jul 07 13:43:31 2014 +0100
@@ -19,6 +19,7 @@
 //#include "nrf_delay.h"
 #include "mbed.h"
 #include "app_util.h"
+#include "app_util_platform.h"
 
 
 #define RTC1_IRQ_PRI            APP_IRQ_PRIORITY_LOW                        /**< Priority of the RTC1 interrupt (used for checking for timeouts and executing timeout handlers). */
@@ -217,7 +218,7 @@
 static void timer_list_insert(app_timer_id_t timer_id)
 {
     timer_node_t * p_timer = &mp_nodes[timer_id];
-    
+
     if (m_timer_id_head == TIMER_NULL)
     {
         m_timer_id_head = timer_id;
@@ -227,7 +228,7 @@
         if (p_timer->ticks_to_expire <= mp_nodes[m_timer_id_head].ticks_to_expire)
         {
             mp_nodes[m_timer_id_head].ticks_to_expire -= p_timer->ticks_to_expire;
-            
+
             p_timer->next   = m_timer_id_head;
             m_timer_id_head = timer_id;
         }
@@ -240,7 +241,7 @@
             ticks_to_expire = p_timer->ticks_to_expire;
             previous        = m_timer_id_head;
             current         = m_timer_id_head;
-            
+
             while ((current != TIMER_NULL) && (ticks_to_expire > mp_nodes[current].ticks_to_expire))
             {
                 ticks_to_expire -= mp_nodes[current].ticks_to_expire;
@@ -274,7 +275,7 @@
     // Find the timer's position in timer list
     previous = m_timer_id_head;
     current  = previous;
-    
+
     while (current != TIMER_NULL)
     {
         if (current == timer_id)
@@ -351,44 +352,44 @@
  */
 static void timer_timeouts_check(void)
 {
-    // Handle expired of timer 
+    // Handle expired of timer
     if (m_timer_id_head != TIMER_NULL)
     {
         app_timer_id_t  timer_id;
         uint32_t        ticks_elapsed;
         uint32_t        ticks_expired;
 
-        // Initialize actual elapsed ticks being consumed to 0 
+        // Initialize actual elapsed ticks being consumed to 0
         ticks_expired = 0;
 
         // ticks_elapsed is collected here, job will use it
         ticks_elapsed = ticks_diff_get(rtc1_counter_get(), m_ticks_latest);
 
-        // Auto variable containing the head of timers expiring 
+        // Auto variable containing the head of timers expiring
         timer_id = m_timer_id_head;
 
-        // Expire all timers within ticks_elapsed and collect ticks_expired 
+        // Expire all timers within ticks_elapsed and collect ticks_expired
         while (timer_id != TIMER_NULL)
         {
             timer_node_t * p_timer;
 
-            // Auto variable for current timer node 
+            // Auto variable for current timer node
             p_timer = &mp_nodes[timer_id];
 
-            // Do nothing if timer did not expire 
+            // Do nothing if timer did not expire
             if (ticks_elapsed < p_timer->ticks_to_expire)
             {
                 break;
             }
 
-            // Decrement ticks_elapsed and collect expired ticks 
+            // Decrement ticks_elapsed and collect expired ticks
             ticks_elapsed -= p_timer->ticks_to_expire;
             ticks_expired += p_timer->ticks_to_expire;
 
-            // Move to next timer 
+            // Move to next timer
             timer_id = p_timer->next;
 
-            // Execute Task 
+            // Execute Task
             timeout_handler_exec(p_timer);
         }
 
@@ -424,10 +425,10 @@
  */
 static bool elapsed_ticks_acquire(uint32_t * p_ticks_elapsed)
 {
-    // Pick the elapsed value from queue 
+    // Pick the elapsed value from queue
     if (m_ticks_elapsed_q_read_ind != m_ticks_elapsed_q_write_ind)
     {
-        // Dequeue elapsed value 
+        // Dequeue elapsed value
         m_ticks_elapsed_q_read_ind++;
         if (m_ticks_elapsed_q_read_ind == CONTEXT_QUEUE_SIZE_MAX)
         {
@@ -443,7 +444,7 @@
     }
     else
     {
-        // No elapsed value in queue 
+        // No elapsed value in queue
         *p_ticks_elapsed = 0;
         return false;
     }
@@ -467,13 +468,13 @@
     {
         timer_user_t * p_user         = &mp_users[user_id];
         uint8_t        user_ops_first = p_user->first;
-        
+
         while (user_ops_first != p_user->last)
         {
             timer_node_t *    p_timer;
             timer_user_op_t * p_user_op = &p_user->p_user_op_queue[user_ops_first];
 
-            // Traverse to next operation in queue 
+            // Traverse to next operation in queue
             user_ops_first++;
             if (user_ops_first == p_user->user_op_queue_size)
             {
@@ -491,7 +492,7 @@
                         p_timer->is_running = false;
                     }
                     break;
-                    
+
                 case TIMER_USER_OP_TYPE_STOP_ALL:
                     // Delete list of running timers, and mark all timers as not running
                     while (m_timer_id_head != TIMER_NULL)
@@ -502,7 +503,7 @@
                         m_timer_id_head    = p_head->next;
                     }
                     break;
-                    
+
                 default:
                     // No implementation needed.
                     break;
@@ -532,17 +533,17 @@
         timer_node_t * p_timer;
         app_timer_id_t id_expired;
 
-        // Auto variable for current timer node 
+        // Auto variable for current timer node
         p_timer = &mp_nodes[m_timer_id_head];
 
-        // Do nothing if timer did not expire 
+        // Do nothing if timer did not expire
         if (ticks_elapsed < p_timer->ticks_to_expire)
         {
             p_timer->ticks_to_expire -= ticks_elapsed;
             break;
         }
 
-        // Decrement ticks_elapsed and collect expired ticks 
+        // Decrement ticks_elapsed and collect expired ticks
         ticks_elapsed -= p_timer->ticks_to_expire;
         ticks_expired += p_timer->ticks_to_expire;
 
@@ -550,11 +551,11 @@
         p_timer->ticks_to_expire = 0;
         p_timer->is_running      = false;
 
-        // Remove the expired timer from head 
+        // Remove the expired timer from head
         id_expired      = m_timer_id_head;
         m_timer_id_head = p_timer->next;
 
-        // Timer will be restarted if periodic 
+        // Timer will be restarted if periodic
         if (p_timer->ticks_periodic_interval != 0)
         {
             p_timer->ticks_at_start       = (ticks_previous + ticks_expired) & MAX_RTC_COUNTER_VAL;
@@ -585,7 +586,7 @@
     {
         timer_user_t * p_user = &mp_users[user_id];
 
-        // Handle insertions of timers 
+        // Handle insertions of timers
         while ((restart_list_head != TIMER_NULL) || (p_user->first != p_user->last))
         {
             app_timer_id_t id_start;
@@ -621,14 +622,14 @@
                 p_timer->p_context               = p_user_op->params.start.p_context;
             }
 
-            // Prepare the node to be inserted 
+            // Prepare the node to be inserted
             if (
                  ((p_timer->ticks_at_start - m_ticks_latest) & MAX_RTC_COUNTER_VAL)
                  <
                  (MAX_RTC_COUNTER_VAL / 2)
                 )
             {
-                p_timer->ticks_to_expire = ticks_diff_get(p_timer->ticks_at_start, m_ticks_latest) + 
+                p_timer->ticks_to_expire = ticks_diff_get(p_timer->ticks_at_start, m_ticks_latest) +
                                            p_timer->ticks_first_interval;
             }
             else
@@ -651,11 +652,11 @@
             p_timer->is_running           = true;
             p_timer->next                 = TIMER_NULL;
 
-            // Insert into list 
+            // Insert into list
             timer_list_insert(id_start);
         }
     }
-    
+
     return (m_timer_id_head != timer_id_old_head);
 }
 
@@ -664,7 +665,7 @@
  */
 static void compare_reg_update(app_timer_id_t timer_id_head_old)
 {
-    // Setup the timeout for timers on the head of the list 
+    // Setup the timeout for timers on the head of the list
     if (m_timer_id_head != TIMER_NULL)
     {
         uint32_t ticks_to_expire = mp_nodes[m_timer_id_head].ticks_to_expire;
@@ -680,7 +681,7 @@
 
         cc += (ticks_elapsed < ticks_to_expire) ? ticks_to_expire : ticks_elapsed;
         cc &= MAX_RTC_COUNTER_VAL;
-        
+
         rtc1_compare0_set(cc);
 
         uint32_t post_counter_val = rtc1_counter_get();
@@ -717,24 +718,24 @@
     bool           ticks_have_elapsed;
     bool           compare_update;
     app_timer_id_t timer_id_head_old;
-    
+
     // Back up the previous known tick and previous list head
     ticks_previous    = m_ticks_latest;
     timer_id_head_old = m_timer_id_head;
-    
+
     // Get number of elapsed ticks
     ticks_have_elapsed = elapsed_ticks_acquire(&ticks_elapsed);
 
     // Handle list deletions
     compare_update = list_deletions_handler();
-    
+
     // Handle expired timers
     if (ticks_have_elapsed)
     {
         expired_timers_handler(ticks_elapsed, ticks_previous, &restart_list_head);
         compare_update = true;
     }
-    
+
     // Handle list insertions
     if (list_insertions_handler(restart_list_head))
     {
@@ -768,10 +769,10 @@
  * @return     Pointer to allocated queue entry, or NULL if queue is full.
  */
 static timer_user_op_t * user_op_alloc(timer_user_t * p_user, app_timer_id_t * p_last_index)
-{        
+{
     app_timer_id_t    last;
     timer_user_op_t * p_user_op;
-    
+
     last = p_user->last + 1;
     if (last == p_user->user_op_queue_size)
     {
@@ -783,10 +784,10 @@
         // Queue is full.
         return NULL;
     }
-    
-    *p_last_index = last;    
+
+    *p_last_index = last;
     p_user_op     = &p_user->p_user_op_queue[p_user->last];
-        
+
     return p_user_op;
 }
 
@@ -808,21 +809,21 @@
                                         void *          p_context)
 {
     app_timer_id_t last_index;
-    
+
     timer_user_op_t * p_user_op = user_op_alloc(&mp_users[user_id], &last_index);
     if (p_user_op == NULL)
     {
         return NRF_ERROR_NO_MEM;
     }
-    
+
     p_user_op->op_type                              = TIMER_USER_OP_TYPE_START;
     p_user_op->timer_id                             = timer_id;
     p_user_op->params.start.ticks_at_start          = rtc1_counter_get();
     p_user_op->params.start.ticks_first_interval    = timeout_initial;
     p_user_op->params.start.ticks_periodic_interval = timeout_periodic;
     p_user_op->params.start.p_context               = p_context;
-    
-    user_op_enque(&mp_users[user_id], last_index);    
+
+    user_op_enque(&mp_users[user_id], last_index);
 
     timer_list_handler_sched();
 
@@ -841,17 +842,17 @@
 static uint32_t timer_stop_op_schedule(timer_user_id_t user_id, app_timer_id_t timer_id)
 {
     app_timer_id_t last_index;
-    
+
     timer_user_op_t * p_user_op = user_op_alloc(&mp_users[user_id], &last_index);
     if (p_user_op == NULL)
     {
         return NRF_ERROR_NO_MEM;
     }
-    
+
     p_user_op->op_type  = TIMER_USER_OP_TYPE_STOP;
     p_user_op->timer_id = timer_id;
-    
-    user_op_enque(&mp_users[user_id], last_index);        
+
+    user_op_enque(&mp_users[user_id], last_index);
 
     timer_list_handler_sched();
 
@@ -866,17 +867,17 @@
 static uint32_t timer_stop_all_op_schedule(timer_user_id_t user_id)
 {
     app_timer_id_t last_index;
-    
+
     timer_user_op_t * p_user_op = user_op_alloc(&mp_users[user_id], &last_index);
     if (p_user_op == NULL)
     {
         return NRF_ERROR_NO_MEM;
     }
-    
+
     p_user_op->op_type  = TIMER_USER_OP_TYPE_STOP_ALL;
     p_user_op->timer_id = TIMER_NULL;
-    
-    user_op_enque(&mp_users[user_id], last_index);        
+
+    user_op_enque(&mp_users[user_id], last_index);
 
     timer_list_handler_sched();
 
@@ -929,29 +930,29 @@
     {
         return NRF_ERROR_INVALID_PARAM;
     }
-    
+
     // Stop RTC to prevent any running timers from expiring (in case of reinitialization)
     rtc1_stop();
-    
+
     m_evt_schedule_func = evt_schedule_func;
 
     // Initialize timer node array
     m_node_array_size = max_timers;
     mp_nodes          = (timer_node_t *) p_buffer;
-    
+
     for (i = 0; i < max_timers; i++)
     {
         mp_nodes[i].state      = STATE_FREE;
         mp_nodes[i].is_running = false;
     }
-    
+
     // Skip timer node array
     p_buffer = &((uint8_t *)p_buffer)[max_timers * sizeof(timer_node_t)];
-    
+
     // Initialize users array
     m_user_array_size = APP_TIMER_INT_LEVELS;
     mp_users          = (timer_user_t *) p_buffer;
-    
+
     // Skip user array
     p_buffer = &((uint8_t *)p_buffer)[APP_TIMER_INT_LEVELS * sizeof(timer_user_t)];
 
@@ -959,12 +960,12 @@
     for (i = 0; i < APP_TIMER_INT_LEVELS; i++)
     {
         timer_user_t * p_user = &mp_users[i];
-        
+
         p_user->first              = 0;
         p_user->last               = 0;
         p_user->user_op_queue_size = op_queues_size;
         p_user->p_user_op_queue    = (timer_user_op_t *) p_buffer;
-    
+
         // Skip operation queue
         p_buffer = &((uint8_t *)p_buffer)[op_queues_size * sizeof(timer_user_op_t)];
     }
@@ -980,7 +981,7 @@
     rtc1_init(prescaler);
 
     m_ticks_latest = rtc1_counter_get();
-    
+
     return NRF_SUCCESS;
 }
 
@@ -1003,8 +1004,8 @@
     if (p_timer_id == NULL)
     {
         return NRF_ERROR_INVALID_PARAM;
-    }    
-    
+    }
+
     // Find free timer
     for (i = 0; i < m_node_array_size; i++)
     {
@@ -1013,12 +1014,12 @@
             mp_nodes[i].state             = STATE_ALLOCATED;
             mp_nodes[i].mode              = mode;
             mp_nodes[i].p_timeout_handler = timeout_handler;
-            
+
             *p_timer_id = i;
             return NRF_SUCCESS;
         }
     }
-    
+
     return NRF_ERROR_NO_MEM;
 }
 
@@ -1032,22 +1033,22 @@
     timer_user_id_t ret;
 
     STATIC_ASSERT(APP_TIMER_INT_LEVELS == 3);
-    
+
     switch (current_int_priority_get())
     {
         case APP_IRQ_PRIORITY_HIGH:
             ret = APP_HIGH_USER_ID;
             break;
-            
+
         case APP_IRQ_PRIORITY_LOW:
             ret = APP_LOW_USER_ID;
             break;
-            
+
         default:
             ret = THREAD_MODE_USER_ID;
             break;
     }
-    
+
     return ret;
 }
 
@@ -1055,7 +1056,7 @@
 uint32_t app_timer_start(app_timer_id_t timer_id, uint32_t timeout_ticks, void * p_context)
 {
     uint32_t timeout_periodic;
-    
+
     // Check state and parameters
     if (mp_nodes == NULL)
     {
@@ -1069,7 +1070,7 @@
     {
         return NRF_ERROR_INVALID_STATE;
     }
-    
+
     // Schedule timer start operation
     timeout_periodic = (mp_nodes[timer_id].mode == APP_TIMER_MODE_REPEATED) ? timeout_ticks : 0;
 
@@ -1096,7 +1097,7 @@
     {
         return NRF_ERROR_INVALID_STATE;
     }
-    
+
     // Schedule timer stop operation
     return timer_stop_op_schedule(user_id_get(), timer_id);
 }
--- a/nordic/nrf-sdk/app_common/app_button.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/app_common/app_button.h	Mon Jul 07 13:43:31 2014 +0100
@@ -40,30 +40,41 @@
 
 #include <stdint.h>
 #include <stdbool.h>
-#include "nordic_global.h"
 #include "nrf.h"
 #include "app_error.h"
 #include "app_scheduler.h"
 #include "nrf_gpio.h"
 
-#define APP_BUTTON_SCHED_EVT_SIZE  sizeof(app_button_event_t)   /**< Size of button events being passed through the scheduler (is to be used for computing the maximum size of scheduler events). */
+#define APP_BUTTON_SCHED_EVT_SIZE sizeof(app_button_event_t)   /**< Size of button events being passed through the scheduler (is to be used for computing the maximum size of scheduler events). */
+#define APP_BUTTON_PUSH        1                               /**< Indicates that a button is pushed. */
+#define APP_BUTTON_RELEASE     0                               /**< Indicates that a button is released. */
+#define APP_BUTTON_ACTIVE_HIGH 1                               /**< Indicates that a button is active high. */
+#define APP_BUTTON_ACTIVE_LOW  0                               /**< Indicates that a button is active low. */
 
 /**@brief Button event handler type. */
-typedef void (*app_button_handler_t)(uint8_t pin_no);
+typedef void (*app_button_handler_t)(uint8_t pin_no, uint8_t button_action);
 
 /**@brief Type of function for passing events from the Button Handler module to the scheduler. */
 typedef uint32_t (*app_button_evt_schedule_func_t) (app_button_handler_t button_handler,
-                                                    uint8_t              pin_no);
+                                                    uint8_t              pin_no,
+                                                    uint8_t              button_action);
 
 /**@brief Button configuration structure. */
 typedef struct
 {
-    uint8_t              pin_no;                                /**< Pin to be used as a button. */
-    bool                 active_high;                           /**< TRUE if pin is active high, FALSE otherwise. */
-    nrf_gpio_pin_pull_t  pull_cfg;                              /**< Pull-up or -down configuration. */
-    app_button_handler_t button_handler;                        /**< Handler to be called when button is pushed. */
+    uint8_t              pin_no;           /**< Pin to be used as a button. */
+    uint8_t              active_state;     /**< APP_BUTTON_ACTIVE_HIGH or APP_BUTTON_ACTIVE_LOW. */
+    nrf_gpio_pin_pull_t  pull_cfg;         /**< Pull-up or -down configuration. */
+    app_button_handler_t button_handler;   /**< Handler to be called when button is pushed. */
 } app_button_cfg_t;
 
+/**@brief  Pin transition direction struct. */
+typedef struct
+{
+    uint32_t high_to_low;   /**Pin went from high to low */
+    uint32_t low_to_high;   /**Pin went from low to high */
+} pin_transition_t;
+
 /**@brief Macro for initializing the Button Handler module.
  *
  * @details It will initialize the specified pins as buttons, and configure the Button Handler
@@ -147,6 +158,7 @@
 {
     app_button_handler_t button_handler;
     uint8_t              pin_no;
+    uint8_t              button_action;
 } app_button_event_t;
 
 static __INLINE void app_button_evt_get(void * p_event_data, uint16_t event_size)
@@ -154,16 +166,18 @@
     app_button_event_t * p_buttons_event = (app_button_event_t *)p_event_data;
     
     APP_ERROR_CHECK_BOOL(event_size == sizeof(app_button_event_t));
-    p_buttons_event->button_handler(p_buttons_event->pin_no);
+    p_buttons_event->button_handler(p_buttons_event->pin_no, p_buttons_event->button_action);
 }
 
 static __INLINE uint32_t app_button_evt_schedule(app_button_handler_t button_handler,
-                                                 uint8_t              pin_no)
+                                                 uint8_t              pin_no,
+                                                 uint8_t              button_action)
 {
     app_button_event_t buttons_event;
     
     buttons_event.button_handler = button_handler;
     buttons_event.pin_no         = pin_no;
+    buttons_event.button_action  = button_action;
     
     return app_sched_event_put(&buttons_event, sizeof(buttons_event), app_button_evt_get);
 }
--- a/nordic/nrf-sdk/app_common/app_error.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/app_common/app_error.h	Mon Jul 07 13:43:31 2014 +0100
@@ -24,7 +24,6 @@
 
 #include <stdint.h>
 #include <stdbool.h>
-#include "nordic_global.h"
 #include "nrf_error.h"
 
 /**@brief Function for error handling, which is called when an error has occurred. 
--- a/nordic/nrf-sdk/app_common/app_fifo.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/app_common/app_fifo.h	Mon Jul 07 13:43:31 2014 +0100
@@ -24,7 +24,6 @@
 
 #include <stdint.h>
 #include <stdlib.h>
-#include "nordic_global.h"
 #include "nrf_error.h"
 
 /**@brief A FIFO instance structure. Keeps track of which bytes to read and write next.
--- a/nordic/nrf-sdk/app_common/app_gpiote.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/app_common/app_gpiote.h	Mon Jul 07 13:43:31 2014 +0100
@@ -33,6 +33,8 @@
  *
  * @note    Even if the application is using the @ref app_scheduler, the GPIOTE event handlers will
  *          be called directly from the GPIOTE interrupt handler.
+ *
+ * @warning If multiple users registers for the same pins the behavior for those pins are undefined.
  */
 
 #ifndef APP_GPIOTE_H__
@@ -40,7 +42,6 @@
 
 #include <stdint.h>
 #include <stdbool.h>
-#include "nordic_global.h"
 #include "nrf.h"
 #include "app_error.h"
 #include "app_util.h"
@@ -62,6 +63,9 @@
 typedef void (*app_gpiote_event_handler_t)(uint32_t event_pins_low_to_high,
                                            uint32_t event_pins_high_to_low);
 
+/**@brief GPIOTE input event handler type. */
+typedef void (*app_gpiote_input_event_handler_t)(void);
+
 /**@brief Macro for initializing the GPIOTE module.
  *
  * @details It will handle dimensioning and allocation of the memory buffer required by the module,
@@ -156,6 +160,60 @@
  */
 uint32_t app_gpiote_pins_state_get(app_gpiote_user_id_t user_id, uint32_t * p_pins);
 
+/**@brief Function for registering event handlers for GPIOTE IN events.
+ *
+ * @param[in] channel         GPIOTE channel [0..3].
+ * @param[in] pin             Pins associated with GPIOTE channel. Changes on following pins will generate events.
+ * @param[in] polarity        Specify operation on input that shall trigger IN event.
+ * @param[in] event_handler   Event handler invoked on the IN event in the GPIOTE interrupt.
+ *
+ * @return   NRF_SUCCESS                 On success.
+ * @retval   NRF_ERROR_INVALID_PARAM     Invalid channel or pin number.
+ * @retval   NRF_ERROR_NOT_SUPPORTED     Driver doesn't support IN events.
+ */
+uint32_t app_gpiote_input_event_handler_register(const uint8_t channel,
+                                                 const uint32_t pin,
+                                                 const uint32_t polarity,
+                                                 app_gpiote_input_event_handler_t event_handler);
+
+/**@brief Function for unregistering event handlers for GPIOTE IN events.
+ *
+ * @return   NRF_SUCCESS                 On success.
+ * @retval   NRF_ERROR_NOT_SUPPORTED     Driver doesn't support IN events.
+ */
+uint32_t app_gpiote_input_event_handler_unregister(const uint8_t channel);
+
+/**@brief Function for registering event handler invoked at the end of a GPIOTE interrupt.
+ *
+ * @param[in] event_handler    Event handler invoked at the end of the GPIOTE interrupt.
+ *
+ * @return   NRF_SUCCESS                 On success.
+ * @retval   NRF_ERROR_NOT_SUPPORTED     Driver doesn't support IN events.
+ */
+uint32_t app_gpiote_end_irq_event_handler_register(app_gpiote_input_event_handler_t event_handler);
+
+/**@brief Function for unregistering event handler invoked at the end of a GPIOTE interrupt.
+ *
+ * @return   NRF_SUCCESS                 On success.
+ * @retval   NRF_ERROR_NOT_SUPPORTED     Driver doesn't support IN events.
+ */
+uint32_t app_gpiote_end_irq_event_handler_unregister(void);
+
+/**@brief Function for enabling interrupts in the GPIOTE driver.
+ *
+ * @return   NRF_SUCCESS                 On success.
+ * @retval   NRF_ERROR_NOT_SUPPORTED     Driver doesn't support.
+ */
+uint32_t app_gpiote_enable_interrupts(void);
+
+/**@brief Function for disabling interrupts in the GPIOTE driver.
+ *
+ * @return   NRF_SUCCESS                 On success.
+ * @retval   NRF_ERROR_NOT_SUPPORTED     Driver doesn't support.
+ */
+uint32_t app_gpiote_disable_interrupts(void);
+
+
 #endif // APP_GPIOTE_H__
 
 /** @} */
--- a/nordic/nrf-sdk/app_common/app_scheduler.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/app_common/app_scheduler.h	Mon Jul 07 13:43:31 2014 +0100
@@ -49,7 +49,6 @@
 #define APP_SCHEDULER_H__
 
 #include <stdint.h>
-#include "nordic_global.h"
 #include "app_error.h"
 
 #define APP_SCHED_EVENT_HEADER_SIZE 8       /**< Size of app_scheduler.event_header_t (only for use inside APP_SCHED_BUF_SIZE()). */
--- a/nordic/nrf-sdk/app_common/app_timer.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/app_common/app_timer.h	Mon Jul 07 13:43:31 2014 +0100
@@ -44,7 +44,6 @@
 #include <stdint.h>
 #include <stdbool.h>
 #include <stdio.h>
-#include "nordic_global.h"
 #include "app_error.h"
 #include "app_util.h"
 #include "app_scheduler.h"
@@ -123,6 +122,13 @@
  *          making sure that the buffer is correctly aligned. It will also connect the timer module
  *          to the scheduler (if specified).
  *
+ * @note    This module assumes that the LFCLK is already running. If it isn't, the module will 
+ *          be non-functional, since the RTC will not run. If you don't use a softdevice, you'll 
+ *          have to start the LFCLK manually. See the rtc_example's \ref lfclk_config() function 
+ *          for an example of how to do this. If you use a softdevice, the LFCLK is started on 
+ *          softdevice init. 
+ *
+ *
  * @param[in]  PRESCALER        Value of the RTC1 PRESCALER register. This will decide the
  *                              timer tick rate. Set to 0 for no prescaling.
  * @param[in]  MAX_TIMERS       Maximum number of timers that can be created at any given time.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nordic/nrf-sdk/app_common/app_trace.h	Mon Jul 07 13:43:31 2014 +0100
@@ -0,0 +1,55 @@
+#ifndef __DEBUG_H_
+#define __DEBUG_H_
+
+#include <stdint.h>
+#include <stdio.h>
+
+/**
+ * @defgroup app_trace Debug Logger
+ * @ingroup app_common
+ * @{
+ * @brief Enables debug logs/ trace over UART.
+ * @details Enables debug logs/ trace over UART. Tracing is enabled only if 
+ *          ENABLE_DEBUG_LOG_SUPPORT is defined in the project.
+ */
+#ifdef ENABLE_DEBUG_LOG_SUPPORT
+/**
+ * @brief Module Initialization.
+ *
+ * @details Initializes the module to use UART as trace output.
+ * 
+ * @warning This function will configure UART using default board configuration (described in @ref nrf51_setups). 
+ *          Do not call this function if UART is configured from a higher level in the application. 
+ */
+void app_trace_init(void);
+
+/**
+ * @brief Log debug messages.
+ *
+ * @details This API logs messages over UART. The module must be initialized before using this API.
+ *
+ * @note Though this is currently a macro, it should be used used and treated as function.
+ */
+#define app_trace_log printf
+
+/**
+ * @brief Dump auxiliary byte buffer to the debug trace.
+ *
+ * @details This API logs messages over UART. The module must be initialized before using this API.
+ * 
+ * @param[in] p_buffer  Buffer to be dumped on the debug trace.
+ * @param[in] len       Size of the buffer.
+ */
+void app_trace_dump(uint8_t * p_buffer, uint32_t len);
+
+#else // ENABLE_DEBUG_LOG_SUPPORT
+
+#define app_trace_init(...)
+#define app_trace_log(...)
+#define app_trace_dump(...)
+
+#endif // ENABLE_DEBUG_LOG_SUPPORT
+
+/** @} */
+
+#endif //__DEBUG_H_
--- a/nordic/nrf-sdk/app_common/app_uart.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/app_common/app_uart.h	Mon Jul 07 13:43:31 2014 +0100
@@ -24,41 +24,40 @@
 
 #include <stdint.h>
 #include <stdbool.h>
-#include "nordic_global.h"
-#include "app_util.h"
+#include "app_util_platform.h"
 
-#define  UART_PIN_DISCONNECTED  0xFFFFFFFF  /**< Value indicating that no pin is connected to this UART register. */
+#define  UART_PIN_DISCONNECTED 0xFFFFFFFF /**< Value indicating that no pin is connected to this UART register. */
 
 /**@brief UART Flow Control modes for the peripheral.
  */
 typedef enum
 {
-    APP_UART_FLOW_CONTROL_DISABLED,         /**< UART Hw Flow Control is disabled. */
-    APP_UART_FLOW_CONTROL_ENABLED,          /**< Standard UART Hw Flow Control is enabled. */
-    APP_UART_FLOW_CONTROL_LOW_POWER         /**< Specialized UART Hw Flow Control is used. The Low Power setting allows the nRF51 to Power Off the UART module when CTS is in-active, and re-enabling the UART when the CTS signal becomes active. This allows the nRF51 to safe power by only using the UART module when it is needed by the remote site. */
+    APP_UART_FLOW_CONTROL_DISABLED, /**< UART Hw Flow Control is disabled. */
+    APP_UART_FLOW_CONTROL_ENABLED,  /**< Standard UART Hw Flow Control is enabled. */
+    APP_UART_FLOW_CONTROL_LOW_POWER /**< Specialized UART Hw Flow Control is used. The Low Power setting allows the nRF51 to Power Off the UART module when CTS is in-active, and re-enabling the UART when the CTS signal becomes active. This allows the nRF51 to safe power by only using the UART module when it is needed by the remote site. */
 } app_uart_flow_control_t;
 
 /**@brief UART communication structure holding configuration settings for the peripheral.
  */
 typedef struct
 {
-    uint8_t                 rx_pin_no;      /**< RX pin number. */
-    uint8_t                 tx_pin_no;      /**< TX pin number. */
-    uint8_t                 rts_pin_no;     /**< RTS pin number, only used if flow control is enabled. */
-    uint8_t                 cts_pin_no;     /**< CTS pin number, only used if flow control is enabled. */
-    app_uart_flow_control_t flow_control;   /**< Flow control setting, if flow control is used, the system will use low power UART mode, based on CTS signal. */
-    bool                    use_parity;     /**< Even parity if TRUE, no parity if FALSE. */
-    uint32_t                baud_rate;      /**< Baud rate configuration. */
+    uint8_t                 rx_pin_no;    /**< RX pin number. */
+    uint8_t                 tx_pin_no;    /**< TX pin number. */
+    uint8_t                 rts_pin_no;   /**< RTS pin number, only used if flow control is enabled. */
+    uint8_t                 cts_pin_no;   /**< CTS pin number, only used if flow control is enabled. */
+    app_uart_flow_control_t flow_control; /**< Flow control setting, if flow control is used, the system will use low power UART mode, based on CTS signal. */
+    bool                    use_parity;   /**< Even parity if TRUE, no parity if FALSE. */
+    uint32_t                baud_rate;    /**< Baud rate configuration. */
 } app_uart_comm_params_t;
 
 /**@brief UART buffer for transmitting/receiving data.
  */
 typedef struct
 {
-    uint8_t * rx_buf;                       /**< Pointer to the RX buffer. */
-    uint32_t  rx_buf_size;                  /**< Size of the RX buffer. */
-    uint8_t * tx_buf;                       /**< Pointer to the TX buffer. */
-    uint32_t  tx_buf_size;                  /**< Size of the TX buffer. */
+    uint8_t * rx_buf;      /**< Pointer to the RX buffer. */
+    uint32_t  rx_buf_size; /**< Size of the RX buffer. */
+    uint8_t * tx_buf;      /**< Pointer to the TX buffer. */
+    uint32_t  tx_buf_size; /**< Size of the TX buffer. */
 } app_uart_buffers_t;
 
 /**@brief Enumeration describing current state of the UART.
@@ -74,8 +73,8 @@
  */
 typedef enum
 {
-    APP_UART_DISCONNECTED,                  /**< State indicating that the UART is disconnected and cannot receive or transmit bytes. */
-    APP_UART_CONNECTED                      /**< State indicating that the UART is connected and ready to receive or transmit bytes. If flow control is disabled, the state will always be connected. */
+    APP_UART_DISCONNECTED, /**< State indicating that the UART is disconnected and cannot receive or transmit bytes. */
+    APP_UART_CONNECTED     /**< State indicating that the UART is connected and ready to receive or transmit bytes. If flow control is disabled, the state will always be connected. */
 } app_uart_connection_state_t;
 
 /**@brief Enumeration which defines events used by the UART module upon data reception or error.
@@ -85,11 +84,11 @@
  */
 typedef enum
 {
-    APP_UART_DATA_READY,                    /**< An event indicating that UART data has been received. The data is available in the FIFO and can be fetched using @ref app_uart_get. */
-    APP_UART_FIFO_ERROR,                    /**< An error in the FIFO module used by the app_uart module has occured. The FIFO error code is stored in app_uart_evt_t.data.error_code field. */
-    APP_UART_COMMUNICATION_ERROR,           /**< An communication error has occured during reception. The error is stored in app_uart_evt_t.data.error_communication field. */
-    APP_UART_TX_EMPTY,                      /**< An event indicating that UART has completed transmission of all available data in the TX FIFO. */
-    APP_UART_DATA,                          /**< An event indicating that UART data has been received, and data is present in data field. This event is only used when no FIFO is configured. */
+    APP_UART_DATA_READY,          /**< An event indicating that UART data has been received. The data is available in the FIFO and can be fetched using @ref app_uart_get. */
+    APP_UART_FIFO_ERROR,          /**< An error in the FIFO module used by the app_uart module has occured. The FIFO error code is stored in app_uart_evt_t.data.error_code field. */
+    APP_UART_COMMUNICATION_ERROR, /**< An communication error has occured during reception. The error is stored in app_uart_evt_t.data.error_communication field. */
+    APP_UART_TX_EMPTY,            /**< An event indicating that UART has completed transmission of all available data in the TX FIFO. */
+    APP_UART_DATA,                /**< An event indicating that UART data has been received, and data is present in data field. This event is only used when no FIFO is configured. */
 } app_uart_evt_type_t;
 
 /**@brief Struct containing events from the UART module.
@@ -99,12 +98,12 @@
  */
 typedef struct
 {
-    app_uart_evt_type_t evt_type;           /**< Type of event. */
+    app_uart_evt_type_t evt_type; /**< Type of event. */
     union
     {
-        uint32_t        error_communication;/**< Field used if evt_type is: APP_UART_COMMUNICATION_ERROR. This field contains the value in the ERRORSRC register for the UART peripheral. The UART_ERRORSRC_x defines from @ref nrf51_bitfields.h can be used to parse the error code. See also the nRF51 Series Reference Manual for specification. */
-        uint32_t        error_code;         /**< Field used if evt_type is: NRF_ERROR_x. Additional status/error code if the error event type is APP_UART_FIFO_ERROR. This error code refer to errors defined in nrf_error.h. */
-        uint8_t         value;              /**< Field used if evt_type is: NRF_ERROR_x. Additional status/error code if the error event type is APP_UART_FIFO_ERROR. This error code refer to errors defined in nrf_error.h. */
+        uint32_t error_communication; /**< Field used if evt_type is: APP_UART_COMMUNICATION_ERROR. This field contains the value in the ERRORSRC register for the UART peripheral. The UART_ERRORSRC_x defines from @ref nrf51_bitfields.h can be used to parse the error code. See also the nRF51 Series Reference Manual for specification. */
+        uint32_t error_code;          /**< Field used if evt_type is: NRF_ERROR_x. Additional status/error code if the error event type is APP_UART_FIFO_ERROR. This error code refer to errors defined in nrf_error.h. */
+        uint8_t  value;               /**< Field used if evt_type is: NRF_ERROR_x. Additional status/error code if the error event type is APP_UART_FIFO_ERROR. This error code refer to errors defined in nrf_error.h. */
     } data;
 } app_uart_evt_t;
 
@@ -115,7 +114,9 @@
  *
  * @param[in]   p_app_uart_event Pointer to UART event.
  */
-typedef void (*app_uart_event_handler_t) (app_uart_evt_t * p_app_uart_event);
+
+
+typedef void (* app_uart_event_handler_t) (app_uart_evt_t * p_app_uart_event);
 
 /**@brief Macro for safe initialization of the UART module in a single user instance when using
  *        a FIFO together with UART.
@@ -132,7 +133,7 @@
  * @note Since this macro allocates a buffer and registers the module as a GPIOTE user when flow
  *       control is enabled, it must only be called once.
  */
-#define APP_UART_FIFO_INIT(P_COMM_PARAMS, RX_BUF_SIZE, TX_BUF_SIZE, EVT_HANDLER, IRQ_PRIO, ERR_CODE)\
+#define APP_UART_FIFO_INIT(P_COMM_PARAMS, RX_BUF_SIZE, TX_BUF_SIZE, EVT_HANDLER, IRQ_PRIO, ERR_CODE) \
     do                                                                                             \
     {                                                                                              \
         uint16_t           APP_UART_UID = 0;                                                       \
@@ -141,9 +142,9 @@
         static uint8_t     tx_buf[TX_BUF_SIZE];                                                    \
                                                                                                    \
         buffers.rx_buf      = rx_buf;                                                              \
-        buffers.rx_buf_size = sizeof(rx_buf);                                                      \
+        buffers.rx_buf_size = sizeof (rx_buf);                                                      \
         buffers.tx_buf      = tx_buf;                                                              \
-        buffers.tx_buf_size = sizeof(tx_buf);                                                      \
+        buffers.tx_buf_size = sizeof (tx_buf);                                                      \
         ERR_CODE = app_uart_init(P_COMM_PARAMS, &buffers, EVT_HANDLER, IRQ_PRIO, &APP_UART_UID);   \
     } while (0)
 
@@ -203,15 +204,15 @@
  * @retval      NRF_ERROR_NO_MEM          GPIOTE module has reached the maximum number of users.
  */
 uint32_t app_uart_init(const app_uart_comm_params_t * p_comm_params,
-                             app_uart_buffers_t *     p_buffers,
-                             app_uart_event_handler_t error_handler,
-                             app_irq_priority_t       irq_priority,
-                             uint16_t *               p_uart_uid);
+                       app_uart_buffers_t *           p_buffers,
+                       app_uart_event_handler_t       error_handler,
+                       app_irq_priority_t             irq_priority,
+                       uint16_t *                     p_uart_uid);
 
 /**@brief Function for getting a byte from the UART.
  *
  * @details This function will get the next byte from the RX buffer. If the RX buffer is empty
- *          an error code will be returned and the app_uart module will generate an event upon 
+ *          an error code will be returned and the app_uart module will generate an event upon
  *          reception of the first byte which is added to the RX buffer.
  *
  * @param[out] p_byte    Pointer to an address where next byte received on the UART will be copied.
@@ -238,10 +239,10 @@
  *
  * @details If flow control is disabled, the state is assumed to always be APP_UART_CONNECTED.
  *
- *          When using flow control the state will be controlled by the CTS. If CTS is set active 
+ *          When using flow control the state will be controlled by the CTS. If CTS is set active
  *          by the remote side, or the app_uart module is in the process of transmitting a byte,
  *          app_uart is in APP_UART_CONNECTED state. If CTS is set inactive by remote side app_uart
- *          will not get into APP_UART_DISCONNECTED state until the last byte in the TXD register 
+ *          will not get into APP_UART_DISCONNECTED state until the last byte in the TXD register
  *          is fully transmitted.
  *
  *          Internal states in the state machine are mapped to the general connected/disconnected
@@ -280,6 +281,6 @@
 uint32_t app_uart_close(uint16_t app_uart_id);
 
 
-#endif // APP_UART_H__
+#endif //APP_UART_H__
 
 /** @} */
--- a/nordic/nrf-sdk/app_common/app_util.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/app_common/app_util.h	Mon Jul 07 13:43:31 2014 +0100
@@ -23,17 +23,8 @@
 #define APP_UTIL_H__
 
 #include <stdint.h>
-#include "nordic_global.h"
+#include <stdbool.h>
 #include "compiler_abstraction.h"
-#include "nrf51.h"
-#include "app_error.h"
-
-/**@brief The interrupt priorities available to the application while the softdevice is active. */
-typedef enum
-{
-    APP_IRQ_PRIORITY_HIGH = 1,
-    APP_IRQ_PRIORITY_LOW  = 3
-} app_irq_priority_t;
 
 enum
 {
@@ -42,12 +33,6 @@
     UNIT_10_MS    = 10000                               /**< Number of microseconds in 10 milliseconds. */
 };
 
-#define NRF_APP_PRIORITY_THREAD    4                    /**< "Interrupt level" when running in Thread Mode. */
-
-/**@cond NO_DOXYGEN */
-#define EXTERNAL_INT_VECTOR_OFFSET 16
-/**@endcond */
-
 /**@brief Macro for doing static (i.e. compile time) assertion.
  *
  * @note If the assertion fails when compiling using Keil, the compiler will report error message
@@ -63,7 +48,12 @@
  * @param[in]   EXPR   Constant expression to be verified.
  */
 
+#if defined(__GNUC__)
+#define STATIC_ASSERT(EXPR) typedef char __attribute__((unused)) static_assert_failed[(EXPR) ? 1 : -1]
+#else
 #define STATIC_ASSERT(EXPR) typedef char static_assert_failed[(EXPR) ? 1 : -1]
+#endif
+
 
 /**@brief type for holding an encoded (i.e. little endian) 16 bit unsigned integer. */
 typedef uint8_t uint16_le_t[2];
@@ -77,48 +67,6 @@
     uint16_t  size;                 /**< Number of array entries. */
     uint8_t * p_data;               /**< Pointer to array entries. */
 } uint8_array_t;
-
-/**@brief Macro for entering a critical region.
- *
- * @note Due to implementation details, there must exist one and only one call to
- *       CRITICAL_REGION_EXIT() for each call to CRITICAL_REGION_ENTER(), and they must be located
- *       in the same scope.
- */
-#define CRITICAL_REGION_ENTER()                                                             \
-    {                                                                                       \
-        uint8_t IS_NESTED_CRITICAL_REGION = 0;                                              \
-        uint32_t CURRENT_INT_PRI = current_int_priority_get();                              \
-        if (CURRENT_INT_PRI != APP_IRQ_PRIORITY_HIGH)                                       \
-        {                                                                                   \
-            uint32_t ERR_CODE = sd_nvic_critical_region_enter(&IS_NESTED_CRITICAL_REGION);  \
-            if (ERR_CODE == NRF_ERROR_SOFTDEVICE_NOT_ENABLED)                               \
-            {                                                                               \
-                __disable_irq();                                                            \
-            }                                                                               \
-            else                                                                            \
-            {                                                                               \
-                APP_ERROR_CHECK(ERR_CODE);                                                  \
-            }                                                                               \
-        }        
-    
-/**@brief Macro for leaving a critical region.
- *
- * @note Due to implementation details, there must exist one and only one call to
- *       CRITICAL_REGION_EXIT() for each call to CRITICAL_REGION_ENTER(), and they must be located
- *       in the same scope.
- */
-#define CRITICAL_REGION_EXIT()                                                              \
-        if (CURRENT_INT_PRI != APP_IRQ_PRIORITY_HIGH)                                       \
-        {                                                                                   \
-            uint32_t ERR_CODE;                                                              \
-            __enable_irq();                                                                 \
-            ERR_CODE = sd_nvic_critical_region_exit(IS_NESTED_CRITICAL_REGION);             \
-            if (ERR_CODE != NRF_ERROR_SOFTDEVICE_NOT_ENABLED)                               \
-            {                                                                               \
-                APP_ERROR_CHECK(ERR_CODE);                                                  \
-            }                                                                               \
-        }                                                                                   \
-    }
     
 /**@brief Perform rounded integer division (as opposed to truncating the result).
  *
@@ -215,29 +163,7 @@
              (((uint32_t)((uint8_t *)p_encoded_data)[2]) << 16) |
              (((uint32_t)((uint8_t *)p_encoded_data)[3]) << 24 ));
 }
-
     
-/**@brief Function for finding the current interrupt level.
- *
- * @return   Current interrupt level.
- * @retval   APP_IRQ_PRIORITY_HIGH    We are running in Application High interrupt level.
- * @retval   APP_IRQ_PRIORITY_LOW     We are running in Application Low interrupt level.
- * @retval   APP_IRQ_PRIORITY_THREAD  We are running in Thread Mode.
- */
-static __INLINE uint8_t current_int_priority_get(void)
-{
-    uint32_t isr_vector_num = (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk);
-    if (isr_vector_num > 0)
-    {
-        int32_t irq_type = ((int32_t)isr_vector_num - EXTERNAL_INT_VECTOR_OFFSET);
-        return (NVIC_GetPriority((IRQn_Type)irq_type) & 0xFF);
-    }
-    else
-    {
-        return NRF_APP_PRIORITY_THREAD;
-    }
-}
-
 /** @brief Function for converting the input voltage (in milli volts) into percentage of 3.0 Volts.
  *
  *  @details The calculation is based on a linearized version of the battery's discharge
@@ -298,7 +224,7 @@
  */
 static __INLINE bool is_word_aligned(void * p)
 {
-    return (((uint32_t)p & 0x00000003) == 0);
+    return (((uintptr_t)p & 0x03) == 0);
 }
 
 #endif // APP_UTIL_H__
--- a/nordic/nrf-sdk/app_common/crc16.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/app_common/crc16.h	Mon Jul 07 13:43:31 2014 +0100
@@ -23,7 +23,6 @@
 #define CRC16_H__
 
 #include <stdint.h>
-#include "nordic_global.h"
 
 /**@brief Function for calculating CRC-16 in blocks.
  *
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nordic/nrf-sdk/app_common/hal_transport.h	Mon Jul 07 13:43:31 2014 +0100
@@ -0,0 +1,227 @@
+/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ *
+ */
+ 
+/**@file
+ *
+ * @defgroup hci_transport HCI Transport
+ * @{
+ * @ingroup  app_common
+ *
+ * @brief    HCI transport module implementation.
+ *
+ * This module implements certain specific features from the three-wire UART transport layer, 
+ * defined by the Bluetooth specification version 4.0 [Vol 4] part D.
+ *
+ * \par Features supported
+ * - Transmission and reception of Vendor Specific HCI packet type application packets.
+ * - Transmission and reception of reliable packets: defined by chapter 6 of the specification.
+ *
+ * \par Features not supported
+ * - Link establishment procedure: defined by chapter 8 of the specification.
+ * - Low power: defined by chapter 9 of the specification. 
+ *
+ * \par Implementation specific behaviour
+ * - As Link establishment procedure is not supported following static link configuration parameters
+ * are used:
+ * + TX window size is 1.
+ * + 16 bit CCITT-CRC must be used.
+ * + Out of frame software flow control not supported.
+ * + Parameters specific for resending reliable packets are compile time configurable (clarifed 
+ * later in this document).
+ * + Acknowledgement packet transmissions are not timeout driven , meaning they are delivered for 
+ * transmission within same context which the corresponding application packet was received. 
+ *
+ * \par Implementation specific limitations
+ * Current implementation has the following limitations which will have impact to system wide 
+ * behaviour:
+ * - Delayed acknowledgement scheduling not implemented: 
+ * There exists a possibility that acknowledgement TX packet and application TX packet will collide 
+ * in the TX pipeline having the end result that acknowledgement packet will be excluded from the TX 
+ * pipeline which will trigger the retransmission algorithm within the peer protocol entity.
+ * - Delayed retransmission scheduling not implemented:  
+ * There exists a possibility that retransmitted application TX packet and acknowledgement TX packet
+ * will collide in the TX pipeline having the end result that retransmitted application TX packet 
+ * will be excluded from the TX pipeline.
+ * - Processing of the acknowledgement number from RX application packets:
+ * Acknowledgement number is not processed from the RX application packets having the end result 
+ * that unnecessary application packet retransmissions can occur.
+ *
+ * The application TX packet processing flow is illustrated by the statemachine below. 
+ *
+ * @image html hci_transport_tx_sm.png "TX - application packet statemachine"
+ *
+ * \par Component specific configuration options
+ *
+ * The following compile time configuration options are available, and used to configure the 
+ * application TX packet retransmission interval, in order to suite various application specific 
+ * implementations:
+ * - MAC_PACKET_SIZE_IN_BITS Maximum size of a single application packet in bits. 
+ * - USED_BAUD_RATE Used uart baudrate. 
+ *
+ * The following compile time configuration option is available to configure module specific 
+ * behaviour:
+ * - MAX_RETRY_COUNT Max retransmission retry count for applicaton packets.
+ */
+ 
+#ifndef HCI_TRANSPORT_H__
+#define HCI_TRANSPORT_H__
+
+#include <stdint.h>
+#include "nrf_error.h"
+
+#define HCI_TRANSPORT_PKT_HEADER_SIZE  (2)   /**< Size of transport packet header */
+
+/**@brief Generic event callback function events. */
+typedef enum
+{
+    HCI_TRANSPORT_RX_RDY,               /**< An event indicating that RX packet is ready for read. */
+    HCI_TRANSPORT_EVT_TYPE_MAX          /**< Enumeration upper bound. */  
+} hci_transport_evt_type_t;
+
+/**@brief Struct containing events from the Transport layer.
+ */
+typedef struct
+{
+    hci_transport_evt_type_t evt_type;  /**< Type of event. */
+} hci_transport_evt_t;
+
+/**@brief Transport layer generic event callback function type.
+ *
+ * @param[in] event                Transport layer event.  
+ */
+typedef void (*hci_transport_event_handler_t)(hci_transport_evt_t event);
+
+/**@brief TX done event callback function result codes. */
+typedef enum
+{
+    HCI_TRANSPORT_TX_DONE_SUCCESS,      /**< Transmission success, peer transport entity has acknowledged the transmission. */
+    HCI_TRANSPORT_TX_DONE_FAILURE       /**< Transmission failure. */    
+} hci_transport_tx_done_result_t;
+
+/**@brief Transport layer TX done event callback function type.
+ *
+ * @param[in] result                TX done event result code. 
+ */
+typedef void (*hci_transport_tx_done_handler_t)(hci_transport_tx_done_result_t result);
+
+/**@brief Function for registering a generic event handler.
+ *
+ * @note Multiple registration requests will overwrite any possible existing registration. 
+ *
+ * @param[in] event_handler         The function to be called by the transport layer upon an event.
+ *
+ * @retval NRF_SUCCESS              Operation success.
+ * @retval NRF_ERROR_NULL           Operation failure. NULL pointer supplied.    
+ */
+uint32_t hci_transport_evt_handler_reg(hci_transport_event_handler_t event_handler);
+
+/**@brief Function for registering a handler for TX done event.
+ *
+ * @note Multiple registration requests will overwrite any possible existing registration. 
+ *
+ * @param[in] event_handler         The function to be called by the transport layer upon TX done
+ *                                  event.
+ *
+ * @retval NRF_SUCCESS              Operation success.
+ * @retval NRF_ERROR_NULL           Operation failure. NULL pointer supplied.    
+ */
+uint32_t hci_transport_tx_done_register(hci_transport_tx_done_handler_t event_handler);
+                                        
+/**@brief Function for opening the transport channel and initializing the transport layer.
+ *
+ * @warning Must not be called for a channel which has been allready opened. 
+ * 
+ * @retval NRF_SUCCESS              Operation success.
+ * @retval NRF_ERROR_INTERNAL       Operation failure. Internal error ocurred. 
+ */
+uint32_t hci_transport_open(void);
+
+/**@brief Function for closing the transport channel.
+ *
+ * @note Can be called multiple times and also for not opened channel.
+ * 
+ * @retval NRF_SUCCESS              Operation success.  
+ */
+uint32_t hci_transport_close(void);
+
+/**@brief Function for allocating tx packet memory.
+ * 
+ * @param[out] pp_memory            Pointer to the packet data.
+ * 
+ * @retval NRF_SUCCESS              Operation success. Memory was allocated.
+ * @retval NRF_ERROR_NO_MEM         Operation failure. No memory available.
+ * @retval NRF_ERROR_NULL           Operation failure. NULL pointer supplied.   
+ */
+uint32_t hci_transport_tx_alloc(uint8_t ** pp_memory);
+
+/**@brief Function for freeing tx packet memory.
+ *
+ * @note Memory management works in FIFO principle meaning that free order must match the alloc 
+ *       order.
+ * 
+ * @retval NRF_SUCCESS              Operation success. Memory was freed.   
+ */
+uint32_t hci_transport_tx_free(void);
+
+/**@brief Function for writing a packet.
+ *
+ * @note Completion of this method does not guarantee that actual peripheral transmission would 
+ *       have completed. 
+ *
+ * @note In case of 0 byte packet length write request, message will consist of only transport 
+ *       module specific headers.  
+ *
+ * @note The buffer provided to this function must be allocated through @ref hci_transport_tx_alloc
+ *       function.
+ *
+ * @retval NRF_SUCCESS              Operation success. Packet was added to the transmission queue 
+ *                                  and an event will be send upon transmission completion. 
+ * @retval NRF_ERROR_NO_MEM         Operation failure. Transmission queue is full and packet was not
+ *                                  added to the transmission queue. User should wait for 
+ *                                  a appropriate event prior issuing this operation again.
+ * @retval NRF_ERROR_DATA_SIZE      Operation failure. Packet size exceeds limit.
+ * @retval NRF_ERROR_NULL           Operation failure. NULL pointer supplied.  
+ * @retval NRF_ERROR_INVALID_STATE  Operation failure. Channel is not open.
+ * @retval NRF_ERROR_INVALID_ADDR   Operation failure. Buffer provided is not allocated through
+ *                                  hci_transport_tx_alloc function.
+ */
+uint32_t hci_transport_pkt_write(const uint8_t * p_buffer, uint16_t length);
+
+/**@brief Function for extracting received packet.
+ *
+ * @note Extracted memory can't be reused by the underlying transport layer untill freed by call to 
+ *       hci_transport_rx_pkt_consume().
+ *
+ * @param[out] pp_buffer            Pointer to the packet data.
+ * @param[out] p_length             Length of packet data in bytes.  
+ *
+ * @retval NRF_SUCCESS              Operation success. Packet was extracted. 
+ * @retval NRF_ERROR_NO_MEM         Operation failure. No packet available to extract.
+ * @retval NRF_ERROR_NULL           Operation failure. NULL pointer supplied.   
+ */
+uint32_t hci_transport_rx_pkt_extract(uint8_t ** pp_buffer, uint16_t * p_length);
+
+/**@brief Function for consuming extracted packet described by p_buffer.
+ *
+ * RX memory pointed to by p_buffer is freed and can be reused by the underlying transport layer.
+ *
+ * @param[in] p_buffer              Pointer to the buffer that has been consumed.
+ *
+ * @retval NRF_SUCCESS              Operation success. 
+ * @retval NRF_ERROR_NO_MEM         Operation failure. No packet available to consume. 
+ * @retval NRF_ERROR_INVALID_ADDR   Operation failure. Not a valid pointer. 
+ */
+uint32_t hci_transport_rx_pkt_consume(uint8_t * p_buffer);
+
+#endif // HCI_TRANSPORT_H__
+
+/** @} */
--- a/nordic/nrf-sdk/app_common/hci_mem_pool.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/app_common/hci_mem_pool.h	Mon Jul 07 13:43:31 2014 +0100
@@ -46,7 +46,6 @@
 #define HCI_MEM_POOL_H__
 
 #include <stdint.h>
-#include "nordic_global.h"
 #include "nrf_error.h"
 
 /**@brief Function for opening the module.
--- a/nordic/nrf-sdk/app_common/hci_slip.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/app_common/hci_slip.h	Mon Jul 07 13:43:31 2014 +0100
@@ -32,7 +32,6 @@
 #define HCI_SLIP_H__
 
 #include <stdint.h>
-#include "nordic_global.h"
 
 /**@brief Event types from the SLIP Layer. */
 typedef enum
--- a/nordic/nrf-sdk/app_common/hci_transport.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/app_common/hci_transport.h	Mon Jul 07 13:43:31 2014 +0100
@@ -76,7 +76,6 @@
 #define HCI_TRANSPORT_H__
 
 #include <stdint.h>
-#include "nordic_global.h"
 #include "nrf_error.h"
 
 /**@brief Generic event callback function events. */
--- a/nordic/nrf-sdk/app_common/pstorage.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/app_common/pstorage.h	Mon Jul 07 13:43:31 2014 +0100
@@ -25,7 +25,6 @@
 #ifndef PSTORAGE_H__
 #define PSTORAGE_H__
 
-#include "nordic_global.h"
 #include "pstorage_platform.h"
 
 
@@ -39,10 +38,11 @@
  *           registered with the interface to report any error during an persistent storage access
  *           operation or any general error that may occur in the interface.
  */
- #define PSTORAGE_ERROR_OP_CODE    0x01  /**< General Error Code */
- #define PSTORAGE_STORE_OP_CODE    0x02  /**< Error when Store Operation was requested */
- #define PSTORAGE_LOAD_OP_CODE     0x03  /**< Error when Load Operation was requested */
- #define PSTORAGE_CLEAR_OP_CODE    0x04  /**< Error when Clear Operation was requested */
+#define PSTORAGE_ERROR_OP_CODE    0x01  /**< General Error Code */
+#define PSTORAGE_STORE_OP_CODE    0x02  /**< Error when Store Operation was requested */
+#define PSTORAGE_LOAD_OP_CODE     0x03  /**< Error when Load Operation was requested */
+#define PSTORAGE_CLEAR_OP_CODE    0x04  /**< Error when Clear Operation was requested */
+#define PSTORAGE_UPDATE_OP_CODE   0x05  /**< Update an already touched storage block */
 
 /**@} */
 
@@ -56,22 +56,21 @@
 /**@brief Persistent Storage Error Reporting Callback
  *
  * @details Persistent Storage Error Reporting Callback that is used by the interface to report
- *          success or failure of a flash operation. Therefore, for store operation or clear
- *          operations, that take time, application can know when the procedure was complete.
- *          For store operation, since no data copy is made, receiving a success or failure
- *          notification, indicated by the reason parameter of callback is an indication that
- *          the resident memory could now be reused or freed, as the case may be.
- *          This callback is not received for load operation.
+ *          success or failure of a flash operation. Therefore, for any operations, application 
+ *          can know when the procedure was complete. For store operation, since no data copy 
+ *          is made, receiving a success or failure notification, indicated by the reason 
+ *          parameter of callback is an indication that the resident memory could now be reused 
+ *          or freed, as the case may be.
  * 
- * @param handle   Identifies module and block for which callback is received.
- * @param op_code  Identifies the operation for which the event is notified.
- * @param result   Identifies the result of flash access operation.
- *                 NRF_SUCCESS implies, operation succeeded.
- * @param p_data   Identifies the application data pointer. In case of store operation, this points
- *                 to the resident source of application memory that application can now free or 
- *                 reuse. In case of clear, this is NULL as no application pointer is needed for
- *                 this operation.
- * @param data_len Length data application had provided for the operation.
+ * @param[in] handle   Identifies module and block for which callback is received.
+ * @param[in] op_code  Identifies the operation for which the event is notified.
+ * @param[in] result   Identifies the result of flash access operation.
+ *                     NRF_SUCCESS implies, operation succeeded.
+ * @param[in] p_data   Identifies the application data pointer. In case of store operation, this 
+ *                     points to the resident source of application memory that application can now 
+ *                     free or reuse. In case of clear, this is NULL as no application pointer is 
+ *                     needed for this operation.
+ * @param[in] data_len Length data application had provided for the operation.
  * 
  */
 typedef void (*pstorage_ntf_cb_t)(pstorage_handle_t *  p_handle,
@@ -81,19 +80,16 @@
                                   uint32_t             data_len);
 
 
-typedef struct ps_module_param
+typedef struct
 {
-
-    pstorage_ntf_cb_t      cb;             /**< Callback registered with the module to be notified of any error occurring in persistent memory management */
-    pstorage_size_t        block_size;     /**< Desired block size for persistent memory storage, for example, if a module has a table with 10 entries, each entry is size 64 bytes,
-                                            *   it can request 10 blocks with block size 64 bytes. On the other hand, the module can also request one block of size 640 based on
-                                            *   how it would like to access or alter memory in persistent memory.
-                                            *   First option is preferred when single entries that need to be updated often when having no impact on the other entries.
-                                            *   While second option is preferred when entries of table are not changed on individually but have common point of loading and storing
-                                            *   data.
-                                            */
-    pstorage_size_t        block_count;    /** Number of blocks requested by the module, minimum values is 1. */
-
+    pstorage_ntf_cb_t cb;             /**< Callback registered with the module to be notified of any error occurring in persistent memory management */
+    pstorage_size_t   block_size;     /**< Desired block size for persistent memory storage, for example, if a module has a table with 10 entries, each entry is size 64 bytes,
+                                       *   it can request 10 blocks with block size 64 bytes. On the other hand, the module can also request one block of size 640 based on
+                                       *   how it would like to access or alter memory in persistent memory.
+                                       *   First option is preferred when single entries that need to be updated often when having no impact on the other entries.
+                                       *   While second option is preferred when entries of table are not changed on individually but have common point of loading and storing
+                                       *   data. */
+    pstorage_size_t   block_count;    /** Number of blocks requested by the module, minimum values is 1. */
 } pstorage_module_param_t;
 
 /**@} */
@@ -112,7 +108,7 @@
  *
  * @details Initializes module. To be called once before any other APIs of the module are used.
  *
- * @retval   NRF_SUCCESS on success, otherwise an appropriate error code.
+ * @retval     NRF_SUCCESS             on success, else an error code indicating reason for failure.
  */
 uint32_t pstorage_init(void);
 
@@ -120,10 +116,11 @@
 /**@brief Register with persistent storage interface.
  *
  * @param[in]  p_module_param Module registration param.
- * @param[out] p_block_id Block identifier to identify persistent memory blocks in case registration
- *             succeeds. Application is expected to use the block ids for subsequent operations on
- *             requested persistent memory. Maximum registrations permitted is determined by
- *             configuration parameter PSTORAGE_MAX_APPLICATIONS.
+ * @param[out] p_block_id     Block identifier to identify persistent memory blocks in case 
+ *                            registration succeeds. Application is expected to use the block ids 
+ *                            for subsequent operations on requested persistent memory. Maximum 
+ *                            registrations permitted is determined by configuration parameter 
+ *                            PSTORAGE_MAX_APPLICATIONS. 
  *             In case more than one memory blocks are requested, the identifier provided here is
  *             the base identifier for the first block and to identify subsequent block,
  *             application shall use \@ref pstorage_block_identifier_get with this base identifier
@@ -132,14 +129,14 @@
  *             \@ref pstorage_block_identifier_get with based id and provide a block number of 5.
  *             This way application is only expected to remember the base block identifier.
  *
- * @retval     NRF_SUCCESS on success, otherwise an appropriate error code.
+ * @retval     NRF_SUCCESS             on success, else an error code indicating reason for failure.
  * @retval     NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
- * @retval     NRF_ERROR_NULL if NULL parameter has been passed.
+ * @retval     NRF_ERROR_NULL          if NULL parameter has been passed.
  * @retval     NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
- * @retval     NRF_ERROR_NO_MEM in case no more registrations can be supported.
+ * @retval     NRF_ERROR_NO_MEM        in case no more registrations can be supported.
  */
 uint32_t pstorage_register(pstorage_module_param_t * p_module_param,
-                           pstorage_handle_t*        p_block_id);
+                           pstorage_handle_t *       p_block_id);
 
 
 /**
@@ -156,13 +153,13 @@
  *          \@ref pstorage_block_identifier_get with based id and provide a block number of 5.
  *          This way application is only expected to remember the base block identifier.
  *
- * @param[in]  p_base_id Base block id received at the time of registration.
- * @param[in]  block_num Block Number, with first block numbered zero.
+ * @param[in]  p_base_id  Base block id received at the time of registration.
+ * @param[in]  block_num  Block Number, with first block numbered zero.
  * @param[out] p_block_id Block identifier for the block number requested in case the API succeeds.
  *
- * @retval     NRF_SUCCESS on success, else an error code indicating reason for failure.
+ * @retval     NRF_SUCCESS             on success, else an error code indicating reason for failure.
  * @retval     NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
- * @retval     NRF_ERROR_NULL if NULL parameter has been passed.
+ * @retval     NRF_ERROR_NULL          if NULL parameter has been passed.
  * @retval     NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
  */
 uint32_t pstorage_block_identifier_get(pstorage_handle_t * p_base_id,
@@ -182,12 +179,12 @@
  *                    write 20 bytes at offset of 12, then this field should be set to 12.
  *                    Should be word aligned.
  *
- * @retval     NRF_SUCCESS on success, otherwise an appropriate error code.
+ * @retval     NRF_SUCCESS             on success, else an error code indicating reason for failure.
  * @retval     NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
- * @retval     NRF_ERROR_NULL if NULL parameter has been passed.
+ * @retval     NRF_ERROR_NULL          if NULL parameter has been passed.
  * @retval     NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
- * @retval     NRF_ERROR_INVALID_ADDR in case data address 'p_src' is not aligned.
- * @retval     NRF_ERROR_NO_MEM in case request cannot be processed.
+ * @retval     NRF_ERROR_INVALID_ADDR  in case data address 'p_src' is not aligned.
+ * @retval     NRF_ERROR_NO_MEM        in case request cannot be processed.
  *
  * @warning    No copy of the data is made, and hence memory provided for data source to be written
  *             to flash cannot be freed or reused by the application until this procedure
@@ -199,6 +196,34 @@
                         pstorage_size_t     size,
                         pstorage_size_t     offset);
 
+/**@brief Routine to update persistently stored data of length 'size' contained in 'p_src' address
+ *        in storage module at 'p_dest' address.
+ *
+ * @param[in]  p_dest Destination address where data is to be updated.
+ * @param[in]  p_src  Source address containing data to be stored. API assumes this to be resident
+ *                    memory and no intermediate copy of data is made by the API.
+ * @param[in]  size   Size of data to be stored expressed in bytes. Should be word aligned.
+ * @param[in]  offset Offset in bytes to be applied when writing to the block.
+ *                    For example, if within a block of 100 bytes, application wishes to
+ *                    write 20 bytes at offset of 12, then this field should be set to 12.
+ *                    Should be word aligned.
+ *
+ * @retval     NRF_SUCCESS             on success, else an error code indicating reason for failure.
+ * @retval     NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
+ * @retval     NRF_ERROR_NULL          if NULL parameter has been passed.
+ * @retval     NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
+ * @retval     NRF_ERROR_INVALID_ADDR  in case data address 'p_src' is not aligned.
+ * @retval     NRF_ERROR_NO_MEM        in case request cannot be processed.
+ *
+ * @warning    No copy of the data is made, and hence memory provided for data source to be written
+ *             to flash cannot be freed or reused by the application until this procedure
+ *             is complete. End of this procedure is notified to the application using the
+ *             notification callback registered by the application.
+ */
+uint32_t pstorage_update(pstorage_handle_t * p_dest,
+                         uint8_t *           p_src,
+                         pstorage_size_t     size,
+                         pstorage_size_t     offset);
 
 /**@brief Routine to load persistently stored data of length 'size' from 'p_src' address
  *        to 'p_dest' address; Equivalent to Storage Read.
@@ -212,34 +237,36 @@
  *                    load 20 bytes from offset of 12, then this field should be set to 12.
  *                    Should be word aligned.
  *
- *
- * @retval     NRF_SUCCESS on success, otherwise an appropriate error code.
+ * @retval     NRF_SUCCESS             on success, else an error code indicating reason for failure.
  * @retval     NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
- * @retval     NRF_ERROR_NULL if NULL parameter has been passed.
+ * @retval     NRF_ERROR_NULL          if NULL parameter has been passed.
  * @retval     NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
- * @retval     NRF_ERROR_INVALID_ADDR in case data address 'p_dst' is not aligned.
+ * @retval     NRF_ERROR_INVALID_ADDR  in case data address 'p_dst' is not aligned.
+ * @retval     NRF_ERROR_NO_MEM        in case request cannot be processed.
  */
 uint32_t pstorage_load(uint8_t *           p_dest,
                        pstorage_handle_t * p_src,
                        pstorage_size_t     size,
                        pstorage_size_t     offset);
 
-
 /**@brief Routine to clear data in persistent memory.
  *
  * @param[in]  p_base_id Base block identifier in persistent memory that needs to cleared;
  *                       Equivalent to an Erase Operation.
  *
  * @param[in]  size      Size of data to be cleared from persistent memory expressed in bytes.
- *                       This is currently unused. And a clear would mean clearing all blocks,
- *                       however, this parameter is to provision for clearing of certain blocks
- *                       of memory only and not all if need be.
+ *                       This parameter is to provision for clearing of certain blocks
+ *                       of memory, or all memory blocks in a registered module. If the total size 
+ *                       of the application module is used (blocks * block size) in combination with
+ *                       the identifier for the first block in the module, all blocks in the 
+ *                       module will be erased.
  *
- * @retval     NRF_SUCCESS on success, otherwise an appropriate error code.
+ * @retval     NRF_SUCCESS             on success, else an error code indicating reason for failure.
  * @retval     NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
- * @retval     NRF_ERROR_NULL if NULL parameter has been passed.
+ * @retval     NRF_ERROR_NULL          if NULL parameter has been passed.
  * @retval     NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
- * @retval     NRF_ERROR_NO_MEM in case request cannot be processed.
+ * @retval     NRF_ERROR_INVALID_ADDR  in case data address 'p_dst' is not aligned.
+ * @retval     NRF_ERROR_NO_MEM        in case request cannot be processed.
  *
  * @note       Clear operations may take time. This API however, does not block until the clear
  *             procedure is complete. Application is notified of procedure completion using
@@ -248,14 +275,26 @@
  */
 uint32_t pstorage_clear(pstorage_handle_t * p_base_id, pstorage_size_t size);
 
+/**
+ * @brief API to get status of number of pending operations with the module.
+ *
+ * @param[out] p_count Number of storage operations pending with the module, if 0,
+ *                     there are no outstanding requests.
+ *
+ * @retval     NRF_SUCCESS             on success, else an error code indicating reason for failure.
+ * @retval     NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
+ * @retval     NRF_ERROR_NULL          if NULL parameter has been passed.
+ */
+uint32_t pstorage_access_status_get(uint32_t * p_count);
+
 #ifdef PSTORAGE_RAW_MODE_ENABLE
 
 /**@brief      Function for registering with persistent storage interface.
  *
  * @param[in]  p_module_param Module registration param.
- * @param[out] p_block_id Block identifier to identify persistent memory blocks in case 
- *             registration succeeds. Application is expected to use the block ids for subsequent
- *             operations on requested persistent memory.
+ * @param[out] p_block_id     Block identifier to identify persistent memory blocks in case 
+ *                            registration succeeds. Application is expected to use the block ids 
+ *                            for subsequent operations on requested persistent memory.
  *             In case more than one memory blocks are requested, the identifier provided here is
  *             the base identifier for the first block and to identify subsequent block,
  *             application shall use \@ref pstorage_block_identifier_get with this base identifier
@@ -264,11 +303,11 @@
  *             \@ref pstorage_block_identifier_get with based id and provide a block number of 5.
  *             This way application is only expected to remember the base block identifier.
  *
- * @retval     NRF_SUCCESS on success, otherwise an appropriate error code.
+ * @retval     NRF_SUCCESS             on success, else an error code indicating reason for failure.
  * @retval     NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
- * @retval     NRF_ERROR_NULL if NULL parameter has been passed.
+ * @retval     NRF_ERROR_NULL          if NULL parameter has been passed.
  * @retval     NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
- * @retval     NRF_ERROR_NO_MEM in case no more registrations can be supported.
+ * @retval     NRF_ERROR_NO_MEM        in case no more registrations can be supported.
  */
 uint32_t pstorage_raw_register(pstorage_module_param_t * p_module_param,
                                pstorage_handle_t *       p_block_id);
@@ -280,17 +319,17 @@
  * @param[in]  p_src  Source address containing data to be stored. API assumes this to be resident
  *                    memory and no intermediate copy of data is made by the API.
  * @param[in]  size   Size of data to be stored expressed in bytes. Should be word aligned.
- * @param[in]  offset Offset in bytes to be applied when writing to the block. 
+ * @param[in]  offset Offset in bytes to be applied when writing to the block.
  *                    For example, if within a block of 100 bytes, application wishes to
  *                    write 20 bytes at offset of 12, then this field should be set to 12.
  *                    Should be word aligned.
  *
- * @retval     NRF_SUCCESS on success, otherwise an appropriate error code.
+ * @retval     NRF_SUCCESS             on success, else an error code indicating reason for failure.
  * @retval     NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
- * @retval     NRF_ERROR_NULL if NULL parameter has been passed.
+ * @retval     NRF_ERROR_NULL          if NULL parameter has been passed.
  * @retval     NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
- * @retval     NRF_ERROR_INVALID_ADDR in case data address 'p_src' is not aligned.
- * @retval     NRF_ERROR_NO_MEM in case request cannot be processed.
+ * @retval     NRF_ERROR_INVALID_ADDR  in case data address 'p_src' is not aligned.
+ * @retval     NRF_ERROR_NO_MEM        in case request cannot be processed.
  *
  * @warning    No copy of the data is made, and hence memory provided for data source to be written
  *             to flash cannot be freed or reused by the application until this procedure
@@ -304,19 +343,18 @@
 
 /**@brief      Function for clearing data in persistent memory in raw mode.
  *
- * @param[in]  p_base_id Base block identifier in persistent memory that needs to cleared;
- *                       Equivalent to an Erase Operation.
+ * @param[in]  p_dest Base block identifier in persistent memory that needs to cleared;
+ *                    Equivalent to an Erase Operation.
+ * @param[in]  size   Size of data to be cleared from persistent memory expressed in bytes.
+ *                    This is currently unused. And a clear would mean clearing all blocks,
+ *                    however, this parameter is to provision for clearing of certain blocks
+ *                    of memory only and not all if need be.
  *
- * @param[in]  size      Size of data to be cleared from persistent memory expressed in bytes.
- *                       This is currently unused. And a clear would mean clearing all blocks,
- *                       however, this parameter is to provision for clearing of certain blocks
- *                       of memory only and not all if need be.
- *
- * @retval     NRF_SUCCESS on success, otherwise an appropriate error code.
+ * @retval     NRF_SUCCESS             on success, else an error code indicating reason for failure.
  * @retval     NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
- * @retval     NRF_ERROR_NULL if NULL parameter has been passed.
+ * @retval     NRF_ERROR_NULL          if NULL parameter has been passed.
  * @retval     NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
- * @retval     NRF_ERROR_NO_MEM in case request cannot be processed.
+ * @retval     NRF_ERROR_NO_MEM        in case request cannot be processed.
  *
  * @note       Clear operations may take time. This API however, does not block until the clear
  *             procedure is complete. Application is notified of procedure completion using
--- a/nordic/nrf-sdk/ble/ble_advdata.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/ble/ble_advdata.h	Mon Jul 07 13:43:31 2014 +0100
@@ -25,7 +25,6 @@
 #include <stdint.h>
 #include <stdbool.h>
 #include <string.h>
-#include "nordic_global.h"
 #include "ble.h"
 #include "app_util.h"
 
--- a/nordic/nrf-sdk/ble/ble_advdata_parser.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/ble/ble_advdata_parser.h	Mon Jul 07 13:43:31 2014 +0100
@@ -1,7 +1,6 @@
 #ifndef BLE_ADVDATA_PARSER_H_
 #define BLE_ADVDATA_PARSER_H_
 
-#include "nordic_global.h"
 #include "ble_advdata.h"
 
 uint32_t ble_advdata_parse(uint8_t * p_data, uint8_t len, ble_advdata_t * advdata);
--- a/nordic/nrf-sdk/ble/ble_bondmngr.h	Thu Jul 03 10:01:02 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,339 +0,0 @@
-/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
- *
- * The information contained herein is property of Nordic Semiconductor ASA.
- * Terms and conditions of usage are described in detail in NORDIC
- * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
- *
- * Licensees are granted free, non-transferable use of the information. NO
- * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
- * the file.
- *
- */
-
-/** @file
- *
- * @defgroup ble_sdk_lib_bond_manager Bonds and Persistent Data Manager
- * @{
- * @ingroup ble_sdk_lib
- * @brief This module handles multiple bonds and persistent attributes.
- *
- * @details When using <i>Bluetooth</i> low energy, a central device and a peripheral device can
- *          exchange identification information which they are capable of storing in memory (for
- *          example, in non-volatile memory). This information can be used for identity verification
- *          between the devices when they reconnect in the future. This relationship is known as a
- *          'bond'.
- *
- *          <b>Bonding Information:</b>
- *
- *          The S110 SoftDevice handles the BLE on-air transactions necessary to establish a new
- *          bond or to use a previous bond when it reconnects to a bonded central. It is however up
- *          to the application layer to memorize the <i>identification information</i> between
- *          connections and to provide them back to the S110 stack when it detects a re-connection
- *          from a previously bonded central. This identification information is referred to as
- *          Bonding Information in code and the SDK.
- *
- *          <b>System Attributes:</b>
- *
- *          If the application is a GATT server, it stores a set of persistent attributes related
- *          to a connection when bonding with a central. On reconnection with the known bonded
- *          central, the application restores the related persistent attributes in the last known
- *          state back to the S110 SoftDevice. These persistent attributes mainly include the Client
- *          Characteristic Configuration Descriptor (or CCCD, see the <i><b>Bluetooth</b>
- *          Core Specification</i> for more information) states and could include other attributes
- *          in the future. Persistent attributes are referred to as System Attributes in code and
- *          in the SDK documentation.
- *
- *          An application can use the Bonds and Persistent Data Manager module (referred to as the
- *          bond manager)  included in the nRF51 SDK to handle most of the operations related to
- *          the Bonding Information and System Attributes. The bond manager notifies the
- *          application when it's connected to a new bonded central or to a previously bonded central.
- *          The application can use the Bond Manager API to store or load (or restore) the
- *          Bonding Information and System Attributes. The bond manager identifies all the centrals
- *          the application is bonded to and restores their respective Bonding Information and
- *          System Attributes to the S110 stack.
- *
- *          In addition, you can use the bond manager to set up your application to advertise:
- *
- *          - To a given bonded central using directed advertisement.
- *          - To a list of bonded centrals - i.e. using whitelist.
- *
- *          The bond manager automatically writes the Bonding Information to the flash memory when
- *          the bonding procedure to a new central is finished. Upon disconnection, the application
- *          should use the Bond Manager API @ref ble_bondmngr_bonded_centrals_store to write the
- *          latest Bonding Information and System Attributes to flash.
- *
- *          The bond manager provides the API @ref ble_bondmngr_sys_attr_store to allow the
- *          application to write the System Attributes to flash while in a connection. Your
- *          application should call this API when it considers that all CCCDs and other persistent
- *          attributes are in a stable state. This API call will safely fail if System Attributes
- *          data for the current connected central is already present in the flash. The API does so
- *          because a flash write in such a situation would require an erase of flash, which takes a
- *          long time (21 milliseconds) to complete. This may disrupt the radio.
- *
- *          Applications using the Bond Manager must have a configuration file named
- *          ble_bondmngr_cfg.h (see below for details).
- *
- *          Refer to @ref ble_bond_mgr_msc to see the flow of events when connecting to a central
- *          using the Bond Manager
- *
- *
- * @section ble_sdk_lib_bond_manager_cfg Configuration File
- * Applications using the Bond Manager must have a configuration file named ble_bondmngr_cfg.h.
- * Here is an example of this file:
- *
- * @code
- * #ifndef BLE_BONDMNGR_CFG_H__
- * #define BLE_BONDMNGR_CFG_H__
- *
- * #define BLE_BONDMNGR_CCCD_COUNT           1
- * #define BLE_BONDMNGR_MAX_BONDED_CENTRALS  4
- *
- * #endif // BLE_BONDMNGR_CFG_H__
- * @endcode
- *
- * BLE_BONDMNGR_CCCD_COUNT is the number of CCCDs used in the application, and
- * BLE_BONDMNGR_MAX_BONDED_CENTRALS is the maximum number of bonded centrals to be supported by the
- * application.
- */
-
-#ifndef BLE_BONDMNGR_H__
-#define BLE_BONDMNGR_H__
-
-#include <stdint.h>
-#include "nordic_global.h"
-#include "ble.h"
-#include "ble_srv_common.h"
-
-
-/** @defgroup ble_bond_mgr_msc Message Sequence Charts
- * @{
- * @brief Bond Manager interaction with S110 Stack
- * @{
- * @defgroup UNBONDED_CENTRAL Connecting to an unbonded central
- * @image html bond_manager_unbonded_master.jpg Connecting to an unbonded central
- * @defgroup BONDED_CENTRAL Connecting to a bonded central
- * @image html bond_manager_bonded_master.jpg Connecting to a bonded central
- * @}
- * @}
- */
-
-/** @defgroup DEFINES Defines
- *  @brief Macros defined by this module.
- * @{ */
-
-#define INVALID_CENTRAL_HANDLE       (-1)                        /**< Invalid handle, used to indicate that the central is not a known bonded central. */
-
-/** @} */
-
-/** @defgroup ENUMS Enumerations
- *  @brief Enumerations defined by this module.
- * @{ */
-
-/**@brief Bond Manager Module event type. */
-typedef enum
-{
-    BLE_BONDMNGR_EVT_NEW_BOND,                                  /**< New bond has been created. */
-    BLE_BONDMNGR_EVT_CONN_TO_BONDED_CENTRAL,                    /**< Connected to a previously bonded central. */
-    BLE_BONDMNGR_EVT_ENCRYPTED,                                 /**< Current link is encrypted. */
-    BLE_BONDMNGR_EVT_AUTH_STATUS_UPDATED,                       /**< Authentication status updated for current central. */
-    BLE_BONDMNGR_EVT_BOND_FLASH_FULL                            /**< Flash block for storing Bonding Information is full. */
-} ble_bondmngr_evt_type_t;
-
-/** @} */
-
-
-/** @defgroup DATA_STRUCTURES Data Structures
- *  @brief Data Structures defined by this module.
- * @{ */
-
-/**@brief Bond Manager Module event. */
-typedef struct
-{
-    ble_bondmngr_evt_type_t evt_type;                           /**< Type of event. */
-    int8_t                  central_handle;                     /**< Handle to the current central. This is an index to the central list maintained internally by the bond manager. */
-    uint16_t                central_id;                         /**< Identifier to the central. This will be the same as Encryption diversifier of the central (see @ref ble_gap_evt_sec_info_request_t). This value is constant for the duration of the bond. */
-} ble_bondmngr_evt_t;
-
-/** @} */
-
-/** @defgroup TYPEDEFS Typedefs
- *  @brief Typedefs defined by this module.
- * @{ */
-
-/**@brief Bond Manager Module event handler type. */
-typedef void (*ble_bondmngr_evt_handler_t) (ble_bondmngr_evt_t * p_evt);
-
-/** @} */
-
-/** @addtogroup DATA_STRUCTURES
- * @{ */
-
-/**@brief Bond Manager Module init structure. This contains all options and data needed for
- *        initialization of the Bond Manager module. */
-typedef struct
-{
-    uint8_t                     flash_page_num_bond;            /**< Flash page number to use for storing Bonding Information. */
-    uint8_t                     flash_page_num_sys_attr;        /**< Flash page number to use for storing System Attributes. */
-    bool                        bonds_delete;                   /**< TRUE if bonding and System Attributes for all centrals is to be deleted from flash during initialization, FALSE otherwise. */
-    ble_bondmngr_evt_handler_t  evt_handler;                    /**< Event handler to be called for handling events in bond manager. */
-    ble_srv_error_handler_t     error_handler;                  /**< Function to be called in case of an error. */
-} ble_bondmngr_init_t;
-
-/** @} */
-
-
-/** @defgroup FUNCTIONS Functions
- *  @brief Functions/APIs implemented and exposed by this module.
- * @{ */
-
-/**@brief Function for initializing the Bond Manager.
- *
- * @param[in]  p_init  This contains information needed to initialize this module.
- *
- * @return     NRF_SUCCESS on successful initialization, otherwise an error code.
- */
-uint32_t ble_bondmngr_init(ble_bondmngr_init_t * p_init);
-
-/**@brief Function for handling all events from the BLE stack that relate to this module.
- *
- * @param[in]  p_ble_evt  The event received from the BLE stack.
- *
- * @return     NRF_SUCCESS if all operations went successfully,
- *             NRF_ERROR_NO_MEM if the maximum number of bonded centrals has been reached.
- *             Other error codes in other situations.
- */
-void ble_bondmngr_on_ble_evt(ble_evt_t * p_ble_evt);
-
-/**@brief Function for storing the bonded centrals data including bonding info and System Attributes into
- *          flash memory.
- *
- * @details If the data to be written is different from the existing data, this function erases the
- *          flash pages before writing to flash.
- *
- * @warning This function could prevent the radio from running. Therefore it MUST be called ONLY
- *          when the application knows that the <i>Bluetooth</i> radio is not active. An example of
- *          such a state is when the application has received the Disconnected event and has not yet
- *          started advertising. <b>If it is called in any other state, or if it is not called at
- *          all, the behavior is undefined.</b>
- *
- * @return  NRF_SUCCESS on success, an error_code otherwise.
- */
-uint32_t ble_bondmngr_bonded_centrals_store(void);
-
-/**@brief Function for deleting the bonded central database from flash.
- *
- * @details After calling this function you should call ble_bondmngr_init() to re-initialize the
- *          RAM database.
- *
- * @return  NRF_SUCCESS on success, an error_code otherwise.
- */
-uint32_t ble_bondmngr_bonded_centrals_delete(void);
-
-/**@brief Function for getting the whitelist containing all currently bonded centrals.
- *
- * @details     This function populates the whitelist with either the IRKs or the public adresses
- *              of all bonded centrals.
- *
- * @param[out]  p_whitelist  Whitelist structure with all bonded centrals.
- *
- * @return      NRF_SUCCESS on success, an error_code otherwise.
- */
-uint32_t ble_bondmngr_whitelist_get(ble_gap_whitelist_t * p_whitelist);
-
-/**@brief Function for getting the central's address corresponding to a given central_handle.
- *
- * @note        This function returns NRF_ERROR_INVALID_PARAM if the given central has a private
- *              address.
- *
- * @param[in]   central_handle  Central's handle.
- * @param[out]  p_central_addr  Pointer to the central's address which can be used for
- *                             directed advertising.
- */
-uint32_t ble_bondmngr_central_addr_get(int8_t central_handle, ble_gap_addr_t * p_central_addr);
-
-/**@brief Function for storing the System Attributes of a newly connected central.
- *
- * @details This function fetches the System Attributes of the current central from the stack, adds
- *          it to the database in memory, and also stores it in the flash (without erasing any
- *          flash page).
- *          This function is intended to facilitate the storage of System Attributes when connected
- *          to new central (whose System Attributes are NOT yet stored in flash) even in connected
- *          state without affecting radio link. This function can, for example, be called after the
- *          CCCD is written by a central. The function will succeed if the central is a new central.
- *          See @ref ble_sdk_app_hids_keyboard or @ref ble_sdk_app_hids_mouse for sample usage.
- *
- * @return  NRF_SUCCESS on success, otherwise an error code.
- *          NRF_ERROR_INVALID_STATE is returned if the System Attributes of the current central is
- *          already present in the flash because it is a previously known central.
- */
-uint32_t ble_bondmngr_sys_attr_store(void);
-
-/**@brief Function for fetching the identifiers of known centrals.
- *
- * @details         This function fetches the identifiers of the centrals that are currently in the
- *                  database, or in other words, known to the bond manager.
- *
- * @param[out]      p_central_ids   Pointer to the array of central identifiers. It is recommended
- *                                  that the length of this array be equal to
- *                                  MAX_NUMBER_OF_BONDED_CENTRALS * 2 bytes. If value of this pointer
- *                                  is NULL, only the number of centrals in the database will be
- *                                  filled in p_length. This can be used to find out the
- *                                  required size of the array pointed to by p_central_ids in
- *                                  a subsequent call.
- * @param[in, out]  p_length        Pointer to the length of p_central_ids array provided as
- *                                  input. On return, this function will write the number of central
- *                                  identifiers found to p_length
- *
- * @return          NRF_SUCCESS on success.
- *                  NRF_ERROR_NULL if the input parameter p_length is NULL.
- *                  NRF_ERROR_INVALID_STATE is returned if the bond manager was not initialized.
- *                  NRF_ERROR_DATA_SIZE is returned if the length of the input parameter
- *                  p_central_ids provided is not enough to fit in all the central identifiers in the
- *                  database.
- */
-uint32_t ble_bondmngr_central_ids_get(uint16_t * p_central_ids, uint16_t * p_length);
-
-/**@brief Function for deleting a single central from the database.
- * @details     This function deletes the Bonding Information and System Attributes of a single
- *              central from the flash.
- *              The application can use the @ref ble_bondmngr_central_ids_get function to fetch the
- *              identifiers of centrals present in the database and then call this function.
- *
- * @warning     This function could prevent the radio from running. Therefore it MUST be called ONLY
- *              when the application knows that the <i>Bluetooth</i> radio is not active. An example
- *              of such a state could be when the application is not in a connected state AND is
- *              also not advertising. <b>If it is called in any other state, the behavior is
- *              undefined.</b>
- *
- * @param[in]   central_id   Identifier of the central to be deleted.
- *
- * @return      NRF_SUCCESS on success.
- *              NRF_ERROR_INVALID_STATE is returned if the bond manager was not initialized.
- *              NRF_ERROR_NOT_FOUND if the central with the given identifier is not found in the
- *              database.
- */
-uint32_t ble_bondmngr_bonded_central_delete(uint16_t central_id);
-
-/**@brief Function to verify encryption status link with bonded central is encrypted or not.
- * @details     This function provides status of encrption of the link with a bonded central.
- *              Its is recommended that the application can use the
- *              @ref ble_bondmngr_central_ids_get function to verify if the central is in the
- *              database and then call this function.
- *
- * @warning     Currently the central id paramater is unused and is added only for future extension.
- *              As, today only one link is permitted for the peripheral device, status of current
- *              link is provided. In future, with more possibilities in the topology, central_id
- *              will be needed to identify the central.
- *
- * @param[out]  status    Status of encryption, true implies link encrypted.
- *
- * @return      NRF_SUCCESS on success.
- *              NRF_ERROR_INVALID_STATE is returned if the bond manager was not initialized.
- */
-uint32_t ble_bondmngr_is_link_encrypted(bool * status);
-
-/** @} */
-
-#endif // BLE_BONDMNGR_H__
-
-/** @} */
--- a/nordic/nrf-sdk/ble/ble_central_bondmngr.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/ble/ble_central_bondmngr.h	Mon Jul 07 13:43:31 2014 +0100
@@ -1,7 +1,6 @@
 #ifndef __BLE_CENTRAL_BONDMNGR_H_
 #define __BLE_CENTRAL_BONDMNGR_H_
 
-#include "nordic_global.h"
 #include "ble.h"
 #include "ble_gap.h"
 
--- a/nordic/nrf-sdk/ble/ble_conn_params.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/ble/ble_conn_params.h	Mon Jul 07 13:43:31 2014 +0100
@@ -22,7 +22,6 @@
 #define BLE_CONN_PARAMS_H__
 
 #include <stdint.h>
-#include "nordic_global.h"
 #include "ble.h"
 #include "ble_srv_common.h"
 
@@ -52,7 +51,7 @@
     uint8_t                       max_conn_params_update_count;     /**< Number of attempts before giving up the negotiation. */
     uint16_t                      start_on_notify_cccd_handle;      /**< If procedure is to be started when notification is started, set this to the handle of the corresponding CCCD. Set to BLE_GATT_HANDLE_INVALID if procedure is to be started on connect event. */
     bool                          disconnect_on_fail;               /**< Set to TRUE if a failed connection parameters update shall cause an automatic disconnection, set to FALSE otherwise. */
-    ble_conn_params_evt_handler_t evt_handler;                      /**< Event handler to be called for handling events in the Battery Service. */
+    ble_conn_params_evt_handler_t evt_handler;                      /**< Event handler to be called for handling events in the Connection Parameters. */
     ble_srv_error_handler_t       error_handler;                    /**< Function to be called in case of an error. */
 } ble_conn_params_init_t;
 
--- a/nordic/nrf-sdk/ble/ble_date_time.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/ble/ble_date_time.h	Mon Jul 07 13:43:31 2014 +0100
@@ -10,7 +10,7 @@
 */
 
 /* Attention! 
-*  To maintain compliance with Nordic Semiconductor ASA�s Bluetooth profile 
+*  To maintain compliance with Nordic Semiconductor ASA’s Bluetooth profile 
 *  qualification listings, this section of source code must not be modified.
 */
 
@@ -30,7 +30,6 @@
 #define BLE_DATE_TIME_H__
 
 #include <stdint.h>
-#include "nordic_global.h"
 
 /**@brief Date and Time structure. */
 typedef struct
--- a/nordic/nrf-sdk/ble/ble_debug_assert_handler.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/ble/ble_debug_assert_handler.h	Mon Jul 07 13:43:31 2014 +0100
@@ -27,7 +27,6 @@
 #define BLE_DEBUG_ASSERT_HANDLER_H__
 
 #include <stdint.h>
-#include "nordic_global.h"
  
 /**@brief Function for handling the Debug assert, which can be called from an error handler. 
  *        To be used only for debugging purposes.
--- a/nordic/nrf-sdk/ble/ble_dtm.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/ble/ble_dtm.h	Mon Jul 07 13:43:31 2014 +0100
@@ -23,7 +23,6 @@
 
 #include <stdint.h>
 #include <stdbool.h>
-#include "nordic_global.h"
 
 
 /**@brief Configuration parameters. */
--- a/nordic/nrf-sdk/ble/ble_error_log.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/ble/ble_error_log.h	Mon Jul 07 13:43:31 2014 +0100
@@ -27,7 +27,6 @@
 #include <stdint.h>
 #include <stdbool.h>
 #include "ble_flash.h"
-#include "nordic_global.h"
 
 #define ERROR_MESSAGE_LENGTH  128                                /**< Length of error message to stored. */
 #define STACK_DUMP_LENGTH     256                                /**< Length of stack to be stored at max: 64 entries of 4 bytes each. */
--- a/nordic/nrf-sdk/ble/ble_flash.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/ble/ble_flash.h	Mon Jul 07 13:43:31 2014 +0100
@@ -33,7 +33,6 @@
 #include <stdint.h>
 #include <stdbool.h>
 #include <nrf51.h>
-#include "nordic_global.h"
 
 #define BLE_FLASH_PAGE_SIZE     ((uint16_t)NRF_FICR->CODEPAGESIZE)  /**< Size of one flash page. */
 #define BLE_FLASH_MAGIC_NUMBER  0x45DE0000                          /**< Magic value to identify if flash contains valid data. */
--- a/nordic/nrf-sdk/ble/ble_racp.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/ble/ble_racp.h	Mon Jul 07 13:43:31 2014 +0100
@@ -22,7 +22,6 @@
 
 #include <stdint.h>
 #include <stdbool.h>
-#include "nordic_global.h"
 #include "ble.h"
 #include "ble_types.h"
 #include "ble.h"
--- a/nordic/nrf-sdk/ble/ble_radio_notification.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/ble/ble_radio_notification.h	Mon Jul 07 13:43:31 2014 +0100
@@ -22,7 +22,6 @@
 
 #include <stdint.h>
 #include <stdbool.h>
-#include "nordic_global.h"
 #include "nrf_soc.h"
 
 /**@brief Application radio notification event handler type. */
--- a/nordic/nrf-sdk/ble/ble_sensorsim.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/ble/ble_sensorsim.h	Mon Jul 07 13:43:31 2014 +0100
@@ -25,7 +25,6 @@
 
 #include <stdint.h>
 #include <stdbool.h>
-#include "nordic_global.h"
 
 /**@brief Triangular waveform sensor simulator configuration. */
 typedef struct
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nordic/nrf-sdk/ble/ble_services/ble_ans_c.h	Mon Jul 07 13:43:31 2014 +0100
@@ -0,0 +1,351 @@
+/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ */
+
+/** @file
+ *
+ * @defgroup ble_sdk_srv_ans_c Alert Notification Service Client
+ * @{
+ * @ingroup ble_sdk_srv
+ * @brief Alert Notification module.
+ *
+ * @details This module implements the Alert Notification Client according to the
+ *          Alert Notification Profile.
+ *
+ * @note The application must propagate BLE stack events to the Alert Notification Client module
+ *       by calling ble_ans_c_on_ble_evt() from the from the @ref ble_stack_handler callback.
+ *
+ * @note Attention! 
+ *  To maintain compliance with Nordic Semiconductor ASA Bluetooth profile 
+ *  qualification listings, this section of source code must not be modified.
+ */
+#ifndef BLE_ANS_C_H__
+#define BLE_ANS_C_H__
+
+#include "ble.h"
+#include "ble_gatts.h"
+#include "ble_types.h"
+#include "ble_srv_common.h"
+#include "device_manager.h"
+
+#define ANS_NB_OF_CHARACTERISTICS                   5                                     /**< Number of characteristics as defined by Alert Notification Service specification. */
+#define ANS_NB_OF_SERVICES                          1                                     /**< Number of services supported in one central. */
+#define INVALID_SERVICE_HANDLE_BASE                 0xF0                                  /**< Base for indicating invalid service handle. */
+#define INVALID_SERVICE_HANDLE                      (INVALID_SERVICE_HANDLE_BASE + 0x0F)  /**< Indication that the current service handle is invalid. */
+#define INVALID_SERVICE_HANDLE_DISC                 (INVALID_SERVICE_HANDLE_BASE + 0x0E)  /**< Indication that the current service handle is invalid but the service has been discovered. */
+#define BLE_ANS_INVALID_HANDLE                      0xFF                                  /**< Indication that the current service handle is invalid. */
+
+// Forward declaration of the ble_ans_c_t type.
+typedef struct ble_ans_c_s ble_ans_c_t;
+
+/** Alerts types as defined in the alert category id; UUID: 0x2A43. */
+typedef enum
+{
+    ANS_TYPE_SIMPLE_ALERT                           = 0,                                  /**< General text alert or non-text alert.*/
+    ANS_TYPE_EMAIL                                  = 1,                                  /**< Alert when email messages arrives.*/
+    ANS_TYPE_NEWS                                   = 2,                                  /**< News feeds such as RSS, Atom.*/
+    ANS_TYPE_NOTIFICATION_CALL                      = 3,                                  /**< Incoming call.*/
+    ANS_TYPE_MISSED_CALL                            = 4,                                  /**< Missed call.*/
+    ANS_TYPE_SMS_MMS                                = 5,                                  /**< SMS/MMS message arrives.*/
+    ANS_TYPE_VOICE_MAIL                             = 6,                                  /**< Voice mail.*/
+    ANS_TYPE_SCHEDULE                               = 7,                                  /**< Alert occurred on calendar, planner.*/
+    ANS_TYPE_HIGH_PRIORITIZED_ALERT                 = 8,                                  /**< Alert that should be handled as high priority.*/
+    ANS_TYPE_INSTANT_MESSAGE                        = 9,                                  /**< Alert for incoming instant messages.*/
+    ANS_TYPE_ALL_ALERTS                             = 0xFF                                /**< Identifies All Alerts. */
+} ble_ans_category_id_t;
+
+/** Alerts notification control point commands as defined in the Alert Notification Specification;
+ * UUID: 0x2A44.
+ */
+typedef enum
+{
+    ANS_ENABLE_NEW_INCOMING_ALERT_NOTIFICATION      = 0,                                  /**< Enable New Incoming Alert Notification.*/
+    ANS_ENABLE_UNREAD_CATEGORY_STATUS_NOTIFICATION  = 1,                                  /**< Enable Unread Category Status Notification.*/
+    ANS_DISABLE_NEW_INCOMING_ALERT_NOTIFICATION     = 2,                                  /**< Disable New Incoming Alert Notification.*/
+    ANS_DISABLE_UNREAD_CATEGORY_STATUS_NOTIFICATION = 3,                                  /**< Disable Unread Category Status Notification.*/
+    ANS_NOTIFY_NEW_INCOMING_ALERT_IMMEDIATELY       = 4,                                  /**< Notify New Incoming Alert immediately.*/
+    ANS_NOTIFY_UNREAD_CATEGORY_STATUS_IMMEDIATELY   = 5,                                  /**< Notify Unread Category Status immediately.*/
+} ble_ans_command_id_t;
+
+/**@brief Alert Notification Event types that are passed from client to application on an event. */
+typedef enum
+{
+    BLE_ANS_C_EVT_DISCOVER_COMPLETE,                                                      /**< A successful connection has been established and the characteristics of the server has been fetched. */
+    BLE_ANS_C_EVT_DISCOVER_FAILED,                                                        /**< It was not possible to discover service or characteristics of the connected peer. */
+    BLE_ANS_C_EVT_RECONNECT,                                                              /**< A re-connection to a known and previously discovered central has occurred. */
+    BLE_ANS_C_EVT_DISCONN_COMPLETE,                                                       /**< The connection has been taken down. */
+    BLE_ANS_C_EVT_NOTIFICATION,                                                           /**< A valid Alert Notification has been received from the server.*/
+    BLE_ANS_C_EVT_READ_RESP,                                                              /**< A read response has been received from the server.*/
+    BLE_ANS_C_EVT_WRITE_RESP                                                              /**< A write response has been received from the server.*/
+} ble_ans_c_evt_type_t;
+
+/**@brief Alert Notification Control Point structure. */
+typedef struct
+{
+    ble_ans_command_id_t                command;                                          /**< The command to be written to the control point, see @ref ble_ans_command_id_t. */
+    ble_ans_category_id_t               category;                                         /**< The category for the control point for which the command applies, see @ref ble_ans_category_id_t. */
+} ble_ans_control_point_t;
+
+/**@brief Alert Notification Setting structure containing the supported alerts in the service.
+  *
+  *@details
+  * The structure contains bit fields describing which alerts that are supported:
+  * 0 = Unsupported
+  * 1 = Supported
+  */
+typedef struct
+{
+    uint8_t                             ans_simple_alert_support           : 1;           /**< Support for General text alert or non-text alert.*/
+    uint8_t                             ans_email_support                  : 1;           /**< Support for Alert when email messages arrives.*/
+    uint8_t                             ans_news_support                   : 1;           /**< Support for News feeds such as RSS, Atom.*/
+    uint8_t                             ans_notification_call_support      : 1;           /**< Support for Incoming call.*/
+    uint8_t                             ans_missed_call_support            : 1;           /**< Support for Missed call.*/
+    uint8_t                             ans_sms_mms_support                : 1;           /**< Support for SMS/MMS message arrives.*/
+    uint8_t                             ans_voice_mail_support             : 1;           /**< Support for Voice mail.*/
+    uint8_t                             ans_schedule_support               : 1;           /**< Support for Alert occurred on calendar, planner.*/
+    uint8_t                             ans_high_prioritized_alert_support : 1;           /**< Support for Alert that should be handled as high priority.*/
+    uint8_t                             ans_instant_message_support        : 1;           /**< Support for Alert for incoming instant messages.*/
+    uint8_t                             reserved                           : 6;           /**< Reserved for future use. */
+} ble_ans_alert_settings_t;
+
+/**@brief Alert Notification structure
+ */
+typedef struct
+{
+    uint8_t                             alert_category;                                   /**< Alert category to which this alert belongs.*/
+    uint8_t                             alert_category_count;                             /**< Number of alerts in the category. */
+    uint32_t                            alert_msg_length;                                 /**< Length of optional text message send by the server. */
+    uint8_t *                           p_alert_msg_buf;                                  /**< Pointer to buffer containing the optional text message. */
+} ble_ans_alert_notification_t;
+
+/**@brief Alert Notification Event structure
+ *
+ * @details The structure contains the event that should be handled, as well as
+ *          additional information.
+ */
+typedef struct
+{
+    ble_ans_c_evt_type_t                evt_type;                                         /**< Type of event. */
+    ble_uuid_t                          uuid;                                             /**< UUID of the event in case of an alert or notification. */
+    union
+    {
+        ble_ans_alert_settings_t        settings;                                         /**< Setting returned from server on read request. */
+        ble_ans_alert_notification_t    alert;                                            /**< Alert Notification data sent by the server. */
+        uint32_t                        error_code;                                       /**< Additional status/error code if the event was caused by a stack error or gatt status, e.g. during service discovery. */
+    } data;
+} ble_ans_c_evt_t;
+
+/**@brief Alert Notification event handler type. */
+typedef void (*ble_ans_c_evt_handler_t) (ble_ans_c_evt_t * p_evt);
+
+/**@brief Alert Notification structure. This contains various status information for the client. */
+typedef struct ble_ans_c_s
+{
+    ble_ans_c_evt_handler_t             evt_handler;                                      /**< Event handler to be called for handling events in the Alert Notification Client Application. */
+    ble_srv_error_handler_t             error_handler;                                    /**< Function to be called in case of an error. */
+    uint16_t                            conn_handle;                                      /**< Handle of the current connection (as provided by the BLE stack, is BLE_CONN_HANDLE_INVALID if not in a connection). */
+    uint8_t                             central_handle;                                   /**< Handle for the currently connected central if peer is bonded. */
+    uint8_t                             service_handle;                                   /**< Handle to the service in the database to use for this instance. */
+    uint32_t                            message_buffer_size;                              /**< Size of message buffer to hold the additional text messages received on notifications. */
+    uint8_t *                           p_message_buffer;                                 /**< Pointer to the buffer to be used for additional text message handling. */
+} ble_ans_c_t;
+
+/**@brief Alert Notification init structure. This contains all options and data needed for
+ *        initialization of the client.*/
+typedef struct
+{
+    ble_ans_c_evt_handler_t             evt_handler;                                      /**< Event handler to be called for handling events in the Battery Service. */
+    ble_srv_error_handler_t             error_handler;                                    /**< Function to be called in case of an error. */
+    uint32_t                            message_buffer_size;                              /**< Size of buffer to handle messages. */
+    uint8_t *                           p_message_buffer;                                 /**< Pointer to buffer for passing messages. */
+} ble_ans_c_init_t;
+
+
+/**@brief Function for handling the Application's BLE Stack events.
+ *
+ * @details Handles all events from the BLE stack of interest to the Alert Notification Client.
+ *
+ * @param[in]   p_ans      Alert Notification Client structure.
+ * @param[in]   p_ble_evt  Event received from the BLE stack.
+ */
+void ble_ans_c_on_ble_evt(ble_ans_c_t * p_ans, const ble_evt_t * p_ble_evt);
+
+
+/**@brief Function for handling the Alert Notification Client - Device Manager Event.
+ *
+ * @details Handles all events from the Bond Manager of interest to the Alert Notification Client.
+ *          The Alert Notification Client will use the events of re-connection to existing central
+ *          and creation of new bonds for handling of service discovery and writing of the Alert
+ *          Notification Control Point for re-send of New Alert and Unread Alert notifications.
+ *
+ * @param[in]   p_ans            Alert Notification Client structure.
+ * @param[in]   p_bond_mgmr_evt  Event received from the Bond Manager.
+ */
+void ble_ans_c_on_device_manager_evt(ble_ans_c_t       * p_ans,
+                                     dm_handle_t const * p_handle,
+                                     dm_event_t const  * p_dm_evt);
+
+
+/**@brief Function for initializing the Alert Notification Client.
+ *
+ * @param[out]  p_ans       Alert Notification Client structure. This structure will have to be
+ *                          supplied by the application. It will be initialized by this function,
+ *                          and will later be used to identify this particular client instance.
+ * @param[in]   p_ans_init  Information needed to initialize the client.
+ *
+ * @return      NRF_SUCCESS on successful initialization of client, otherwise an error code.
+ */
+uint32_t ble_ans_c_init(ble_ans_c_t * p_ans, const ble_ans_c_init_t * p_ans_init);
+
+
+/**@brief Function for writing the to CCCD to enable new alert notifications from the Alert Notification Service.
+ *
+ * @param[in]  p_ans       Alert Notification structure. This structure will have to be supplied by
+ *                         the application. It identifies the particular client instance to use.
+ *
+ * @return     NRF_SUCCESS on successful writing of the CCCD, otherwise an error code.
+ */
+uint32_t ble_ans_c_enable_notif_new_alert(const ble_ans_c_t * p_ans);
+
+
+/**@brief Function for writing to the CCCD to enable unread alert notifications from the Alert Notification Service.
+ *
+ * @param[in]  p_ans       Alert Notification structure. This structure will have to be supplied by
+ *                         the application. It identifies the particular client instance to use.
+ *
+ * @return     NRF_SUCCESS on successful writing of the CCCD, otherwise an error code.
+ */
+uint32_t ble_ans_c_enable_notif_unread_alert(const ble_ans_c_t * p_ans);
+
+
+/**@brief Function for writing to the CCCD to disable new alert notifications from the Alert Notification Service.
+ *
+ * @param[in]  p_ans       Alert Notification structure. This structure will have to be supplied by
+ *                         the application. It identifies the particular client instance to use.
+ *
+ * @return     NRF_SUCCESS on successful writing of the CCCD, otherwise an error code.
+ */
+uint32_t ble_ans_c_disable_notif_new_alert(const ble_ans_c_t * p_ans);
+
+
+/**@brief Function for writing to the CCCD to disable unread alert notifications from the Alert Notification Service.
+ *
+ * @param[in]  p_ans       Alert Notification structure. This structure will have to be supplied by
+ *                         the application. It identifies the particular client instance to use.
+ *
+ * @return     NRF_SUCCESS on successful writing of the CCCD, otherwise an error code.
+ */
+uint32_t ble_ans_c_disable_notif_unread_alert(const ble_ans_c_t * p_ans);
+
+
+/**@brief Function for writing to the Alert Notification Control Point to specify alert notification behavior in the
+ * Alert Notification Service on the Central.
+ *
+ * @param[in]  p_ans           Alert Notification structure. This structure will have to be
+ *                             supplied by the application. It identifies the particular client
+ *                             instance to use.
+ * @param[in]  p_control_point Alert Notification Control Point structure. This structure
+ *                             specifies the values to write to the Alert Notification Control
+ *                             Point, UUID 0x2A44.
+ *
+ * @return     NRF_SUCCESS     on successful writing of the Control Point, otherwise an error code.
+ */
+uint32_t ble_ans_c_control_point_write(const ble_ans_c_t * p_ans,
+                                       const ble_ans_control_point_t * p_control_point);
+
+
+/**@brief Function for reading the Supported New Alert characteristic value of the service.
+ *        The value describes the alerts supported in the central.
+ *
+ * @param[in]  p_ans       Alert Notification structure. This structure will have to be supplied by
+ *                         the application. It identifies the particular client instance to use.
+ *
+ * @return     NRF_SUCCESS on successful transmission of the read request, otherwise an error code.
+ */
+uint32_t ble_ans_c_new_alert_read(const ble_ans_c_t * p_ans);
+
+
+/**@brief Function for reading the Supported Unread Alert characteristic value of the service.
+ *        The value describes the alerts supported in the central.
+ *
+ * @param[in]  p_ans       Alert Notification structure. This structure will have to be supplied by
+ *                         the application. It identifies the particular client instance to use.
+ *
+ * @return     NRF_SUCCESS on successful transmission of the read request, otherwise an error code.
+ */
+uint32_t ble_ans_c_unread_alert_read(const ble_ans_c_t * p_ans);
+
+
+/**@brief Function for requesting the peer to notify the New Alert characteristics immediately.
+ *
+ * @param[in]  p_ans       Alert Notification structure. This structure will have to be supplied by
+ *                         the application. It identifies the particular client instance to use.
+ * @param[in]  category    The category ID for which the peer should notify the client.
+ *
+ * @return     NRF_SUCCESS on successful transmission of the read request, otherwise an error code.
+ */
+uint32_t ble_ans_c_new_alert_notify(const ble_ans_c_t * p_ans, ble_ans_category_id_t category);
+
+
+/**@brief Function for requesting the peer to notify the Unread Alert characteristics immediately.
+ *
+ * @param[in]  p_ans       Alert Notification structure. This structure will have to be supplied by
+ *                         the application. It identifies the particular client instance to use.
+ * @param[in]  category    The category ID for which the peer should notify the client.
+ *
+ * @return     NRF_SUCCESS on successful transmission of the read request, otherwise an error code.
+ */
+uint32_t ble_ans_c_unread_alert_notify(const ble_ans_c_t * p_ans, ble_ans_category_id_t category);
+
+
+/**@brief  Function for loading previous discovered service and characteristic handles for bonded centrals from
+ *          flash into RAM.
+ *
+ * @details Read the database of all discovered service and characteristic handles from flash.
+ *          If the flash does not contain any valid data, the array of discovered service handles in
+ *          RAM will be empty.
+ *
+ * @param[in] p_ans  Alert Notification structure. This structure will have to be supplied by the
+ *                   application. It identifies the particular client instance to use.
+ *
+ * @note    Currently the Alert Notification Client uses only one page in flash.
+ *
+ * @return  NRF_SUCCESS if all operations went successfully, an error_code otherwise.
+ */
+uint32_t ble_ans_c_service_load(const ble_ans_c_t * p_ans);
+
+
+/**@brief Function for storing discovered service and characteristic handles for bonded centrals into flash memory.
+ *
+ * @details This function will erase the flash page (if the data to store
+ *          are diferent than the one already stored) and then write into flash. Those
+ *          operations could prevent the radio to run.
+ *
+ * @note    Do not call this function while in a connection or when advertising. If you do, the
+ *          behavior is undefined.
+ *
+ * @return  NRF_SUCCESS if all operations went successfully, an error_code otherwise.
+ */
+uint32_t ble_ans_c_service_store(void);
+
+
+/**@brief Function for deleting the Alert Notification Client database from flash.
+ *
+ * @details After calling this function you should call ble_ans_c_init(...) to re-initialize
+ *          the RAM database.
+ *
+ * @return  NRF_SUCCESS if all operations went successfully.
+ */
+uint32_t ble_ans_c_service_delete(void);
+
+#endif // BLE_ANS_C_H__
+
+/** @} */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nordic/nrf-sdk/ble/ble_services/ble_bas.h	Mon Jul 07 13:43:31 2014 +0100
@@ -0,0 +1,133 @@
+/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ *
+ */
+
+/** @file
+ *
+ * @defgroup ble_sdk_srv_bas Battery Service
+ * @{
+ * @ingroup ble_sdk_srv
+ * @brief Battery Service module.
+ *
+ * @details This module implements the Battery Service with the Battery Level characteristic.
+ *          During initialization it adds the Battery Service and Battery Level characteristic
+ *          to the BLE stack database. Optionally it can also add a Report Reference descriptor
+ *          to the Battery Level characteristic (used when including the Battery Service in
+ *          the HID service).
+ *
+ *          If specified, the module will support notification of the Battery Level characteristic
+ *          through the ble_bas_battery_level_update() function.
+ *          If an event handler is supplied by the application, the Battery Service will
+ *          generate Battery Service events to the application.
+ *
+ * @note The application must propagate BLE stack events to the Battery Service module by calling
+ *       ble_bas_on_ble_evt() from the from the @ref ble_stack_handler callback.
+ *
+ * @note Attention! 
+ *  To maintain compliance with Nordic Semiconductor ASA Bluetooth profile 
+ *  qualification listings, this section of source code must not be modified.
+ */
+
+#ifndef BLE_BAS_H__
+#define BLE_BAS_H__
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "ble.h"
+#include "ble_srv_common.h"
+
+/**@brief Battery Service event type. */
+typedef enum
+{
+    BLE_BAS_EVT_NOTIFICATION_ENABLED,                             /**< Battery value notification enabled event. */
+    BLE_BAS_EVT_NOTIFICATION_DISABLED                             /**< Battery value notification disabled event. */
+} ble_bas_evt_type_t;
+
+/**@brief Battery Service event. */
+typedef struct
+{
+    ble_bas_evt_type_t evt_type;                                  /**< Type of event. */
+} ble_bas_evt_t;
+
+// Forward declaration of the ble_bas_t type. 
+typedef struct ble_bas_s ble_bas_t;
+
+/**@brief Battery Service event handler type. */
+typedef void (*ble_bas_evt_handler_t) (ble_bas_t * p_bas, ble_bas_evt_t * p_evt);
+
+/**@brief Battery Service init structure. This contains all options and data needed for
+ *        initialization of the service.*/
+typedef struct
+{
+    ble_bas_evt_handler_t         evt_handler;                    /**< Event handler to be called for handling events in the Battery Service. */
+    bool                          support_notification;           /**< TRUE if notification of Battery Level measurement is supported. */
+    ble_srv_report_ref_t *        p_report_ref;                   /**< If not NULL, a Report Reference descriptor with the specified value will be added to the Battery Level characteristic */
+    uint8_t                       initial_batt_level;             /**< Initial battery level */
+    ble_srv_cccd_security_mode_t  battery_level_char_attr_md;     /**< Initial security level for battery characteristics attribute */
+    ble_gap_conn_sec_mode_t       battery_level_report_read_perm; /**< Initial security level for battery report read attribute */
+} ble_bas_init_t;
+
+/**@brief Battery Service structure. This contains various status information for the service. */
+typedef struct ble_bas_s
+{
+    ble_bas_evt_handler_t         evt_handler;                    /**< Event handler to be called for handling events in the Battery Service. */
+    uint16_t                      service_handle;                 /**< Handle of Battery Service (as provided by the BLE stack). */
+    ble_gatts_char_handles_t      battery_level_handles;          /**< Handles related to the Battery Level characteristic. */
+    uint16_t                      report_ref_handle;              /**< Handle of the Report Reference descriptor. */
+    uint8_t                       battery_level_last;             /**< Last Battery Level measurement passed to the Battery Service. */
+    uint16_t                      conn_handle;                    /**< Handle of the current connection (as provided by the BLE stack, is BLE_CONN_HANDLE_INVALID if not in a connection). */
+    bool                          is_notification_supported;      /**< TRUE if notification of Battery Level is supported. */
+} ble_bas_t;
+
+/**@brief Function for initializing the Battery Service.
+ *
+ * @param[out]  p_bas       Battery Service structure. This structure will have to be supplied by
+ *                          the application. It will be initialized by this function, and will later
+ *                          be used to identify this particular service instance.
+ * @param[in]   p_bas_init  Information needed to initialize the service.
+ *
+ * @return      NRF_SUCCESS on successful initialization of service, otherwise an error code.
+ */
+uint32_t ble_bas_init(ble_bas_t * p_bas, const ble_bas_init_t * p_bas_init);
+
+/**@brief Function for handling the Application's BLE Stack events.
+ *
+ * @details Handles all events from the BLE stack of interest to the Battery Service.
+ *
+ * @note For the requirements in the BAS specification to be fulfilled,
+ *       ble_bas_battery_level_update() must be called upon reconnection if the
+ *       battery level has changed while the service has been disconnected from a bonded
+ *       client.
+ *
+ * @param[in]   p_bas      Battery Service structure.
+ * @param[in]   p_ble_evt  Event received from the BLE stack.
+ */
+void ble_bas_on_ble_evt(ble_bas_t * p_bas, ble_evt_t * p_ble_evt);
+
+/**@brief Function for updating the battery level.
+ *
+ * @details The application calls this function after having performed a battery measurement. If
+ *          notification has been enabled, the battery level characteristic is sent to the client.
+ *
+ * @note For the requirements in the BAS specification to be fulfilled,
+ *       this function must be called upon reconnection if the battery level has changed
+ *       while the service has been disconnected from a bonded client.
+ *
+ * @param[in]   p_bas          Battery Service structure.
+ * @param[in]   battery_level  New battery measurement value (in percent of full capacity).
+ *
+ * @return      NRF_SUCCESS on success, otherwise an error code.
+ */
+uint32_t ble_bas_battery_level_update(ble_bas_t * p_bas, uint8_t battery_level);
+
+#endif // BLE_BAS_H__
+
+/** @} */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nordic/nrf-sdk/ble/ble_services/ble_bps.h	Mon Jul 07 13:43:31 2014 +0100
@@ -0,0 +1,161 @@
+/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ */
+
+/** @file
+ *
+ * @defgroup ble_sdk_srv_bps Blood Pressure Service
+ * @{
+ * @ingroup ble_sdk_srv
+ * @brief Blood Pressure Service module.
+ *
+ * @details This module implements the Blood Pressure Service.
+ *
+ *          If an event handler is supplied by the application, the Blood Pressure 
+ *          Service will generate Blood Pressure Service events to the application.
+ *
+ * @note The application must propagate BLE stack events to the Blood Pressure Service
+ *       module by calling ble_bps_on_ble_evt() from the from the @ref ble_stack_handler function.
+ *
+ * @note Attention! 
+ *  To maintain compliance with Nordic Semiconductor ASA Bluetooth profile 
+ *  qualification listings, this section of source code must not be modified.
+ */
+
+#ifndef BLE_BPS_H__
+#define BLE_BPS_H__
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "ble.h"
+#include "ble_srv_common.h"
+#include "ble_date_time.h"
+
+// Blood Pressure Feature bits
+#define BLE_BPS_FEATURE_BODY_MOVEMENT_BIT               (0x01 << 0)         /**< Body Movement Detection Support bit. */
+#define BLE_BPS_FEATURE_CUFF_FIT_BIT                    (0x01 << 1)         /**< Cuff Fit Detection Support bit. */
+#define BLE_BPS_FEATURE_IRREGULAR_PULSE_BIT             (0x01 << 2)         /**< Irregular Pulse Detection Support bit. */
+#define BLE_BPS_FEATURE_PULSE_RATE_RANGE_BIT            (0x01 << 3)         /**< Pulse Rate Range Detection Support bit. */
+#define BLE_BPS_FEATURE_MEASUREMENT_POSITION_BIT        (0x01 << 4)         /**< Measurement Position Detection Support bit. */
+#define BLE_BPS_FEATURE_MULTIPLE_BOND_BIT               (0x01 << 5)         /**< Multiple Bond Support bit. */
+
+/**@brief Blood Pressure Service event type. */
+typedef enum
+{
+    BLE_BPS_EVT_INDICATION_ENABLED,                                         /**< Blood Pressure value indication enabled event. */
+    BLE_BPS_EVT_INDICATION_DISABLED,                                        /**< Blood Pressure value indication disabled event. */
+    BLE_BPS_EVT_INDICATION_CONFIRMED                                        /**< Confirmation of a blood pressure measurement indication has been received. */
+} ble_bps_evt_type_t;
+
+/**@brief Blood Pressure Service event. */
+typedef struct
+{
+    ble_bps_evt_type_t evt_type;                                            /**< Type of event. */
+} ble_bps_evt_t;
+
+// Forward declaration of the ble_bps_t type. 
+typedef struct ble_bps_s ble_bps_t;
+
+/**@brief Blood Pressure Service event handler type. */
+typedef void (*ble_bps_evt_handler_t) (ble_bps_t * p_bps, ble_bps_evt_t * p_evt);
+
+/**@brief SFLOAT format (IEEE-11073 16-bit FLOAT, defined as a 16-bit vlue with 12-bit mantissa and
+ *        4-bit exponent. */
+typedef struct
+{
+  int8_t  exponent;                                                         /**< Base 10 exponent, only 4 bits */
+  int16_t mantissa;                                                         /**< Mantissa, only 12 bits */
+} ieee_float16_t;
+
+/**@brief Blood Pressure Service init structure. This contains all options and data
+ *        needed for initialization of the service. */
+typedef struct
+{
+    ble_bps_evt_handler_t        evt_handler;                               /**< Event handler to be called for handling events in the Blood Pressure Service. */
+    ble_srv_cccd_security_mode_t bps_meas_attr_md;                          /**< Initial security level for blood pressure measurement attribute */
+    ble_srv_security_mode_t      bps_feature_attr_md;                       /**< Initial security level for blood pressure feature attribute */
+    uint16_t                     feature;                                   /**< Initial value for blood pressure feature */
+} ble_bps_init_t;
+
+/**@brief Blood Pressure Service structure. This contains various status information for
+ *        the service. */
+typedef struct ble_bps_s
+{
+    ble_bps_evt_handler_t        evt_handler;                               /**< Event handler to be called for handling events in the Blood Pressure Service. */
+    uint16_t                     service_handle;                            /**< Handle of Blood Pressure Service (as provided by the BLE stack). */
+    ble_gatts_char_handles_t     meas_handles;                              /**< Handles related to the Blood Pressure Measurement characteristic. */
+    ble_gatts_char_handles_t     feature_handles;                           /**< Handles related to the Blood Pressure Feature characteristic. */
+    uint16_t                     conn_handle;                               /**< Handle of the current connection (as provided by the BLE stack, is BLE_CONN_HANDLE_INVALID if not in a connection). */
+    uint16_t                     feature;                                   /**< Value of Blood Pressure feature. */
+} ble_bps_t;
+
+/**@brief Blood Pressure Service measurement structure. This contains a Blood Pressure
+ *        measurement. */
+typedef struct ble_bps_meas_s
+{
+    bool                         blood_pressure_units_in_kpa;               /**< Blood Pressure Units Flag, 0=mmHg, 1=kPa */
+    bool                         time_stamp_present;                        /**< Time Stamp Flag, 0=not present, 1=present. */
+    bool                         pulse_rate_present;                        /**< Pulse Rate Flag, 0=not present, 1=present. */
+    bool                         user_id_present;                           /**< User ID Flag, 0=not present, 1=present. */
+    bool                         measurement_status_present;                /**< Measurement Status Flag, 0=not present, 1=present. */
+    ieee_float16_t               blood_pressure_systolic;                   /**< Blood Pressure Measurement Compound Value - Systolic. */
+    ieee_float16_t               blood_pressure_diastolic;                  /**< Blood Pressure Measurement Compound Value - Diastolic . */
+    ieee_float16_t               mean_arterial_pressure;                    /**< Blood Pressure Measurement Compound Value - Mean Arterial Pressure. */
+    ble_date_time_t              time_stamp;                                /**< Time Stamp. */
+    ieee_float16_t               pulse_rate;                                /**< Pulse Rate. */
+    uint8_t                      user_id;                                   /**< User ID. */
+    uint16_t                     measurement_status;                        /**< Measurement Status. */
+} ble_bps_meas_t;
+
+/**@brief Function for initializing the Blood Pressure Service.
+ *
+ * @param[out]  p_bps       Blood Pressure Service structure. This structure will have to
+ *                          be supplied by the application. It will be initialized by this function,
+ *                          and will later be used to identify this particular service instance.
+ * @param[in]   p_bps_init  Information needed to initialize the service.
+ *
+ * @return      NRF_SUCCESS on successful initialization of service, otherwise an error code.
+ */
+uint32_t ble_bps_init(ble_bps_t * p_bps, const ble_bps_init_t * p_bps_init);
+
+/**@brief Function for handling the Application's BLE Stack events.
+ *
+ * @details Handles all events from the BLE stack of interest to the Blood Pressure Service.
+ *
+ * @param[in]   p_bps      Blood Pressure Service structure.
+ * @param[in]   p_ble_evt  Event received from the BLE stack.
+ */
+void ble_bps_on_ble_evt(ble_bps_t * p_bps, ble_evt_t * p_ble_evt);
+
+/**@brief Function for sending blood pressure measurement if indication has been enabled.
+ *
+ * @details The application calls this function after having performed a Blood Pressure
+ *          measurement. If indication has been enabled, the measurement data is encoded and
+ *          sent to the client.
+ *
+ * @param[in]   p_bps       Blood Pressure Service structure.
+ * @param[in]   p_bps_meas  Pointer to new blood pressure measurement.
+ *
+ * @return      NRF_SUCCESS on success, otherwise an error code.
+ */
+uint32_t ble_bps_measurement_send(ble_bps_t * p_bps, ble_bps_meas_t * p_bps_meas);
+
+/**@brief Function for checking if indication of Blood Pressure Measurement is currently enabled.
+ *
+ * @param[in]   p_bps                  Blood Pressure Service structure.
+ * @param[out]  p_indication_enabled   TRUE if indication is enabled, FALSE otherwise.
+ *
+ * @return      NRF_SUCCESS on success, otherwise an error code.
+ */
+uint32_t ble_bps_is_indication_enabled(ble_bps_t * p_bps, bool * p_indication_enabled);
+
+#endif // BLE_BPS_H__
+
+/** @} */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nordic/nrf-sdk/ble/ble_services/ble_cscs.h	Mon Jul 07 13:43:31 2014 +0100
@@ -0,0 +1,161 @@
+/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ *
+ */
+
+/** @file
+ *
+ * @defgroup ble_sdk_srv_csc Cycling Speed and Cadence Service
+ * @{
+ * @ingroup ble_sdk_srv
+ * @brief Cycling Speed and Cadence Service module.
+ *
+ * @details This module implements the Cycling Speed and Cadence Service. If enabled, notification
+ *          of the Cycling Speead and Candence Measurement is performed when the application
+ *          calls ble_cscs_measurement_send().
+ *
+ *          To use this service, you need to provide the the supported features (@ref BLE_CSCS_FEATURES).
+ *          If you choose to support Wheel revolution data (feature bit @ref BLE_CSCS_FEATURE_WHEEL_REV_BIT), 
+ *          you then need to support the 'setting of cumulative value' operation by the supporting the 
+ *          Speed and Cadence Control Point (@ref ble_sdk_srv_sc_ctrlpt) by setting the @ref BLE_SRV_SC_CTRLPT_CUM_VAL_OP_SUPPORTED
+ *          bit of the ctrplt_supported_functions in the @ref ble_cscs_init_t structure.
+ *          If you want to support the 'start autocalibration' control point feature, you need, after the @ref BLE_SC_CTRLPT_EVT_START_CALIBRATION
+ *          has been received and the auto calibration is finished, to call the @ref ble_sc_ctrlpt_rsp_send to indicate that the operation is finished
+ *          and thus be able to receive new control point operations.
+ *          If you want to support the 'sensor location' related operation, you need to provide a list of supported location in the 
+ *          @ref ble_cscs_init_t structure.
+ *          
+ *
+ * @note The application or the service using this module must propagate BLE stack events to the 
+ *       Cycling Speead and Candence Service module by calling ble_cscs_on_ble_evt() from the 
+ *       from the @ref ble_stack_handler function. This service will forward the event to the @ref ble_sdk_srv_sc_ctrlpt module.
+ *
+ * @note Attention! 
+ *  To maintain compliance with Nordic Semiconductor ASA Bluetooth profile 
+ *  qualification listings, this section of source code must not be modified.
+ */
+
+#ifndef BLE_CSCS_H__
+#define BLE_CSCS_H__
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "ble.h"
+#include "ble_srv_common.h"
+#include "ble_sc_ctrlpt.h"
+#include "ble_sensor_location.h"
+
+/** @defgroup BLE_CSCS_FEATURES Cycling Speed and Cadence Service feature bits
+ * @{ */
+#define BLE_CSCS_FEATURE_WHEEL_REV_BIT                  (0x01 << 0)     /**< Wheel Revolution Data Supported bit. */
+#define BLE_CSCS_FEATURE_CRANK_REV_BIT                  (0x01 << 1)     /**< Crank Revolution Data Supported bit. */
+#define BLE_CSCS_FEATURE_MULTIPLE_SENSORS_BIT           (0x01 << 2)     /**< Multiple Sensor Locations Supported bit. */
+/** @} */
+
+/**@brief Cycling Speed and Cadence Service event type. */
+typedef enum
+{
+    BLE_CSCS_EVT_NOTIFICATION_ENABLED,                                  /**< Cycling Speed and Cadence value notification enabled event. */
+    BLE_CSCS_EVT_NOTIFICATION_DISABLED                                  /**< Cycling Speed and Cadence value notification disabled event. */
+} ble_cscs_evt_type_t;
+
+/**@brief Cycling Speed and Cadence Service event. */
+typedef struct
+{
+    ble_cscs_evt_type_t evt_type;                                       /**< Type of event. */
+} ble_cscs_evt_t;
+
+// Forward declaration of the ble_csc_t type. 
+typedef struct ble_cscs_s ble_cscs_t;
+
+/**@brief Cycling Speed and Cadence Service event handler type. */
+typedef void (*ble_cscs_evt_handler_t) (ble_cscs_t * p_cscs, ble_cscs_evt_t * p_evt);
+
+/**@brief Cycling Speed and Cadence Service init structure. This contains all options and data
+*         needed for initialization of the service. */
+typedef struct
+{
+    ble_cscs_evt_handler_t       evt_handler;                           /**< Event handler to be called for handling events in the Cycling Speed and Cadence Service. */
+    ble_srv_cccd_security_mode_t csc_meas_attr_md;                      /**< Initial security level for cycling speed and cadence measurement attribute */
+    ble_srv_cccd_security_mode_t csc_ctrlpt_attr_md;                    /**< Initial security level for cycling speed and cadence control point attribute */
+    ble_srv_security_mode_t      csc_feature_attr_md;                   /**< Initial security level for feature attribute */
+    uint16_t                     feature;                               /**< Initial value for features of sensor @ref BLE_CSCS_FEATURES. */
+    uint8_t                      ctrplt_supported_functions;            /**< Supported control point functionnalities see @ref BLE_SRV_SC_CTRLPT_SUPP_FUNC. */
+    ble_sc_ctrlpt_evt_handler_t  ctrlpt_evt_handler;                    /**< Event handler */
+    ble_sensor_location_t        *list_supported_locations;             /**< List of supported sensor locations.*/
+    uint8_t                      size_list_supported_locations;         /**< Number of supported sensor locations in the list.*/
+    ble_srv_error_handler_t      error_handler;                         /**< Function to be called in case of an error. */
+    ble_sensor_location_t        *sensor_location;                      /**< Initial Sensor Location, if NULL, sensor_location characteristic is not added*/
+    ble_srv_cccd_security_mode_t csc_sensor_loc_attr_md;                /**< Initial security level for sensor location attribute */
+} ble_cscs_init_t;
+
+/**@brief Cycling Speed and Cadence Service structure. This contains various status information for
+ *        the service. */
+typedef struct ble_cscs_s
+{
+    ble_cscs_evt_handler_t       evt_handler;                           /**< Event handler to be called for handling events in the Cycling Speed and Cadence Service. */
+    uint16_t                     service_handle;                        /**< Handle of Cycling Speed and Cadence Service (as provided by the BLE stack). */
+    ble_gatts_char_handles_t     meas_handles;                          /**< Handles related to the Cycling Speed and Cadence Measurement characteristic. */
+    ble_gatts_char_handles_t     feature_handles;                       /**< Handles related to the Cycling Speed and Cadence feature characteristic. */
+    ble_gatts_char_handles_t     sensor_loc_handles;                    /**< Handles related to the Cycling Speed and Cadence Sensor Location characteristic. */
+    uint16_t                     conn_handle;                           /**< Handle of the current connection (as provided by the BLE stack, is BLE_CONN_HANDLE_INVALID if not in a connection). */
+    uint16_t                     feature;                               /**< Bit mask of features available on sensor. */
+    ble_sc_ctrlpt_t              ctrl_pt;                               /**< data for speed and cadence control point */
+} ble_cscs_t;
+
+/**@brief Cycling Speed and Cadence Service measurement structure. This contains a Cycling Speed and
+ *        Cadence Service measurement. */
+typedef struct ble_cscs_meas_s
+{
+    bool        is_wheel_rev_data_present;                              /**< True if Wheel Revolution Data is present in the measurement. */
+    bool        is_crank_rev_data_present;                              /**< True if Crank Revolution Data is present in the measurement. */
+    uint32_t    cumulative_wheel_revs;                                  /**< Cumulative Wheel Revolutions. */
+    uint16_t    last_wheel_event_time;                                  /**< Last Wheel Event Time. */
+    uint16_t    cumulative_crank_revs;                                  /**< Cumulative Crank Revolutions. */
+    uint16_t    last_crank_event_time;                                  /**< Last Crank Event Time. */
+} ble_cscs_meas_t;
+
+/**@brief Function for initializing the Cycling Speed and Cadence Service.
+ *
+ * @param[out]  p_cscs      Cycling Speed and Cadence Service structure. This structure will have to
+ *                          be supplied by the application. It will be initialized by this function,
+ *                          and will later be used to identify this particular service instance.
+ * @param[in]   p_cscs_init Information needed to initialize the service.
+ *
+ * @return      NRF_SUCCESS on successful initialization of service, otherwise an error code.
+ */
+uint32_t ble_cscs_init(ble_cscs_t * p_cscs, const ble_cscs_init_t * p_cscs_init);
+
+/**@brief Function for handling the Application's BLE Stack events.
+ *
+ * @details Handles all events from the BLE stack of interest to the Cycling Speed and Cadence
+ *          Service.
+ *
+ * @param[in]   p_cscs     Cycling Speed and Cadence Service structure.
+ * @param[in]   p_ble_evt  Event received from the BLE stack.
+ */
+void ble_cscs_on_ble_evt(ble_cscs_t * p_cscs, ble_evt_t * p_ble_evt);
+
+/**@brief Function for sending cycling speed and cadence measurement if notification has been enabled.
+ *
+ * @details The application calls this function after having performed a Cycling Speed and Cadence
+ *          Service measurement. If notification has been enabled, the measurement data is encoded
+ *          and sent to the client.
+ *
+ * @param[in]   p_cscs         Cycling Speed and Cadence Service structure.
+ * @param[in]   p_measurement  Pointer to new cycling speed and cadence measurement.
+ *
+ * @return      NRF_SUCCESS on success, otherwise an error code.
+ */
+uint32_t ble_cscs_measurement_send(ble_cscs_t * p_cscs, ble_cscs_meas_t * p_measurement);
+
+#endif // BLE_CSCS_H__
+
+/** @} */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nordic/nrf-sdk/ble/ble_services/ble_dfu.h	Mon Jul 07 13:43:31 2014 +0100
@@ -0,0 +1,234 @@
+/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ *
+ */
+
+/**@file
+ *
+ * @defgroup ble_sdk_srv_dfu Device Firmware Update Service
+ * @{
+ * @ingroup  ble_sdk_srv
+ * @brief    Device Firmware Update Service
+ *
+ * @details  The Device Firmware Update (DFU) service is a GATT based service that can be used for
+ *           performing firmware updates over BLE. Note that this implementation uses vendor
+ *           specific UUIDs for service and characteristics and is intended to demonstrate the
+ *           firmware updates over BLE. Refer @ref dfu_ble_service_spec and @ref
+ *           dfu_ble_profile_spec for more information on the service and profile respectively.
+ */
+
+#ifndef BLE_DFU_H__
+#define BLE_DFU_H__
+
+#include <stdint.h>
+#include "ble_gatts.h"
+#include "ble.h"
+#include "ble_srv_common.h"
+
+#define BLE_DFU_SERVICE_UUID     0x1530                                 /**< The UUID of the DFU Service. */
+#define BLE_DFU_PKT_CHAR_UUID    0x1532                                 /**< The UUID of the DFU Packet Characteristic. */
+#define BLE_DFU_CTRL_PT_UUID     0x1531                                 /**< The UUID of the DFU Control Point. */
+#define BLE_DFU_STATUS_REP_UUID  0x1533                                 /**< The UUID of the DFU Status Report Characteristic. */
+
+
+/**@brief   DFU Event type.
+ *
+ * @details This enumeration contains the types of events that will be received from the DFU Service.
+ */
+typedef enum
+{
+    BLE_DFU_START,                                                      /**< The event indicating that the peer wants the application to prepare for a new firmware update. */
+    BLE_DFU_RECEIVE_INIT_DATA,                                          /**< The event indicating that the peer wants the application to prepare to receive init parameters. */
+    BLE_DFU_RECEIVE_APP_DATA,                                           /**< The event indicating that the peer wants the application to prepare to receive the new firmware image. */
+    BLE_DFU_VALIDATE,                                                   /**< The event indicating that the peer wants the application to validate the newly received firmware image. */
+    BLE_DFU_ACTIVATE_N_RESET,                                           /**< The event indicating that the peer wants the application to undergo activate new firmware and restart with new valid application */
+    BLE_DFU_SYS_RESET,                                                  /**< The event indicating that the peer wants the application to undergo a reset and start the currently valid application image.*/
+    BLE_DFU_PKT_RCPT_NOTIF_ENABLED,                                     /**< The event indicating that the peer has enabled packet receipt notifications. It is the responsibility of the application to call @ref ble_dfu_pkts_rcpt_notify each time the number of packets indicated by num_of_pkts field in @ref ble_dfu_evt_t is received.*/
+    BLE_DFU_PKT_RCPT_NOTIF_DISABLED,                                    /**< The event indicating that the peer has disabled the packet receipt notifications.*/
+    BLE_DFU_PACKET_WRITE,                                               /**< The event indicating that the peer has written a value to the 'DFU Packet' characteristic. The data received from the peer will be present in the @ref ble_dfu_pkt_write element contained within @ref ble_dfu_evt_t.*/
+    BLE_DFU_BYTES_RECEIVED_SEND                                         /**< The event indicating that the peer is requesting for the number of bytes of firmware data last received by the application. It is the responsibility of the application to call @ref ble_dfu_pkts_rcpt_notify in response to this event. */
+} ble_dfu_evt_type_t;
+
+/**@brief   DFU Procedure type.
+ *
+ * @details This enumeration contains the types of DFU procedures.
+ */
+typedef enum
+{
+    BLE_DFU_START_PROCEDURE        = 1,                                 /**< DFU Start procedure.*/
+    BLE_DFU_INIT_PROCEDURE         = 2,                                 /**< DFU Initialization procedure.*/
+    BLE_DFU_RECEIVE_APP_PROCEDURE  = 3,                                 /**< Firmware receiving procedure.*/
+    BLE_DFU_VALIDATE_PROCEDURE     = 4,                                 /**< Firmware image validation procedure .*/
+    BLE_DFU_PKT_RCPT_REQ_PROCEDURE = 8                                  /**< Packet receipt notification request procedure. */
+} ble_dfu_procedure_t;
+
+/**@brief   DFU Response value type.
+ */
+typedef enum
+{
+    BLE_DFU_RESP_VAL_SUCCESS = 1,                                       /**< Success.*/
+    BLE_DFU_RESP_VAL_INVALID_STATE,                                     /**< Invalid state.*/
+    BLE_DFU_RESP_VAL_NOT_SUPPORTED,                                     /**< Operation not supported.*/
+    BLE_DFU_RESP_VAL_DATA_SIZE,                                         /**< Data size exceeds limit.*/
+    BLE_DFU_RESP_VAL_CRC_ERROR,                                         /**< CRC Error.*/
+    BLE_DFU_RESP_VAL_OPER_FAILED                                        /**< Operation failed.*/
+} ble_dfu_resp_val_t;
+
+/**@brief   DFU Packet structure.
+ *
+ * @details This structure contains the value of the DFU Packet characteristic as written by the
+ *          peer and the length of the value written. It will be filled by the DFU Service when the
+ *          peer writes to the DFU Packet characteristic.
+ */
+typedef struct
+{
+    uint8_t                      len;                                   /**< Length of the packet received. */
+    uint8_t *                    p_data;                                /**< Pointer to the received packet. This will point to a word aligned memory location.*/
+} ble_dfu_pkt_write_t;
+
+/**@brief   Packet receipt notification request structure.
+ *
+ * @details This structure contains the contents of the packet receipt notification request
+ *          sent by the DFU Controller.
+ */
+typedef struct
+{
+    uint16_t                     num_of_pkts;                           /**< The number of packets of firmware data to be received by application before sending the next Packet Receipt Notification to the peer. */
+} ble_pkt_rcpt_notif_req_t;
+
+/**@brief   DFU Event structure.
+ *
+ * @details This structure contains the event generated by the DFU Service based on the data
+ *          received from the peer.
+ */
+typedef struct
+{
+    ble_dfu_evt_type_t           ble_dfu_evt_type;                      /**< Type of the event.*/
+    union
+    {
+        ble_dfu_pkt_write_t      ble_dfu_pkt_write;                     /**< The DFU packet received. This field is when the @ref ble_dfu_evt_type field is set to @ref BLE_DFU_PACKET_WRITE.*/
+        ble_pkt_rcpt_notif_req_t pkt_rcpt_notif_req;                    /**< Packet receipt notification request. This field is when the @ref ble_dfu_evt_type field is set to @ref BLE_DFU_PKT_RCPT_NOTIF_ENABLED.*/
+    } evt;
+} ble_dfu_evt_t;
+
+// Forward declaration of the ble_dfu_t type.
+typedef struct ble_dfu_s ble_dfu_t;
+
+/**@brief DFU Service event handler type. */
+typedef void (*ble_dfu_evt_handler_t) (ble_dfu_t * p_dfu, ble_dfu_evt_t * p_evt);
+
+/**@brief   DFU service structure.
+ *
+ * @details This structure contains status information related to the service.
+ */
+typedef struct ble_dfu_s
+{
+    uint16_t                     conn_handle;                           /**< Handle of the current connection (as provided by the S110 SoftDevice). This will be BLE_CONN_HANDLE_INVALID when not in a connection. */
+    uint16_t                     service_handle;                        /**< Handle of DFU Service (as provided by the S110 SoftDevice). */
+    uint8_t                      uuid_type;                             /**< UUID type assigned for DFU Service by the S110 SoftDevice. */
+    ble_gatts_char_handles_t     dfu_pkt_handles;                       /**< Handles related to the DFU Packet characteristic. */
+    ble_gatts_char_handles_t     dfu_ctrl_pt_handles;                   /**< Handles related to the DFU Control Point characteristic. */
+    ble_gatts_char_handles_t     dfu_status_rep_handles;                /**< Handles related to the DFU Status Report characteristic. */
+    ble_dfu_evt_handler_t        evt_handler;                           /**< The event handler to be called when an event is to be sent to the application.*/
+    ble_srv_error_handler_t      error_handler;                         /**< Function to be called in case of an error. */
+} ble_dfu_t;
+
+/**@brief      DFU service initialization structure.
+ *
+ * @details    This structure contains the initialization information for the DFU Service. The
+ *             application needs to fill this structure and pass it to the DFU Service using the
+ *             @ref ble_dfu_init function.
+ */
+typedef struct
+{
+    ble_dfu_evt_handler_t        evt_handler;                           /**< Event handler to be called for handling events in the Device Firmware Update Service. */
+    ble_srv_error_handler_t      error_handler;                         /**< Function to be called in case of an error. */
+} ble_dfu_init_t;
+
+/**@brief      Function for handling a BLE event.
+ *
+ * @details    The DFU service expects the application to call this function each time an event
+ *             is received from the S110 SoftDevice. This function processes the event, if it is
+ *             relevant for the DFU service and calls the DFU event handler of the application if
+ *             necessary.
+ *
+ * @param[in]  p_dfu        Pointer to the DFU service structure.
+ * @param[in]  p_ble_evt    Pointer to the event received from S110 SoftDevice.
+ */
+void ble_dfu_on_ble_evt(ble_dfu_t * p_dfu, ble_evt_t * p_ble_evt);
+
+/**@brief      Function for initializing the DFU service.
+ *
+ * @param[out] p_dfu        Device Firmware Update service structure. This structure will have to be
+ *                          supplied by the application. It will be initialized by this function,
+ *                          and will later be used to identify the service instance.
+ * @param[in]  p_dfu_init   Information needed to initialize the service.
+ *
+ * @return     NRF_SUCCESS if the DFU service and its characteristics were successfully added to the
+ *             S110 SoftDevice. Otherwise an error code.
+ *             This function returns NRF_ERROR_NULL if the value of evt_handler in p_dfu_init
+ *             structure provided is NULL or if the pointers supplied as input are NULL.
+ */
+uint32_t ble_dfu_init(ble_dfu_t * p_dfu, ble_dfu_init_t * p_dfu_init);
+
+/**@brief       Function for sending response to a control point command.
+ *
+ * @details     This function will encode a DFU Control Point response using the given input
+ *              parameters and will send a notification of the same to the peer.
+ *
+ * @param[in]   p_dfu       Pointer to the DFU service structure.
+ * @param[in]   dfu_proc    Procedure for which this response is to be sent.
+ * @param[in]   resp_val    Response value.
+ *
+ * @return      NRF_SUCCESS if the DFU Service has successfully requested the S110 SoftDevice to
+ *              send the notification. Otherwise an error code.
+ *              This function returns NRF_ERROR_INVALID_STATE if the device is not connected to a
+ *              peer or if the DFU service is not initialized or if the notification of the DFU
+ *              Status Report characteristic was not enabled by the peer. It returns NRF_ERROR_NULL
+ *              if the pointer p_dfu is NULL.
+ */
+uint32_t ble_dfu_response_send(ble_dfu_t *          p_dfu,
+                               ble_dfu_procedure_t  dfu_proc,
+                               ble_dfu_resp_val_t   resp_val);
+
+/**@brief      Function for notifying the peer about the number of bytes of firmware data received.
+ *
+ * @param[in]  p_dfu                      Pointer to the DFU service structure.
+ * @param[in]  num_of_firmware_bytes_rcvd Number of bytes.
+ *
+ * @return     NRF_SUCCESS if the DFU Service has successfully requested the S110 SoftDevice to send
+ *             the notification. Otherwise an error code.
+ *             This function returns NRF_ERROR_INVALID_STATE if the device is not connected to a
+ *             peer or if the DFU service is not initialized or if the notification of the DFU
+ *             Status Report characteristic was not enabled by the peer. It returns NRF_ERROR_NULL
+ *             if the pointer p_dfu is NULL.
+ */
+uint32_t ble_dfu_bytes_rcvd_report(ble_dfu_t * p_dfu, uint32_t num_of_firmware_bytes_rcvd);
+
+/**@brief      Function for sending Packet Receipt Notification to the peer.
+ *
+ *             This function will encode the number of bytes received as input parameter into a
+ *             notification of the control point characteristic and send it to the peer.
+ *
+ * @param[in]  p_dfu                      Pointer to the DFU service structure.
+ * @param[in]  num_of_firmware_bytes_rcvd Number of bytes of firmware image received.
+ *
+ * @return     NRF_SUCCESS if the DFU Service has successfully requested the S110 SoftDevice to send
+ *             the notification. Otherwise an error code.
+ *             This function returns NRF_ERROR_INVALID_STATE if the device is not connected to a
+ *             peer or if the DFU service is not initialized or if the notification of the DFU
+ *             Status Report characteristic was not enabled by the peer. It returns NRF_ERROR_NULL
+ *             if the pointer p_dfu is NULL.
+ */
+uint32_t ble_dfu_pkts_rcpt_notify(ble_dfu_t * p_dfu, uint32_t num_of_firmware_bytes_rcvd);
+
+#endif // BLE_DFU_H__
+
+/** @} */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nordic/nrf-sdk/ble/ble_services/ble_dis.h	Mon Jul 07 13:43:31 2014 +0100
@@ -0,0 +1,95 @@
+/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ *
+ */
+
+/** @file
+ *
+ * @defgroup ble_sdk_srv_dis Device Information Service
+ * @{
+ * @ingroup ble_sdk_srv
+ * @brief Device Information Service module.
+ *
+ * @details This module implements the Device Information Service.
+ *          During initialization it adds the Device Information Service to the BLE stack database.
+ *          It then encodes the supplied information, and adds the curresponding characteristics.
+ *
+ * @note Attention! 
+ *  To maintain compliance with Nordic Semiconductor ASA Bluetooth profile 
+ *  qualification listings, this section of source code must not be modified.
+ */
+
+#ifndef BLE_DIS_H__
+#define BLE_DIS_H__
+
+#include <stdint.h>
+#include "ble_srv_common.h"
+
+// Vendor ID Source values
+#define BLE_DIS_VENDOR_ID_SRC_BLUETOOTH_SIG   1                 /**< Vendor ID assigned by Bluetooth SIG. */
+#define BLE_DIS_VENDOR_ID_SRC_USB_IMPL_FORUM  2                 /**< Vendor ID assigned by USB Implementer's Forum. */
+
+/**@brief System ID parameters */
+typedef struct
+{
+    uint64_t manufacturer_id;                                   /**< Manufacturer ID. Only 5 LSOs shall be used. */
+    uint32_t organizationally_unique_id;                        /**< Organizationally unique ID. Only 3 LSOs shall be used. */
+} ble_dis_sys_id_t;
+
+/**@brief IEEE 11073-20601 Regulatory Certification Data List Structure */
+typedef struct
+{
+    uint8_t *  p_list;                                          /**< Pointer the byte array containing the encoded opaque structure based on IEEE 11073-20601 specification. */
+    uint8_t    list_len;                                        /**< Length of the byte array. */
+} ble_dis_reg_cert_data_list_t;
+
+/**@brief PnP ID parameters */
+typedef struct
+{
+    uint8_t  vendor_id_source;                                  /**< Vendor ID Source. see @ref DIS_VENDOR_ID_SRC_VALUES. */
+    uint16_t vendor_id;                                         /**< Vendor ID. */
+    uint16_t product_id;                                        /**< Product ID. */
+    uint16_t product_version;                                   /**< Product Version. */
+} ble_dis_pnp_id_t;
+
+/**@brief Device Information Service init structure. This contains all possible characteristics 
+ *        needed for initialization of the service.
+ */
+typedef struct
+{
+    ble_srv_utf8_str_t             manufact_name_str;           /**< Manufacturer Name String. */
+    ble_srv_utf8_str_t             model_num_str;               /**< Model Number String. */
+    ble_srv_utf8_str_t             serial_num_str;              /**< Serial Number String. */
+    ble_srv_utf8_str_t             hw_rev_str;                  /**< Hardware Revision String. */
+    ble_srv_utf8_str_t             fw_rev_str;                  /**< Firmware Revision String. */
+    ble_srv_utf8_str_t             sw_rev_str;                  /**< Software Revision String. */
+    ble_dis_sys_id_t *             p_sys_id;                    /**< System ID. The helper function @ref dis_sys_id_encode can be used to encode the value of this characteristic. */
+    ble_dis_reg_cert_data_list_t * p_reg_cert_data_list;        /**< IEEE 11073-20601 Regulatory Certification Data List. */
+    ble_dis_pnp_id_t *             p_pnp_id;                    /**< PnP ID. The helper function @ref dis_pnp_id_encode can be used to encode the value of this characteristic. */
+    ble_srv_security_mode_t        dis_attr_md;                 /**< Initial Security Setting for Device Information Characteristics. */
+} ble_dis_init_t;
+
+/**@brief Function for initializing the Device Information Service.
+ *
+ * @details This call allows the application to initialize the device information service. 
+ *          It adds the DIS service and DIS characteristics to the database, using the initial
+ *          values supplied through the p_dis_init parameter. Characteristics which are not to be
+ *          added, shall be set to NULL in p_dis_init.
+ *
+ * @param[in]   p_dis_init   The structure containing the values of characteristics needed by the
+ *                           service.
+ *
+ * @return      NRF_SUCCESS on successful initialization of service.
+ */
+uint32_t ble_dis_init(const ble_dis_init_t * p_dis_init);
+
+#endif // BLE_DIS_H__
+
+/** @} */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nordic/nrf-sdk/ble/ble_services/ble_gls.h	Mon Jul 07 13:43:31 2014 +0100
@@ -0,0 +1,265 @@
+/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ */
+
+/** @file
+ *
+ * @defgroup ble_sdk_srv_gls Glucose Service
+ * @{
+ * @ingroup ble_sdk_srv
+ * @brief Glucose Service module.
+ *
+ * @details This module implements the Glucose Service.
+ *
+ * @note The application must propagate BLE stack events to the Glucose Service module by calling
+ *       ble_gls_on_ble_evt() from the from the @ref ble_stack_handler callback.
+ *
+ * @note Attention! 
+ *  To maintain compliance with Nordic Semiconductor ASA Bluetooth profile 
+ *  qualification listings, this section of source code must not be modified.
+ */
+
+#ifndef BLE_GLS_H__
+#define BLE_GLS_H__
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "ble.h"
+#include "ble_srv_common.h"
+#include "ble_date_time.h"
+
+/**@brief Glucose feature */
+#define BLE_GLS_FEATURE_LOW_BATT                       0x0001  /**< Low Battery Detection During Measurement Supported */
+#define BLE_GLS_FEATURE_MALFUNC                        0x0002  /**< Sensor Malfunction Detection Supported */
+#define BLE_GLS_FEATURE_SAMPLE_SIZE                    0x0004  /**< Sensor Sample Size Supported */
+#define BLE_GLS_FEATURE_INSERT_ERR                     0x0008  /**< Sensor Strip Insertion Error Detection Supported */
+#define BLE_GLS_FEATURE_TYPE_ERR                       0x0010  /**< Sensor Strip Type Error Detection Supported */
+#define BLE_GLS_FEATURE_RES_HIGH_LOW                   0x0020  /**< Sensor Result High-Low Detection Supported */
+#define BLE_GLS_FEATURE_TEMP_HIGH_LOW                  0x0040  /**< Sensor Temperature High-Low Detection Supported */
+#define BLE_GLS_FEATURE_READ_INT                       0x0080  /**< Sensor Read Interrupt Detection Supported */
+#define BLE_GLS_FEATURE_GENERAL_FAULT                  0x0100  /**< General Device Fault Supported */
+#define BLE_GLS_FEATURE_TIME_FAULT                     0x0200  /**< Time Fault Supported */
+#define BLE_GLS_FEATURE_MULTI_BOND                     0x0400  /**< Multiple Bond Supported */
+
+/**@brief Glucose measurement flags */
+#define BLE_GLS_MEAS_FLAG_TIME_OFFSET                  0x01    /**< Time Offset Present */
+#define BLE_GLS_MEAS_FLAG_CONC_TYPE_LOC                0x02    /**< Glucose Concentration, Type, and Sample Location Present */
+#define BLE_GLS_MEAS_FLAG_UNITS_KG_L                   0x00    /**< Glucose Concentration Units kg/L */
+#define BLE_GLS_MEAS_FLAG_UNITS_MOL_L                  0x04    /**< Glucose Concentration Units mol/L */
+#define BLE_GLS_MEAS_FLAG_SENSOR_STATUS                0x08    /**< Sensor Status Annunciation Present */
+#define BLE_GLS_MEAS_FLAG_CONTEXT_INFO                 0x10    /**< Context Information Follows */
+
+/**@brief Glucose measurement type */
+#define BLE_GLS_MEAS_TYPE_CAP_BLOOD                    1       /**< Capillary whole blood */
+#define BLE_GLS_MEAS_TYPE_CAP_PLASMA                   2       /**< Capillary plasma */
+#define BLE_GLS_MEAS_TYPE_VEN_BLOOD                    3       /**< Venous whole blood */
+#define BLE_GLS_MEAS_TYPE_VEN_PLASMA                   4       /**< Venous plasma */
+#define BLE_GLS_MEAS_TYPE_ART_BLOOD                    5       /**< Arterial whole blood */
+#define BLE_GLS_MEAS_TYPE_ART_PLASMA                   6       /**< Arterial plasma */
+#define BLE_GLS_MEAS_TYPE_UNDET_BLOOD                  7       /**< Undetermined whole blood */
+#define BLE_GLS_MEAS_TYPE_UNDET_PLASMA                 8       /**< Undetermined plasma */
+#define BLE_GLS_MEAS_TYPE_FLUID                        9       /**< Interstitial fluid (ISF) */
+#define BLE_GLS_MEAS_TYPE_CONTROL                      10      /**< Control solution */
+
+/**@brief Glucose measurement location */
+#define BLE_GLS_MEAS_LOC_FINGER                        1       /**< Finger */
+#define BLE_GLS_MEAS_LOC_AST                           2       /**< Alternate Site Test (AST) */
+#define BLE_GLS_MEAS_LOC_EAR                           3       /**< Earlobe */
+#define BLE_GLS_MEAS_LOC_CONTROL                       4       /**< Control solution */
+#define BLE_GLS_MEAS_LOC_NOT_AVAIL                     15      /**< Sample Location value not available */
+
+/**@brief Glucose sensor status annunciation */
+#define BLE_GLS_MEAS_STATUS_BATT_LOW                   0x0001  /**< Device battery low at time of measurement */
+#define BLE_GLS_MEAS_STATUS_SENSOR_FAULT               0x0002  /**< Sensor malfunction or faulting at time of measurement */
+#define BLE_GLS_MEAS_STATUS_SAMPLE_SIZE                0x0004  /**< Sample size for blood or control solution insufficient at time of measurement */
+#define BLE_GLS_MEAS_STATUS_STRIP_INSERT               0x0008  /**< Strip insertion error */
+#define BLE_GLS_MEAS_STATUS_STRIP_TYPE                 0x0010  /**< Strip type incorrect for device */
+#define BLE_GLS_MEAS_STATUS_RESULT_HIGH                0x0020  /**< Sensor result higher than the device can process */
+#define BLE_GLS_MEAS_STATUS_RESULT_LOW                 0x0040  /**< Sensor result lower than the device can process */
+#define BLE_GLS_MEAS_STATUS_TEMP_HIGH                  0x0080  /**< Sensor temperature too high for valid test/result at time of measurement */
+#define BLE_GLS_MEAS_STATUS_TEMP_LOW                   0x0100  /**< Sensor temperature too low for valid test/result at time of measurement */
+#define BLE_GLS_MEAS_STATUS_STRIP_PULL                 0x0200  /**< Sensor read interrupted because strip was pulled too soon at time of measurement */
+#define BLE_GLS_MEAS_STATUS_GENERAL_FAULT              0x0400  /**< General device fault has occurred in the sensor */
+#define BLE_GLS_MEAS_STATUS_TIME_FAULT                 0x0800  /**< Time fault has occurred in the sensor and time may be inaccurate */
+
+/**@brief Glucose measurement context flags */
+#define BLE_GLS_CONTEXT_FLAG_CARB                      0x01    /**< Carbohydrate id and carbohydrate present */
+#define BLE_GLS_CONTEXT_FLAG_MEAL                      0x02    /**< Meal present */
+#define BLE_GLS_CONTEXT_FLAG_TESTER                    0x04    /**< Tester-health present */
+#define BLE_GLS_CONTEXT_FLAG_EXERCISE                  0x08    /**< Exercise duration and exercise intensity present */
+#define BLE_GLS_CONTEXT_FLAG_MED                       0x10    /**< Medication ID and medication present */
+#define BLE_GLS_CONTEXT_FLAG_MED_KG                    0x00    /**< Medication value units, kilograms */
+#define BLE_GLS_CONTEXT_FLAG_MED_L                     0x20    /**< Medication value units, liters */
+#define BLE_GLS_CONTEXT_FLAG_HBA1C                     0x40    /**< Hba1c present */
+#define BLE_GLS_CONTEXT_FLAG_EXT                       0x80    /**< Extended flags present */
+
+/**@brief Glucose measurement context carbohydrate ID */
+#define BLE_GLS_CONTEXT_CARB_BREAKFAST                 1       /**< Breakfast */
+#define BLE_GLS_CONTEXT_CARB_LUNCH                     2       /**< Lunch */
+#define BLE_GLS_CONTEXT_CARB_DINNER                    3       /**< Dinner */
+#define BLE_GLS_CONTEXT_CARB_SNACK                     4       /**< Snack */
+#define BLE_GLS_CONTEXT_CARB_DRINK                     5       /**< Drink */
+#define BLE_GLS_CONTEXT_CARB_SUPPER                    6       /**< Supper */
+#define BLE_GLS_CONTEXT_CARB_BRUNCH                    7       /**< Brunch */
+
+/**@brief Glucose measurement context meal */
+#define BLE_GLS_CONTEXT_MEAL_PREPRANDIAL               1       /**< Preprandial (before meal) */
+#define BLE_GLS_CONTEXT_MEAL_POSTPRANDIAL              2       /**< Postprandial (after meal) */
+#define BLE_GLS_CONTEXT_MEAL_FASTING                   3       /**< Fasting */
+#define BLE_GLS_CONTEXT_MEAL_CASUAL                    4       /**< Casual (snacks, drinks, etc.) */
+#define BLE_GLS_CONTEXT_MEAL_BEDTIME                   5       /**< Bedtime */
+
+/**@brief Glucose measurement context tester */
+#define BLE_GLS_CONTEXT_TESTER_SELF                    1       /**< Self */
+#define BLE_GLS_CONTEXT_TESTER_PRO                     2       /**< Health care professional */
+#define BLE_GLS_CONTEXT_TESTER_LAB                     3       /**< Lab test */
+#define BLE_GLS_CONTEXT_TESTER_NOT_AVAIL               15      /**< Tester value not available */
+
+/**@brief Glucose measurement context health */
+#define BLE_GLS_CONTEXT_HEALTH_MINOR                   1       /**< Minor health issues */
+#define BLE_GLS_CONTEXT_HEALTH_MAJOR                   2       /**< Major health issues */
+#define BLE_GLS_CONTEXT_HEALTH_MENSES                  3       /**< During menses */
+#define BLE_GLS_CONTEXT_HEALTH_STRESS                  4       /**< Under stress */
+#define BLE_GLS_CONTEXT_HEALTH_NONE                    5       /**< No health issues */
+#define BLE_GLS_CONTEXT_HEALTH_NOT_AVAIL               15      /**< Health value not available */
+
+/**@brief Glucose measurement context medication ID */
+#define BLE_GLS_CONTEXT_MED_RAPID                      1       /**< Rapid acting insulin */
+#define BLE_GLS_CONTEXT_MED_SHORT                      2       /**< Short acting insulin */
+#define BLE_GLS_CONTEXT_MED_INTERMED                   3       /**< Intermediate acting insulin */
+#define BLE_GLS_CONTEXT_MED_LONG                       4       /**< Long acting insulin */
+#define BLE_GLS_CONTEXT_MED_PREMIX                     5       /**< Pre-mixed insulin */
+
+/**@brief SFLOAT format (IEEE-11073 16-bit FLOAT, meaning 4 bits for exponent (base 10) and 12 bits mantissa) */
+typedef struct
+{
+  int8_t exponent;                                             /**< Base 10 exponent, should be using only 4 bits */
+  int16_t mantissa;                                            /**< Mantissa, should be using only 12 bits */
+} sfloat_t;
+
+/**@brief Glucose Service event type. */
+typedef enum
+{
+    BLE_GLS_EVT_NOTIFICATION_ENABLED,                          /**< Glucose value notification enabled event. */
+    BLE_GLS_EVT_NOTIFICATION_DISABLED                          /**< Glucose value notification disabled event. */
+} ble_gls_evt_type_t;
+
+/**@brief Glucose Service event. */
+typedef struct
+{
+    ble_gls_evt_type_t evt_type;                               /**< Type of event. */
+} ble_gls_evt_t;
+
+// Forward declaration of the ble_gls_t type. 
+typedef struct ble_gls_s ble_gls_t;
+
+/**@brief Glucose Service event handler type. */
+typedef void (*ble_gls_evt_handler_t) (ble_gls_t * p_gls, ble_gls_evt_t * p_evt);
+
+/**@brief Glucose Measurement structure. This contains glucose measurement value. */
+typedef struct
+{
+    uint8_t         flags;                                     /**< Flags */
+    uint16_t        sequence_number;                           /**< Sequence number */
+    ble_date_time_t base_time;                                 /**< Time stamp */
+    int16_t         time_offset;                               /**< Time offset */
+    sfloat_t        glucose_concentration;                     /**< Glucose concentration */
+    uint8_t         type;                                      /**< Type */
+    uint8_t         sample_location;                           /**< Sample location */
+    uint16_t        sensor_status_annunciation;                /**< Sensor status annunciation */
+} ble_gls_meas_t;
+
+/**@brief Glucose measurement context structure */
+typedef struct
+{
+    uint8_t       flags;                                       /**< Flags */
+    uint8_t       extended_flags;                              /**< Extended Flags */
+    uint8_t       carbohydrate_id;                             /**< Carbohydrate ID */
+    sfloat_t      carbohydrate;                                /**< Carbohydrate */
+    uint8_t       meal;                                        /**< Meal */
+    uint8_t       tester_and_health;                           /**< Tester and health */
+    uint16_t      exercise_duration;                           /**< Exercise Duration */
+    uint8_t       exercise_intensity;                          /**< Exercise Intensity */
+    uint8_t       medication_id;                               /**< Medication ID */
+    sfloat_t      medication;                                  /**< Medication */
+    uint16_t      hba1c;                                       /**< HbA1c */
+} ble_gls_meas_context_t;
+
+/**@brief Glucose measurement record */
+typedef struct
+{
+  ble_gls_meas_t          meas;                                /**< Glucose measurement */
+  ble_gls_meas_context_t  context;                             /**< Glucose measurement context */
+} ble_gls_rec_t;
+
+/**@brief Glucose Service init structure. This contains all options and data needed for
+ *        initialization of the service. */
+typedef struct
+{
+    ble_gls_evt_handler_t     evt_handler;                     /**< Event handler to be called for handling events in the Glucose Service. */
+    ble_srv_error_handler_t   error_handler;                   /**< Function to be called in case of an error. */
+    uint16_t                  feature;                         /**< Glucose Feature value indicating supported features. */
+    bool                      is_context_supported;            /**< Determines if optional Glucose Measurement Context is to be supported. */
+} ble_gls_init_t;
+
+/**@brief Glucose Service structure. This contains various status information for the service. */
+typedef struct ble_gls_s
+{
+    ble_gls_evt_handler_t     evt_handler;                     /**< Event handler to be called for handling events in the Glucose Service. */
+    ble_srv_error_handler_t   error_handler;                   /**< Function to be called in case of an error. */
+    uint16_t                  service_handle;                  /**< Handle of Glucose Service (as provided by the BLE stack). */
+    ble_gatts_char_handles_t  glm_handles;                     /**< Handles related to the Glucose Measurement characteristic. */
+    ble_gatts_char_handles_t  glm_context_handles;             /**< Handles related to the Glucose Measurement Context characteristic. */
+    ble_gatts_char_handles_t  glf_handles;                     /**< Handles related to the Glucose Feature characteristic. */
+    ble_gatts_char_handles_t  racp_handles;                    /**< Handles related to the Record Access Control Point characteristic. */
+    uint16_t                  conn_handle;                     /**< Handle of the current connection (as provided by the BLE stack, is BLE_CONN_HANDLE_INVALID if not in a connection). */
+    uint16_t                  feature;
+    bool                      is_context_supported;
+} ble_gls_t;
+
+/**@brief Function for initializing the Glucose Service.
+ *
+ * @details This call allows the application to initialize the Glucose Service.
+ *
+ * @param[out]  p_gls       Glucose Service structure. This structure will have to be supplied by
+ *                          the application. It will be initialized by this function, and will later
+ *                          be used to identify this particular service instance.
+ * @param[in]   p_gls_init  Information needed to initialize the service.
+ *
+ * @return      NRF_SUCCESS on successful initialization of service, otherwise an error code.
+ */
+uint32_t ble_gls_init(ble_gls_t * p_gls, const ble_gls_init_t * p_gls_init);
+
+/**@brief Function for handling the Application's BLE Stack events.
+ *
+ * @details Handles all events from the BLE stack of interest to the Glucose Service.
+ *
+ * @param[in]   p_gls      Glucose Service structure.
+ * @param[in]   p_ble_evt  Event received from the BLE stack.
+ */
+void ble_gls_on_ble_evt(ble_gls_t * p_gls, ble_evt_t * p_ble_evt);
+
+/**@brief Function for reporting a new glucose measurement to the glucose service module.
+ *
+ * @details The application calls this function after having performed a new glucose measurement.
+ *          The new measurement is recorded in the RACP database.
+ *
+ * @param[in]   p_gls                    Glucose Service structure.
+ * @param[in]   p_rec                    Pointer to glucose record (measurement plus context).
+ *
+ * @return      NRF_SUCCESS on success, otherwise an error code.
+ */
+uint32_t ble_gls_glucose_new_meas(ble_gls_t * p_gls, ble_gls_rec_t * p_rec);
+
+#endif // BLE_GLS_H__
+
+/** @} */
+
+/** @endcond */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nordic/nrf-sdk/ble/ble_services/ble_gls_db.h	Mon Jul 07 13:43:31 2014 +0100
@@ -0,0 +1,86 @@
+/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ */
+
+/** @file
+ *
+ * @defgroup ble_sdk_srv_gls_db Glucose Database Service
+ * @{
+ * @ingroup ble_sdk_srv
+ * @brief Glucose Service module.
+ *
+ * @details This module implements at database of stored glucose measurement values.
+ *
+ * @note Attention! 
+ *  To maintain compliance with Nordic Semiconductor ASA Bluetooth profile 
+ *  qualification listings, These APIs must not be modified. However, the corresponding
+ *  functions' implementations can be modified.
+ */
+
+#ifndef BLE_GLS_DB_H__
+#define BLE_GLS_DB_H__
+
+#include <stdint.h>
+#include "ble_gls.h"
+
+#define BLE_GLS_DB_MAX_RECORDS      20
+
+/**@brief Function for initializing the glucose record database.
+ *
+ * @details This call initializes the database holding glucose records.
+ *
+ * @return      NRF_SUCCESS on success. 
+ */
+uint32_t ble_gls_db_init(void);
+
+/**@brief Function for getting the number of records in the database.
+ *
+ * @details This call returns the number of records in the database.
+ *
+ * @return      Number of records in the database.
+ */
+uint16_t ble_gls_db_num_records_get(void);
+
+/**@brief Function for getting a record from the database.
+ *
+ * @details This call returns a specified record from the database.
+ *
+ * @param[in]   record_num    Index of the record to retrieve.
+ * @param[out]  p_rec         Pointer to record structure where retrieved record is copied to.
+ * 
+ * @return      NRF_SUCCESS on success.
+ */
+uint32_t ble_gls_db_record_get(uint8_t record_num, ble_gls_rec_t * p_rec);
+
+/**@brief Function for adding a record at the end of the database.
+ *
+ * @details This call adds a record as the last record in the database.
+ *
+ * @param[in]   p_rec   Pointer to record to add to database.
+ * 
+ * @return      NRF_SUCCESS on success.
+ */
+uint32_t ble_gls_db_record_add(ble_gls_rec_t * p_rec);
+
+/**@brief Function for deleting a database entry.
+ *
+ * @details This call deletes an record from the database.
+ *
+ * @param[in]   record_num   Index of record to delete.
+ * 
+ * @return      NRF_SUCCESS on success.
+ */
+uint32_t ble_gls_db_record_delete(uint8_t record_num);
+
+#endif // BLE_GLS_DB_H__
+
+/** @} */
+
+/** @endcond */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nordic/nrf-sdk/ble/ble_services/ble_hids.h	Mon Jul 07 13:43:31 2014 +0100
@@ -0,0 +1,310 @@
+/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ *
+ */
+
+/** @file
+ *
+ * @defgroup ble_sdk_srv_hids Human Interface Device Service
+ * @{
+ * @ingroup ble_sdk_srv
+ * @brief Human Interface Device Service module.
+ *
+ * @details This module implements the Human Interface Device Service with the corresponding set of
+ *          characteristics. During initialization it adds the Human Interface Device Service and 
+ *          a set of characteristics as per the Human Interface Device Service specification and
+ *          the user requirements to the BLE stack database.
+ *
+ *          If enabled, notification of Input Report characteristics is performed when the
+ *          application calls the corresponding ble_hids_xx_input_report_send() function.
+ *
+ *          If an event handler is supplied by the application, the Human Interface Device Service
+ *          will generate Human Interface Device Service events to the application.
+ *
+ * @note The application must propagate BLE stack events to the Human Interface Device Service
+ *       module by calling ble_hids_on_ble_evt() from the @ref ble_stack_handler callback.
+ *
+ * @note Attention! 
+ *  To maintain compliance with Nordic Semiconductor ASA Bluetooth profile 
+ *  qualification listings, this section of source code must not be modified.
+ */
+
+#ifndef BLE_HIDS_H__
+#define BLE_HIDS_H__
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "ble.h"
+#include "ble_srv_common.h"
+
+// Report Type values
+#define BLE_HIDS_REP_TYPE_INPUT                 1
+#define BLE_HIDS_REP_TYPE_OUTPUT                2
+#define BLE_HIDS_REP_TYPE_FEATURE               3
+
+// Maximum number of the various Report Types
+#define BLE_HIDS_MAX_INPUT_REP                  10
+#define BLE_HIDS_MAX_OUTPUT_REP                 10
+#define BLE_HIDS_MAX_FEATURE_REP                10
+
+// Information Flags
+#define HID_INFO_FLAG_REMOTE_WAKE_MSK           0x01
+#define HID_INFO_FLAG_NORMALLY_CONNECTABLE_MSK  0x02
+
+/**@brief HID Service characteristic id. */
+typedef struct
+{
+    uint16_t uuid;                                  /**< UUID of characteristic. */
+    uint8_t  rep_type;                              /**< Type of report (only used for BLE_UUID_REPORT_CHAR, see @ref BLE_HIDS_REPORT_TYPE). */
+    uint8_t  rep_index;                             /**< Index of the characteristic (only used for BLE_UUID_REPORT_CHAR). */
+} ble_hids_char_id_t;
+
+/**@brief HID Service event type. */
+typedef enum
+{
+    BLE_HIDS_EVT_HOST_SUSP,                         /**< Suspend command received. */
+    BLE_HIDS_EVT_HOST_EXIT_SUSP,                    /**< Exit suspend command received. */
+    BLE_HIDS_EVT_NOTIF_ENABLED,                     /**< Notification enabled event. */
+    BLE_HIDS_EVT_NOTIF_DISABLED,                    /**< Notification disabled event. */
+    BLE_HIDS_EVT_REP_CHAR_WRITE,                    /**< A new value has been written to an Report characteristic. */
+    BLE_HIDS_EVT_BOOT_MODE_ENTERED,                 /**< Boot mode entered. */
+    BLE_HIDS_EVT_REPORT_MODE_ENTERED,               /**< Report mode entered. */
+    BLE_HIDS_EVT_REPORT_READ                        /**< Read with response */
+} ble_hids_evt_type_t;
+
+/**@brief HID Service event. */
+typedef struct
+{
+    ble_hids_evt_type_t evt_type;                   /**< Type of event. */
+    union
+    {
+        struct
+        {
+            ble_hids_char_id_t char_id;             /**< Id of characteristic for which notification has been started. */
+        } notification;
+        struct
+        {
+            ble_hids_char_id_t char_id;             /**< Id of characteristic having been written. */
+            uint16_t           offset;              /**< Offset for the write operation. */
+            uint16_t           len;                 /**< Length of the incoming data. */
+            uint8_t*           data;                /**< Incoming data, variable length */            
+        } char_write;
+        struct
+        {
+            ble_hids_char_id_t char_id;             /**< Id of characteristic being read. */
+        } char_auth_read;
+    } params;
+    ble_evt_t * p_ble_evt;                          /**< corresponding received ble event, NULL if not relevant */
+} ble_hids_evt_t;
+
+// Forward declaration of the ble_hids_t type. 
+typedef struct ble_hids_s ble_hids_t;
+
+/**@brief HID Service event handler type. */
+typedef void (*ble_hids_evt_handler_t) (ble_hids_t * p_hids, ble_hids_evt_t * p_evt);
+
+/**@brief HID Information characteristic value. */
+typedef struct
+{
+    uint16_t                      bcd_hid;          /**< 16-bit unsigned integer representing version number of base USB HID Specification implemented by HID Device */
+    uint8_t                       b_country_code;   /**< Identifies which country the hardware is localized for. Most hardware is not localized and thus this value would be zero (0). */
+    uint8_t                       flags;            /**< See http://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.hid_information.xml */
+    ble_srv_security_mode_t       security_mode;    /**< Security mode for the HID Information characteristic. */
+} ble_hids_hid_information_t;
+
+/**@brief HID Service Input Report characteristic init structure. This contains all options and 
+ *        data needed for initialization of one Input Report characteristic. */
+typedef struct
+{
+    uint16_t                      max_len;          /**< Maximum length of characteristic value. */
+    ble_srv_report_ref_t          rep_ref;          /**< Value of the Report Reference descriptor. */
+    ble_srv_cccd_security_mode_t  security_mode;    /**< Security mode for the HID Input Report characteristic, including cccd. */
+    uint8_t                       read_resp : 1;    /**< Should application generate a response to read requests. */
+} ble_hids_inp_rep_init_t;
+
+/**@brief HID Service Output Report characteristic init structure. This contains all options and 
+ *        data needed for initialization of one Output Report characteristic. */
+typedef struct
+{
+    uint16_t                      max_len;          /**< Maximum length of characteristic value. */
+    ble_srv_report_ref_t          rep_ref;          /**< Value of the Report Reference descriptor. */
+    ble_srv_cccd_security_mode_t  security_mode;    /**< Security mode for the HID Output Report characteristic, including cccd. */
+    uint8_t                       read_resp : 1;    /**< Should application generate a response to read requests. */
+} ble_hids_outp_rep_init_t;
+
+/**@brief HID Service Feature Report characteristic init structure. This contains all options and 
+ *        data needed for initialization of one Feature Report characteristic. */
+typedef struct
+{
+    uint16_t                      max_len;          /**< Maximum length of characteristic value. */
+    ble_srv_report_ref_t          rep_ref;          /**< Value of the Report Reference descriptor. */
+    ble_srv_cccd_security_mode_t  security_mode;    /**< Security mode for the HID Service Feature Report characteristic, including cccd. */
+    uint8_t                       read_resp : 1;    /**< Should application generate a response to read requests. */
+} ble_hids_feature_rep_init_t;
+
+/**@brief HID Service Report Map characteristic init structure. This contains all options and data 
+ *        needed for initialization of the Report Map characteristic. */
+typedef struct
+{
+    uint8_t *                     p_data;           /**< Report map data. */
+    uint16_t                      data_len;         /**< Length of report map data. */
+    uint8_t                       ext_rep_ref_num;  /**< Number of Optional External Report Reference descriptors. */
+    ble_uuid_t *                  p_ext_rep_ref;    /**< Optional External Report Reference descriptor (will be added if != NULL). */
+    ble_srv_security_mode_t       security_mode;    /**< Security mode for the HID Service Report Map characteristic. */
+} ble_hids_rep_map_init_t;
+
+/**@brief HID Report characteristic structure. */
+typedef struct
+{
+    ble_gatts_char_handles_t      char_handles;     /**< Handles related to the Report characteristic. */
+    uint16_t                      ref_handle;       /**< Handle of the Report Reference descriptor. */
+} ble_hids_rep_char_t;
+
+/**@brief HID Service init structure. This contains all options and data needed for initialization 
+ *        of the service. */
+typedef struct
+{
+    ble_hids_evt_handler_t        evt_handler;                                  /**< Event handler to be called for handling events in the HID Service. */
+    ble_srv_error_handler_t       error_handler;                                /**< Function to be called in case of an error. */
+    bool                          is_kb;                                        /**< TRUE if device is operating as a keyboard, FALSE if it is not. */
+    bool                          is_mouse;                                     /**< TRUE if device is operating as a mouse, FALSE if it is not. */
+    uint8_t                       inp_rep_count;                                /**< Number of Input Report characteristics. */
+    ble_hids_inp_rep_init_t *     p_inp_rep_array;                              /**< Information about the Input Report characteristics. */
+    uint8_t                       outp_rep_count;                               /**< Number of Output Report characteristics. */
+    ble_hids_outp_rep_init_t *    p_outp_rep_array;                             /**< Information about the Output Report characteristics. */
+    uint8_t                       feature_rep_count;                            /**< Number of Feature Report characteristics. */
+    ble_hids_feature_rep_init_t * p_feature_rep_array;                          /**< Information about the Feature Report characteristics. */
+    ble_hids_rep_map_init_t       rep_map;                                      /**< Information nedeed for initialization of the Report Map characteristic. */
+    ble_hids_hid_information_t    hid_information;                              /**< Value of the HID Information characteristic. */
+    uint8_t                       included_services_count;                      /**< Number of services to include in HID service. */
+    uint16_t *                    p_included_services_array;                    /**< Array of services to include in HID service. */
+    ble_srv_security_mode_t       security_mode_protocol;                       /**< Security settings for HID service protocol attribute */
+    ble_srv_security_mode_t       security_mode_ctrl_point;                     /**< Security settings for HID service Control Point attribute */
+    ble_srv_cccd_security_mode_t  security_mode_boot_mouse_inp_rep;             /**< Security settings for HID service Mouse input report attribute */
+    ble_srv_cccd_security_mode_t  security_mode_boot_kb_inp_rep;                /**< Security settings for HID service Keyboard input report attribute */
+    ble_srv_security_mode_t       security_mode_boot_kb_outp_rep;               /**< Security settings for HID service Keyboard output report attribute */
+} ble_hids_init_t;
+
+/**@brief HID Service structure. This contains various status information for the service. */
+typedef struct ble_hids_s
+{
+    ble_hids_evt_handler_t        evt_handler;                                  /**< Event handler to be called for handling events in the HID Service. */
+    ble_srv_error_handler_t       error_handler;                                /**< Function to be called in case of an error. */
+    uint16_t                      service_handle;                               /**< Handle of HID Service (as provided by the BLE stack). */
+    ble_gatts_char_handles_t      protocol_mode_handles;                        /**< Handles related to the Protocol Mode characteristic (will only be created if ble_hids_init_t.is_kb or ble_hids_init_t.is_mouse is set). */
+    uint8_t                       inp_rep_count;                                /**< Number of Input Report characteristics. */
+    ble_hids_rep_char_t           inp_rep_array[BLE_HIDS_MAX_INPUT_REP];        /**< Information about the Input Report characteristics. */
+    uint8_t                       outp_rep_count;                               /**< Number of Output Report characteristics. */
+    ble_hids_rep_char_t           outp_rep_array[BLE_HIDS_MAX_OUTPUT_REP];      /**< Information about the Output Report characteristics. */
+    uint8_t                       feature_rep_count;                            /**< Number of Feature Report characteristics. */
+    ble_hids_rep_char_t           feature_rep_array[BLE_HIDS_MAX_FEATURE_REP];  /**< Information about the Feature Report characteristics. */
+    ble_gatts_char_handles_t      rep_map_handles;                              /**< Handles related to the Report Map characteristic. */
+    uint16_t                      rep_map_ext_rep_ref_handle;                   /**< Handle of the Report Map External Report Reference descriptor. */
+    ble_gatts_char_handles_t      boot_kb_inp_rep_handles;                      /**< Handles related to the Boot Keyboard Input Report characteristic (will only be created if ble_hids_init_t.is_kb is set). */
+    ble_gatts_char_handles_t      boot_kb_outp_rep_handles;                     /**< Handles related to the Boot Keyboard Output Report characteristic (will only be created if ble_hids_init_t.is_kb is set). */
+    ble_gatts_char_handles_t      boot_mouse_inp_rep_handles;                   /**< Handles related to the Boot Mouse Input Report characteristic (will only be created if ble_hids_init_t.is_mouse is set). */
+    ble_gatts_char_handles_t      hid_information_handles;                      /**< Handles related to the Report Map characteristic. */
+    ble_gatts_char_handles_t      hid_control_point_handles;                    /**< Handles related to the Report Map characteristic. */
+    uint16_t                      conn_handle;                                  /**< Handle of the current connection (as provided by the BLE stack, is BLE_CONN_HANDLE_INVALID if not in a connection). */
+} ble_hids_t;
+
+/**@brief Function for initializing the HID Service.
+ *
+ * @param[out]  p_hids       HID Service structure. This structure will have to be supplied by the
+ *                           application. It will be initialized by this function, and will later be
+ *                           used to identify this particular service instance.
+ * @param[in]   p_hids_init  Information needed to initialize the service.
+ *
+ * @return      NRF_SUCCESS on successful initialization of service, otherwise an error code.
+ */
+uint32_t ble_hids_init(ble_hids_t * p_hids, const ble_hids_init_t * p_hids_init);
+
+/**@brief Function for handling the Application's BLE Stack events.
+ *
+ * @details Handles all events from the BLE stack of interest to the HID Service.
+ *
+ * @param[in]   p_hids     HID Service structure.
+ * @param[in]   p_ble_evt  Event received from the BLE stack.
+ */
+void ble_hids_on_ble_evt(ble_hids_t * p_hids, ble_evt_t * p_ble_evt);
+
+/**@brief Function for sending Input Report.
+ *
+ * @details Sends data on an Input Report characteristic.
+ *
+ * @param[in]   p_hids       HID Service structure.
+ * @param[in]   rep_index    Index of the characteristic (corresponding to the index in 
+ *                           ble_hids_t.inp_rep_array as passed to ble_hids_init()).
+ * @param[in]   len          Length of data to be sent.
+ * @param[in]   p_data       Pointer to data to be sent.
+ *
+ * @return      NRF_SUCCESS on successful sending of input report, otherwise an error code.
+ */
+uint32_t ble_hids_inp_rep_send(ble_hids_t * p_hids, 
+                               uint8_t      rep_index, 
+                               uint16_t     len, 
+                               uint8_t *    p_data);
+
+/**@brief Function for sending Boot Keyboard Input Report.
+ *
+ * @details Sends data on an Boot Keyboard Input Report characteristic.
+ *
+ * @param[in]   p_hids       HID Service structure.
+ * @param[in]   len          Length of data to be sent.
+ * @param[in]   p_data       Pointer to data to be sent.
+ *
+ * @return      NRF_SUCCESS on successful sending of the report, otherwise an error code.
+ */
+uint32_t ble_hids_boot_kb_inp_rep_send(ble_hids_t * p_hids, 
+                                       uint16_t     len, 
+                                       uint8_t *    p_data);
+
+/**@brief Function for sending Boot Mouse Input Report.
+ *
+ * @details Sends data on an Boot Mouse Input Report characteristic.
+ *
+ * @param[in]   p_hids              HID Service structure.
+ * @param[in]   buttons             State of mouse buttons.
+ * @param[in]   x_delta             Horizontal movement.
+ * @param[in]   y_delta             Vertical movement.
+ * @param[in]   optional_data_len   Length of optional part of Boot Mouse Input Report.
+ * @param[in]   p_optional_data     Optional part of Boot Mouse Input Report.
+ *
+ * @return      NRF_SUCCESS on successful sending of the report, otherwise an error code.
+ */
+uint32_t ble_hids_boot_mouse_inp_rep_send(ble_hids_t * p_hids, 
+                                          uint8_t      buttons, 
+                                          int8_t       x_delta, 
+                                          int8_t       y_delta,
+                                          uint16_t     optional_data_len,
+                                          uint8_t *    p_optional_data);
+
+/**@brief Function for getting the current value of Output Report from the stack.
+ *
+ * @details Fetches the current value of the output report characteristic from the stack.
+ *
+ * @param[in]   p_hids      HID Service structure.
+ * @param[in]   rep_index   Index of the characteristic (corresponding to the index in
+ *                          ble_hids_t.outp_rep_array as passed to ble_hids_init()).
+ * @param[in]   len         Length of output report needed.
+ * @param[in]   offset      Offset in bytes to read from.
+ * @param[out]  p_outp_rep  Pointer to the output report.
+ *
+ * @return      NRF_SUCCESS on successful read of the report, otherwise an error code.
+ */
+uint32_t ble_hids_outp_rep_get(ble_hids_t * p_hids,
+                               uint8_t      rep_index,
+                               uint16_t     len,
+                               uint8_t      offset,
+                               uint8_t *    p_outp_rep);
+
+#endif // BLE_HIDS_H__
+
+/** @} */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nordic/nrf-sdk/ble/ble_services/ble_hrs.h	Mon Jul 07 13:43:31 2014 +0100
@@ -0,0 +1,194 @@
+/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ *
+ */
+
+/** @file
+ *
+ * @defgroup ble_sdk_srv_hrs Heart Rate Service
+ * @{
+ * @ingroup ble_sdk_srv
+ * @brief Heart Rate Service module.
+ *
+ * @details This module implements the Heart Rate Service with the Heart Rate Measurement,
+ *          Body Sensor Location and Heart Rate Control Point characteristics.
+ *          During initialization it adds the Heart Rate Service and Heart Rate Measurement
+ *          characteristic to the BLE stack database. Optionally it also adds the
+ *          Body Sensor Location and Heart Rate Control Point characteristics.
+ *
+ *          If enabled, notification of the Heart Rate Measurement characteristic is performed
+ *          when the application calls ble_hrs_heart_rate_measurement_send().
+ *
+ *          The Heart Rate Service also provides a set of functions for manipulating the
+ *          various fields in the Heart Rate Measurement characteristic, as well as setting
+ *          the Body Sensor Location characteristic value.
+ *
+ *          If an event handler is supplied by the application, the Heart Rate Service will
+ *          generate Heart Rate Service events to the application.
+ *
+ * @note The application must propagate BLE stack events to the Heart Rate Service module by calling
+ *       ble_hrs_on_ble_evt() from the from the @ref ble_stack_handler callback.
+ *
+ * @note Attention! 
+ *  To maintain compliance with Nordic Semiconductor ASA Bluetooth profile 
+ *  qualification listings, this section of source code must not be modified.
+ */
+
+#ifndef BLE_HRS_H__
+#define BLE_HRS_H__
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "ble.h"
+#include "ble_srv_common.h"
+
+// Body Sensor Location values
+#define BLE_HRS_BODY_SENSOR_LOCATION_OTHER      0
+#define BLE_HRS_BODY_SENSOR_LOCATION_CHEST      1
+#define BLE_HRS_BODY_SENSOR_LOCATION_WRIST      2
+#define BLE_HRS_BODY_SENSOR_LOCATION_FINGER     3
+#define BLE_HRS_BODY_SENSOR_LOCATION_HAND       4
+#define BLE_HRS_BODY_SENSOR_LOCATION_EAR_LOBE   5
+#define BLE_HRS_BODY_SENSOR_LOCATION_FOOT       6
+
+#define BLE_HRS_MAX_BUFFERED_RR_INTERVALS       20      /**< Size of RR Interval buffer inside service. */
+
+/**@brief Heart Rate Service event type. */
+typedef enum
+{
+    BLE_HRS_EVT_NOTIFICATION_ENABLED,                   /**< Heart Rate value notification enabled event. */
+    BLE_HRS_EVT_NOTIFICATION_DISABLED                   /**< Heart Rate value notification disabled event. */
+} ble_hrs_evt_type_t;
+
+/**@brief Heart Rate Service event. */
+typedef struct
+{
+    ble_hrs_evt_type_t evt_type;                        /**< Type of event. */
+} ble_hrs_evt_t;
+
+// Forward declaration of the ble_hrs_t type. 
+typedef struct ble_hrs_s ble_hrs_t;
+
+/**@brief Heart Rate Service event handler type. */
+typedef void (*ble_hrs_evt_handler_t) (ble_hrs_t * p_hrs, ble_hrs_evt_t * p_evt);
+
+/**@brief Heart Rate Service init structure. This contains all options and data needed for
+ *        initialization of the service. */
+typedef struct
+{
+    ble_hrs_evt_handler_t        evt_handler;                                          /**< Event handler to be called for handling events in the Heart Rate Service. */
+    bool                         is_sensor_contact_supported;                          /**< Determines if sensor contact detection is to be supported. */
+    uint8_t *                    p_body_sensor_location;                               /**< If not NULL, initial value of the Body Sensor Location characteristic. */
+    ble_srv_cccd_security_mode_t hrs_hrm_attr_md;                                      /**< Initial security level for heart rate service measurement attribute */
+    ble_srv_security_mode_t      hrs_bsl_attr_md;                                      /**< Initial security level for body sensor location attribute */
+} ble_hrs_init_t;
+
+/**@brief Heart Rate Service structure. This contains various status information for the service. */
+typedef struct ble_hrs_s
+{
+    ble_hrs_evt_handler_t        evt_handler;                                          /**< Event handler to be called for handling events in the Heart Rate Service. */
+    bool                         is_expended_energy_supported;                         /**< TRUE if Expended Energy measurement is supported. */
+    bool                         is_sensor_contact_supported;                          /**< TRUE if sensor contact detection is supported. */
+    uint16_t                     service_handle;                                       /**< Handle of Heart Rate Service (as provided by the BLE stack). */
+    ble_gatts_char_handles_t     hrm_handles;                                          /**< Handles related to the Heart Rate Measurement characteristic. */
+    ble_gatts_char_handles_t     bsl_handles;                                          /**< Handles related to the Body Sensor Location characteristic. */
+    ble_gatts_char_handles_t     hrcp_handles;                                         /**< Handles related to the Heart Rate Control Point characteristic. */
+    uint16_t                     conn_handle;                                          /**< Handle of the current connection (as provided by the BLE stack, is BLE_CONN_HANDLE_INVALID if not in a connection). */
+    bool                         is_sensor_contact_detected;                           /**< TRUE if sensor contact has been detected. */
+    uint16_t                     rr_interval[BLE_HRS_MAX_BUFFERED_RR_INTERVALS];       /**< Set of RR Interval measurements since the last Heart Rate Measurement transmission. */
+    uint16_t                     rr_interval_count;                                    /**< Number of RR Interval measurements since the last Heart Rate Measurement transmission. */
+} ble_hrs_t;
+
+/**@brief Function for initializing the Heart Rate Service.
+ *
+ * @param[out]  p_hrs       Heart Rate Service structure. This structure will have to be supplied by
+ *                          the application. It will be initialized by this function, and will later
+ *                          be used to identify this particular service instance.
+ * @param[in]   p_hrs_init  Information needed to initialize the service.
+ *
+ * @return      NRF_SUCCESS on successful initialization of service, otherwise an error code.
+ */
+uint32_t ble_hrs_init(ble_hrs_t * p_hrs, const ble_hrs_init_t * p_hrs_init);
+
+/**@brief Function for handling the Application's BLE Stack events.
+ *
+ * @details Handles all events from the BLE stack of interest to the Heart Rate Service.
+ *
+ * @param[in]   p_hrs      Heart Rate Service structure.
+ * @param[in]   p_ble_evt  Event received from the BLE stack.
+ */
+void ble_hrs_on_ble_evt(ble_hrs_t * p_hrs, ble_evt_t * p_ble_evt);
+
+/**@brief Function for sending heart rate measurement if notification has been enabled.
+ *
+ * @details The application calls this function after having performed a heart rate measurement.
+ *          If notification has been enabled, the heart rate measurement data is encoded and sent to
+ *          the client.
+ *
+ * @param[in]   p_hrs                    Heart Rate Service structure.
+ * @param[in]   heart_rate               New heart rate measurement.
+ * @param[in]   include_expended_energy  Determines if expended energy will be included in the
+ *                                       heart rate measurement data.
+ *
+ * @return      NRF_SUCCESS on success, otherwise an error code.
+ */
+uint32_t ble_hrs_heart_rate_measurement_send(ble_hrs_t * p_hrs, uint16_t heart_rate);
+
+/**@brief Function for adding a RR Interval measurement to the RR Interval buffer.
+ *
+ * @details All buffered RR Interval measurements will be included in the next heart rate
+ *          measurement message, up to the maximum number of measurements that will fit into the
+ *          message. If the buffer is full, the oldest measurement in the buffer will be deleted.
+ *
+ * @param[in]   p_hrs        Heart Rate Service structure.
+ * @param[in]   rr_interval  New RR Interval measurement (will be buffered until the next
+ *                           transmission of Heart Rate Measurement).
+ */
+void ble_hrs_rr_interval_add(ble_hrs_t * p_hrs, uint16_t rr_interval);
+
+/**@brief Function for checking if RR Interval buffer is full.
+ *
+ * @param[in]   p_hrs        Heart Rate Service structure.
+ *
+ * @return      true if RR Interval buffer is full, false otherwise.
+ */
+bool ble_hrs_rr_interval_buffer_is_full(ble_hrs_t * p_hrs);
+
+/**@brief Function for setting the state of the Sensor Contact Supported bit.
+ *
+ * @param[in]   p_hrs                        Heart Rate Service structure.
+ * @param[in]   is_sensor_contact_supported  New state of the Sensor Contact Supported bit.
+ *
+ * @return      NRF_SUCCESS on success, otherwise an error code.
+ */
+uint32_t ble_hrs_sensor_contact_supported_set(ble_hrs_t * p_hrs, bool is_sensor_contact_supported);
+
+/**@brief Function for setting the state of the Sensor Contact Detected bit.
+ *
+ * @param[in]   p_hrs                        Heart Rate Service structure.
+ * @param[in]   is_sensor_contact_detected   TRUE if sensor contact is detected, FALSE otherwise.
+ */
+void ble_hrs_sensor_contact_detected_update(ble_hrs_t * p_hrs, bool is_sensor_contact_detected);
+
+/**@brief Function for setting the Body Sensor Location.
+ *
+ * @details Sets a new value of the Body Sensor Location characteristic. The new value will be sent
+ *          to the client the next time the client reads the Body Sensor Location characteristic.
+ *
+ * @param[in]   p_hrs                 Heart Rate Service structure.
+ * @param[in]   body_sensor_location  New Body Sensor Location.
+ *
+ * @return      NRF_SUCCESS on success, otherwise an error code.
+ */
+uint32_t ble_hrs_body_sensor_location_set(ble_hrs_t * p_hrs, uint8_t body_sensor_location);
+
+#endif // BLE_HRS_H__
+
+/** @} */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nordic/nrf-sdk/ble/ble_services/ble_hts.h	Mon Jul 07 13:43:31 2014 +0100
@@ -0,0 +1,160 @@
+/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ */
+
+/** @file
+ *
+ * @defgroup ble_sdk_srv_hts Health Thermometer Service
+ * @{
+ * @ingroup ble_sdk_srv
+ * @brief Health Thermometer Service module.
+ *
+ * @details This module implements the Health Thermometer Service.
+ *
+ *          If an event handler is supplied by the application, the Health Thermometer 
+ *          Service will generate Health Thermometer Service events to the application.
+ *
+ * @note The application must propagate BLE stack events to the Health Thermometer Service
+ *       module by calling ble_hts_on_ble_evt() from the from the @ref ble_stack_handler function.
+ *
+ * @note Attention! 
+ *  To maintain compliance with Nordic Semiconductor ASA Bluetooth profile 
+ *  qualification listings, this section of source code must not be modified.
+ */
+
+#ifndef BLE_HTS_H__
+#define BLE_HTS_H__
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "ble.h"
+#include "ble_srv_common.h"
+#include "ble_date_time.h"
+
+// Temperature Type measurement locations
+#define BLE_HTS_TEMP_TYPE_ARMPIT      1
+#define BLE_HTS_TEMP_TYPE_BODY        2
+#define BLE_HTS_TEMP_TYPE_EAR         3
+#define BLE_HTS_TEMP_TYPE_FINGER      4
+#define BLE_HTS_TEMP_TYPE_GI_TRACT    5
+#define BLE_HTS_TEMP_TYPE_MOUTH       6
+#define BLE_HTS_TEMP_TYPE_RECTUM      7
+#define BLE_HTS_TEMP_TYPE_TOE         8
+#define BLE_HTS_TEMP_TYPE_EAR_DRUM    9
+
+/**@brief Health Thermometer Service event type. */
+typedef enum
+{
+    BLE_HTS_EVT_INDICATION_ENABLED,                                         /**< Health Thermometer value indication enabled event. */
+    BLE_HTS_EVT_INDICATION_DISABLED,                                        /**< Health Thermometer value indication disabled event. */
+    BLE_HTS_EVT_INDICATION_CONFIRMED                                        /**< Confirmation of a temperature measurement indication has been received. */
+} ble_hts_evt_type_t;
+
+/**@brief Health Thermometer Service event. */
+typedef struct
+{
+    ble_hts_evt_type_t evt_type;                                            /**< Type of event. */
+} ble_hts_evt_t;
+
+// Forward declaration of the ble_hts_t type. 
+typedef struct ble_hts_s ble_hts_t;
+
+/**@brief Health Thermometer Service event handler type. */
+typedef void (*ble_hts_evt_handler_t) (ble_hts_t * p_hts, ble_hts_evt_t * p_evt);
+
+/**@brief FLOAT format (IEEE-11073 32-bit FLOAT, defined as a 32-bit value with a 24-bit mantissa
+ *        and an 8-bit exponent. */
+typedef struct
+{
+  int8_t  exponent;                                                         /**< Base 10 exponent */
+  int32_t mantissa;                                                         /**< Mantissa, should be using only 24 bits */
+} ieee_float32_t;
+
+/**@brief Health Thermometer Service init structure. This contains all options and data
+ *        needed for initialization of the service. */
+typedef struct
+{
+    ble_hts_evt_handler_t        evt_handler;                               /**< Event handler to be called for handling events in the Health Thermometer Service. */
+    ble_srv_cccd_security_mode_t hts_meas_attr_md;                          /**< Initial security level for health thermometer measurement attribute */
+    ble_srv_security_mode_t      hts_temp_type_attr_md;                     /**< Initial security level for health thermometer tempearture type attribute */
+    uint8_t                      temp_type_as_characteristic;               /**< Set non-zero if temp type given as characteristic */
+    uint8_t                      temp_type;                                 /**< Temperature type if temperature characteristic is used */
+} ble_hts_init_t;
+
+/**@brief Health Thermometer Service structure. This contains various status information for
+ *        the service. */
+typedef struct ble_hts_s
+{
+    ble_hts_evt_handler_t        evt_handler;                               /**< Event handler to be called for handling events in the Health Thermometer Service. */
+    uint16_t                     service_handle;                            /**< Handle of Health Thermometer Service (as provided by the BLE stack). */
+    ble_gatts_char_handles_t     meas_handles;                              /**< Handles related to the Health Thermometer Measurement characteristic. */
+    ble_gatts_char_handles_t     temp_type_handles;                         /**< Handles related to the Health Thermometer Temperature Type characteristic. */
+    uint16_t                     conn_handle;                               /**< Handle of the current connection (as provided by the BLE stack, is BLE_CONN_HANDLE_INVALID if not in a connection). */
+    uint8_t                      temp_type;                                 /**< Temperature type indicates where the measurement was taken. */
+} ble_hts_t;
+
+/**@brief Health Thermometer Service measurement structure. This contains a Health Thermometer
+ *        measurement. */
+typedef struct ble_hts_meas_s
+{
+    bool                         temp_in_fahr_units;                        /**< True if Temperature is in Fahrenheit units, Celcius otherwise. */
+    bool                         time_stamp_present;                        /**< True if Time Stamp is present. */
+    bool                         temp_type_present;                         /**< True if Temperature Type is present. */
+    ieee_float32_t               temp_in_celcius;                           /**< Temperature Measurement Value (Celcius). */
+    ieee_float32_t               temp_in_fahr;                              /**< Temperature Measurement Value (Fahrenheit). */
+    ble_date_time_t              time_stamp;                                /**< Time Stamp. */
+    uint8_t                      temp_type;                                 /**< Temperature Type. */
+} ble_hts_meas_t;
+
+/**@brief Function for initializing the Health Thermometer Service.
+ *
+ * @param[out]  p_hts       Health Thermometer Service structure. This structure will have to
+ *                          be supplied by the application. It will be initialized by this function,
+ *                          and will later be used to identify this particular service instance.
+ * @param[in]   p_hts_init  Information needed to initialize the service.
+ *
+ * @return      NRF_SUCCESS on successful initialization of service, otherwise an error code.
+ */
+uint32_t ble_hts_init(ble_hts_t * p_hts, const ble_hts_init_t * p_hts_init);
+
+/**@brief Function for handling the Application's BLE Stack events.
+ *
+ * @details Handles all events from the BLE stack of interest to the Health Thermometer Service.
+ *
+ * @param[in]   p_hts      Health Thermometer Service structure.
+ * @param[in]   p_ble_evt  Event received from the BLE stack.
+ */
+void ble_hts_on_ble_evt(ble_hts_t * p_hts, ble_evt_t * p_ble_evt);
+
+/**@brief Function for sending health thermometer measurement if indication has been enabled.
+ *
+ * @details The application calls this function after having performed a Health Thermometer
+ *          measurement. If indication has been enabled, the measurement data is encoded and
+ *          sent to the client.
+ *
+ * @param[in]   p_hts       Health Thermometer Service structure.
+ * @param[in]   p_hts_meas  Pointer to new health thermometer measurement.
+ *
+ * @return      NRF_SUCCESS on success, otherwise an error code.
+ */
+uint32_t ble_hts_measurement_send(ble_hts_t * p_hts, ble_hts_meas_t * p_hts_meas);
+
+/**@brief Function for checking if indication of Temperature Measurement is currently enabled.
+ *
+ * @param[in]   p_hts                  Health Thermometer Service structure.
+ * @param[out]  p_indication_enabled   TRUE if indication is enabled, FALSE otherwise.
+ *
+ * @return      NRF_SUCCESS on success, otherwise an error code.
+ */
+uint32_t ble_hts_is_indication_enabled(ble_hts_t * p_hts, bool * p_indication_enabled);
+
+#endif // BLE_HTS_H__
+
+/** @} */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nordic/nrf-sdk/ble/ble_services/ble_ias.h	Mon Jul 07 13:43:31 2014 +0100
@@ -0,0 +1,112 @@
+/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ *
+ */
+
+/** @file
+ *
+ * @defgroup ble_sdk_srv_ias Immediate Alert Service
+ * @{
+ * @ingroup ble_sdk_srv
+ * @brief Immediate Alert Service module.
+ *
+ * @details This module implements the Immediate Alert Service with the Alert Level characteristic.
+ *          During initialization it adds the Immediate Alert Service and Alert Level characteristic
+ *          to the BLE stack database.
+ *
+ *          The application must supply an event handler for receiving Immediate Alert Service 
+ *          events. Using this handler, the service will notify the application when the 
+ *          Alert Level characteristic value changes.
+ *
+ *          The service also provides a function for letting the application poll the current
+ *          value of the Alert Level characteristic.
+ *
+ * @note The application must propagate BLE stack events to the Immediate Alert Service
+ *       module by calling ble_ias_on_ble_evt() from the @ref ble_stack_handler callback.
+ *
+ * @note Attention! 
+ *  To maintain compliance with Nordic Semiconductor ASA Bluetooth profile 
+ *  qualification listings, this section of source code must not be modified.
+*/
+
+#ifndef BLE_IAS_H__
+#define BLE_IAS_H__
+
+#include <stdint.h>
+#include "ble.h"
+
+/**@brief Immediate Alert Service event type. */
+typedef enum
+{
+    BLE_IAS_EVT_ALERT_LEVEL_UPDATED                     /**< Alert Level Updated event. */
+} ble_ias_evt_type_t;
+
+/**@brief Immediate Alert Service event. */
+typedef struct
+{
+    ble_ias_evt_type_t evt_type;                        /**< Type of event. */
+    union
+    {
+        uint8_t alert_level;                            /**< New Alert Level value. */
+    } params;
+} ble_ias_evt_t;
+
+// Forward declaration of the ble_ias_t type. 
+typedef struct ble_ias_s ble_ias_t;
+
+/**@brief Immediate Alert Service event handler type. */
+typedef void (*ble_ias_evt_handler_t) (ble_ias_t * p_ias, ble_ias_evt_t * p_evt);
+
+/**@brief Immediate Alert Service init structure. This contains all options and data needed for
+ *        initialization of the service. */
+typedef struct
+{
+    ble_ias_evt_handler_t evt_handler;                  /**< Event handler to be called for handling events in the Immediate Alert Service. */
+} ble_ias_init_t;
+
+/**@brief Immediate Alert Service structure. This contains various status information for the
+ *        service. */
+typedef struct ble_ias_s
+{
+    ble_ias_evt_handler_t     evt_handler;              /**< Event handler to be called for handling events in the Immediate Alert Service. */
+    uint16_t                  service_handle;           /**< Handle of Immediate Alert Service (as provided by the BLE stack). */
+    ble_gatts_char_handles_t  alert_level_handles;      /**< Handles related to the Alert Level characteristic. */
+} ble_ias_t;
+
+/**@brief Function for initializing the Immediate Alert Service.
+ *
+ * @param[out]  p_ias       Immediate Alert Service structure. This structure will have to be
+ *                          supplied by the application. It will be initialized by this function,
+ *                          and will later be used to identify this particular service instance.
+ * @param[in]   p_ias_init  Information needed to initialize the service.
+ *
+ * @return      NRF_SUCCESS on successful initialization of service, otherwise an error code.
+ */
+uint32_t ble_ias_init(ble_ias_t * p_ias, const ble_ias_init_t * p_ias_init);
+
+/**@brief Function for handling the Application's BLE Stack events.
+ *
+ * @details Handles all events from the BLE stack of interest to the Immediate Alert Service.
+ *
+ * @param[in]   p_ias      Immediate Alert Service structure.
+ * @param[in]   p_ble_evt  Event received from the BLE stack.
+ */
+void ble_ias_on_ble_evt(ble_ias_t * p_ias, ble_evt_t * p_ble_evt);
+
+/**@brief Function for getting current value of the Alert Level characteristic.
+ *
+ * @param[in]   p_ias          Immediate Alert Service structure.
+ * @param[out]  p_alert_level  Current Alert Level value.
+ */
+uint32_t ble_ias_alert_level_get(ble_ias_t * p_ias, uint8_t * p_alert_level);
+
+#endif // BLE_IAS_H__
+
+/** @} */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nordic/nrf-sdk/ble/ble_services/ble_ias_c.h	Mon Jul 07 13:43:31 2014 +0100
@@ -0,0 +1,119 @@
+/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ *
+ */
+
+/** @file
+ *
+ * @defgroup ble_sdk_srv_ias_c Immediate Alert Service Client
+ * @{
+ * @ingroup ble_sdk_srv
+ * @brief Immediate Alert Service Client module
+ *
+ * @details This module implements the Immediate Alert Service client - locator role of the Find Me
+ *          profile. On @ref BLE_GAP_EVT_CONNECTED event, this module starts discovery of the
+ *          Immediate Alert Service with Alert Level characteristic at the peer. This module will
+ *          indicate the application about a successful service & characteristic discovery using
+ *          @ref BLE_IAS_C_EVT_CHAR_DISCOVERED event. The application can use @ref
+ *          ble_ias_c_send_alert_level function to signal alerts to the peer.
+ *
+ * @note The application must propagate BLE stack events to this module by calling
+ *       ble_ias_c_on_ble_evt() from the from the @ref ble_stack_handler callback function.
+ */
+
+#ifndef BLE_IAS_C_H__
+#define BLE_IAS_C_H__
+
+#include "ble_srv_common.h"
+#include "ble_gattc.h"
+#include "ble.h"
+#include <stdint.h>
+
+// Forward declaration of the ble_ias_c_t type.
+typedef struct ble_ias_c_s ble_ias_c_t;
+
+/**@brief Immediate Alert Service client event type. */
+typedef enum
+{
+    BLE_IAS_C_EVT_SRV_DISCOVERED,                       /**< Event indicating that the Immediate Alert Service is found at the peer. */
+    BLE_IAS_C_EVT_SRV_NOT_FOUND,                        /**< Event indicating that the Immediate Alert Service is not found at the peer. */
+    BLE_IAS_C_EVT_DISCONN_COMPLETE                      /**< Event indicating that the Immediate Alert Service client module has completed the processing of BLE_GAP_EVT_DISCONNECTED event. This event is raised only if a valid instance of IAS was found at the peer during the discovery phase. This event can be used the application to do clean up related to the IAS Client.*/
+} ble_ias_c_evt_type_t;
+
+/**@brief Immediate Alert Service client event. */
+typedef struct
+{
+    ble_ias_c_evt_type_t evt_type;                      /**< Type of event. */
+} ble_ias_c_evt_t;
+
+/**@brief Immediate Alert Service client event handler type. */
+typedef void (*ble_ias_c_evt_handler_t) (ble_ias_c_t * p_ias_c, ble_ias_c_evt_t * p_evt);
+
+/**@brief IAS Client structure. This contains various status information for the client. */
+typedef struct ble_ias_c_s
+{
+    ble_ias_c_evt_handler_t   evt_handler;              /**< Event handler to be called for handling events in the Immediate Alert Service client. */
+    ble_srv_error_handler_t   error_handler;            /**< Function to be called in case of an error. */
+    uint16_t                  alert_level_handle;       /**< Handle of Alert Level characteristic at peer (as provided by the BLE stack). */
+    uint16_t                  conn_handle;              /**< Handle of the current connection (as provided by the BLE stack, is BLE_CONN_HANDLE_INVALID if not in a connection). */
+} ble_ias_c_t;
+
+/**@brief IAS Client init structure. This contains all options and data needed for initialization of
+ *        the client.*/
+typedef struct
+{
+    ble_ias_c_evt_handler_t   evt_handler;              /**< Event handler to be called for handling events from the Immediate Alert Service client. */
+    ble_srv_error_handler_t   error_handler;            /**< Function to be called in case of an error. */
+} ble_ias_c_init_t;
+
+/**@brief Function for initializing the Immediate Alert Service client.
+ *
+ * @details This call allows the application to initialize the Immediate Alert Service client.
+ *
+ * @param[out]  p_ias_c      Immediate Alert Service client structure. This structure will have to
+ *                           be supplied by the application. It will be initialized by this
+ *                           function, and will later be used to identify this particular client
+ *                           instance.
+ * @param[in]   p_ias_c_init Information needed to initialize the Immediate Alert Service client.
+ *
+ * @return      NRF_SUCCESS on successful initialization of service.
+ */
+uint32_t ble_ias_c_init(ble_ias_c_t * p_ias_c, const ble_ias_c_init_t * p_ias_c_init);
+
+/**@brief Function for sending alert level to the peer.
+ *
+ * @details This function allows the application to send an alert to the peer.
+ *
+ * @param[in]   p_ias_c      Immediate Alert Service client structure.
+ * @param[in]   alert_level  Required alert level to be sent to the peer.
+ *
+ * @return      NRF_SUCCESS on success, otherwise an error code.
+ */
+uint32_t ble_ias_c_send_alert_level(const ble_ias_c_t * p_ias_c, uint8_t alert_level);
+
+/**@brief Function for handling the Application's BLE Stack events for Immediate Alert Service client.
+ *
+ * @details Handles all events from the BLE stack of interest to the Immediate Alert Service client.
+ *
+ * @param[in]   p_ias_c      Immediate Alert Service client structure.
+ * @param[in]   p_ble_evt    Event received from the BLE stack.
+ */
+void ble_ias_c_on_ble_evt(ble_ias_c_t * p_ias_c, const ble_evt_t * p_ble_evt);
+
+/**@brief Function for checking whether the peer's Immediate Alert Service instance and the alert level
+ *        characteristic have been discovered.
+ * @param[in]  p_ias_c      Immediate Alert Service client structure.
+ */
+static __INLINE bool ble_ias_c_is_ias_discovered(const ble_ias_c_t * p_ias_c)
+{
+    return (p_ias_c->alert_level_handle != BLE_GATT_HANDLE_INVALID);
+}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nordic/nrf-sdk/ble/ble_services/ble_lls.h	Mon Jul 07 13:43:31 2014 +0100
@@ -0,0 +1,115 @@
+/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ *
+ */
+
+/** @file
+ *
+ * @defgroup ble_sdk_srv_lls Link Loss Service
+ * @{
+ * @ingroup ble_sdk_srv
+ * @brief Link Loss Service module.
+ *
+ * @details This module implements the Link Loss Service with the Alert Level characteristic.
+ *          During initialization it adds the Link Loss Service and Alert Level characteristic
+ *          to the BLE stack database.
+ *
+ *          The application must supply an event handler for receiving Link Loss Service 
+ *          events. Using this handler, the service will notify the application when the 
+ *          link has been lost, and which Alert Level has been set.
+ *
+ *          The service also provides a function for letting the application poll the current
+ *          value of the Alert Level characteristic.
+ *
+ * @note The application must propagate BLE stack events to the Link Loss Service
+ *       module by calling ble_lls_on_ble_evt() from the @ref ble_stack_handler callback.
+ *
+ * @note Attention! 
+ *  To maintain compliance with Nordic Semiconductor ASA Bluetooth profile 
+ *  qualification listings, this section of source code must not be modified.
+*/
+
+#ifndef BLE_LLS_H__
+#define BLE_LLS_H__
+
+#include <stdint.h>
+#include "ble.h"
+#include "ble_srv_common.h"
+
+/**@brief Link Loss Service event type. */
+typedef enum
+{
+    BLE_LLS_EVT_LINK_LOSS_ALERT                         /**< Alert Level Updated event. */
+} ble_lls_evt_type_t;
+
+/**@brief Link Loss Service event. */
+typedef struct
+{
+    ble_lls_evt_type_t evt_type;                        /**< Type of event. */
+    union
+    {
+        uint8_t alert_level;                            /**< New Alert Level value. */
+    } params;
+} ble_lls_evt_t;
+
+// Forward declaration of the ble_lls_t type.
+typedef struct ble_lls_s ble_lls_t;
+
+/**@brief Link Loss Service event handler type. */
+typedef void (*ble_lls_evt_handler_t) (ble_lls_t * p_lls, ble_lls_evt_t * p_evt);
+
+/**@brief Link Loss Service init structure. This contains all options and data needed for initialization of the service. */
+typedef struct
+{
+    ble_lls_evt_handler_t     evt_handler;              /**< Event handler to be called for handling events in the Link Loss Service. */
+    ble_srv_error_handler_t   error_handler;            /**< Function to be called in case of an error. */
+    uint8_t                   initial_alert_level;      /**< Initial value of the Alert Level characteristic. */
+    ble_srv_security_mode_t   lls_attr_md;              /**< Initial Security Setting for Link Loss Service Characteristics. */
+} ble_lls_init_t;
+
+/**@brief Link Loss Service structure. This contains various status information for the service. */
+typedef struct ble_lls_s
+{
+    ble_lls_evt_handler_t     evt_handler;              /**< Event handler to be called for handling events in the Link Loss Service. */
+    ble_srv_error_handler_t   error_handler;            /**< Function to be called in case of an error. */
+    uint16_t                  service_handle;           /**< Handle of Link Loss Service (as provided by the BLE stack). */
+    ble_gatts_char_handles_t  alert_level_handles;      /**< Handles related to the Alert Level characteristic. */
+} ble_lls_t;
+
+/**@brief Function for initializing the Link Loss Service.
+ *
+ * @param[out]  p_lls       Link Loss Service structure. This structure will have to be supplied by
+ *                          the application. It will be initialized by this function, and will later
+ *                          be used to identify this particular service instance.
+ * @param[in]   p_lls_init  Information needed to initialize the service.
+ *
+ * @return      NRF_SUCCESS on successful initialization of service, otherwise an error code.
+ */
+uint32_t ble_lls_init(ble_lls_t * p_lls, const ble_lls_init_t * p_lls_init);
+
+/**@brief Function for handling the Application's BLE Stack events.
+ *
+ * @details Handles all events from the BLE stack of interest to the Link Loss Service.
+ *
+ * @param[in]   p_lls      Link Loss Service structure.
+ * @param[in]   p_ble_evt  Event received from the BLE stack.
+ */
+void ble_lls_on_ble_evt(ble_lls_t * p_lls, ble_evt_t * p_ble_evt);
+
+/**@brief Function for getting current value of the Alert Level characteristic.
+ *
+ * @param[in]   p_lls          Link Loss Service structure.
+ * @param[out]  p_alert_level  Current Alert Level value.
+ */
+uint32_t ble_lls_alert_level_get(ble_lls_t * p_lls, uint8_t * p_alert_level);
+
+#endif // BLE_LLS_H__
+
+/** @} */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nordic/nrf-sdk/ble/ble_services/ble_rscs.h	Mon Jul 07 13:43:31 2014 +0100
@@ -0,0 +1,140 @@
+/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ *
+ */
+
+/** @file
+ *
+ * @defgroup ble_sdk_srv_rsc Running Speed and Cadence Service
+ * @{
+ * @ingroup ble_sdk_srv
+ * @brief Running Speed and Cadence Service module.
+ *
+ * @details This module implements the Running Speed and Cadence Service. If enabled, notification
+ *          of the Running Speead and Candence Measurement is performed when the application
+ *          calls ble_rscs_measurement_send().
+ *
+ *          If an event handler is supplied by the application, the Running Speed and Cadence
+ *          Service will generate Running Speed and Cadence Service events to the application.
+ *
+ * @note The application must propagate BLE stack events to the Running Speead and Candence Service
+ *       module by calling ble_rscs_on_ble_evt() from the from the @ref ble_stack_handler function.
+ *
+ * @note Attention! 
+ *  To maintain compliance with Nordic Semiconductor ASA Bluetooth profile 
+ *  qualification listings, this section of source code must not be modified.
+ */
+
+#ifndef BLE_RSCS_H__
+#define BLE_RSCS_H__
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "ble.h"
+#include "ble_srv_common.h"
+
+/**@brief Running Speed and Cadence Service feature bits. */
+#define BLE_RSCS_FEATURE_INSTANT_STRIDE_LEN_BIT             (0x01 << 0)     /**< Instantaneous Stride Length Measurement Supported bit. */
+#define BLE_RSCS_FEATURE_TOTAL_DISTANCE_BIT                 (0x01 << 1)     /**< Total Distance Measurement Supported bit. */
+#define BLE_RSCS_FEATURE_WALKING_OR_RUNNING_STATUS_BIT      (0x01 << 2)     /**< Walking or Running Status Supported bit. */
+#define BLE_RSCS_FEATURE_CALIBRATION_PROCEDURE_BIT          (0x01 << 3)     /**< Calibration Procedure Supported bit. */
+#define BLE_RSCS_FEATURE_MULTIPLE_SENSORS_BIT               (0x01 << 4)     /**< Multiple Sensor Locations Supported bit. */
+
+/**@brief Running Speed and Cadence Service event type. */
+typedef enum
+{
+    BLE_RSCS_EVT_NOTIFICATION_ENABLED,                                      /**< Running Speed and Cadence value notification enabled event. */
+    BLE_RSCS_EVT_NOTIFICATION_DISABLED                                      /**< Running Speed and Cadence value notification disabled event. */
+} ble_rscs_evt_type_t;
+
+/**@brief Running Speed and Cadence Service event. */
+typedef struct
+{
+    ble_rscs_evt_type_t evt_type;                                           /**< Type of event. */
+} ble_rscs_evt_t;
+
+// Forward declaration of the ble_rsc_t type. 
+typedef struct ble_rscs_s ble_rscs_t;
+
+/**@brief Running Speed and Cadence Service event handler type. */
+typedef void (*ble_rscs_evt_handler_t) (ble_rscs_t * p_rscs, ble_rscs_evt_t * p_evt);
+
+/**@brief Running Speed and Cadence Service init structure. This contains all options and data
+ *        needed for initialization of the service. */
+typedef struct
+{
+    ble_rscs_evt_handler_t       evt_handler;                               /**< Event handler to be called for handling events in the Running Speed and Cadence Service. */
+    ble_srv_cccd_security_mode_t rsc_meas_attr_md;                          /**< Initial security level for running speed and cadence measurement attribute */
+    ble_srv_security_mode_t      rsc_feature_attr_md;                       /**< Initial security level for feature attribute */
+    uint16_t                     feature;                                   /**< Initial value for features of sensor. */
+} ble_rscs_init_t;
+
+/**@brief Running Speed and Cadence Service structure. This contains various status information for
+ *        the service. */
+typedef struct ble_rscs_s
+{
+    ble_rscs_evt_handler_t       evt_handler;                               /**< Event handler to be called for handling events in the Running Speed and Cadence Service. */
+    uint16_t                     service_handle;                            /**< Handle of Running Speed and Cadence Service (as provided by the BLE stack). */
+    ble_gatts_char_handles_t     meas_handles;                              /**< Handles related to the Running Speed and Cadence Measurement characteristic. */
+    ble_gatts_char_handles_t     feature_handles;                           /**< Handles related to the Running Speed and Cadence feature characteristic. */
+    uint16_t                     conn_handle;                               /**< Handle of the current connection (as provided by the BLE stack, is BLE_CONN_HANDLE_INVALID if not in a connection). */
+    uint16_t                     feature;                                   /**< Bit mask of features available on sensor. */
+} ble_rscs_t;
+
+/**@brief Running Speed and Cadence Service measurement structure. This contains a Running Speed and
+ *        Cadence measurement. */
+typedef struct ble_rscs_meas_s
+{
+    bool        is_inst_stride_len_present;                                 /**< True if Instantaneous Stride Length is present in the measurement. */
+    bool        is_total_distance_present;                                  /**< True if Total Distance is present in the measurement. */
+    bool        is_running;                                                 /**< True if running, False if walking. */
+    uint16_t    inst_speed;                                                 /**< Instantaneous Speed. */
+    uint8_t     inst_cadence;                                               /**< Instantaneous Cadence. */
+    uint16_t    inst_stride_length;                                         /**< Instantaneous Stride Length. */
+    uint32_t    total_distance;                                             /**< Total Distance. */
+} ble_rscs_meas_t;
+
+/**@brief Function for initializing the Running Speed and Cadence Service.
+ *
+ * @param[out]  p_rscs      Running Speed and Cadence Service structure. This structure will have to
+ *                          be supplied by the application. It will be initialized by this function,
+ *                          and will later be used to identify this particular service instance.
+ * @param[in]   p_rscs_init Information needed to initialize the service.
+ *
+ * @return      NRF_SUCCESS on successful initialization of service, otherwise an error code.
+ */
+uint32_t ble_rscs_init(ble_rscs_t * p_rscs, const ble_rscs_init_t * p_rscs_init);
+
+/**@brief Function for handling the Application's BLE Stack events.
+ *
+ * @details Handles all events from the BLE stack of interest to the Running Speed and Cadence
+ *          Service.
+ *
+ * @param[in]   p_rscs     Running Speed and Cadence Service structure.
+ * @param[in]   p_ble_evt  Event received from the BLE stack.
+ */
+void ble_rscs_on_ble_evt(ble_rscs_t * p_rscs, ble_evt_t * p_ble_evt);
+
+/**@brief Function for sending running speed and cadence measurement if notification has been enabled.
+ *
+ * @details The application calls this function after having performed a Running Speed and Cadence
+ *          measurement. If notification has been enabled, the measurement data is encoded and sent
+ *          to the client.
+ *
+ * @param[in]   p_rscs         Running Speed and Cadence Service structure.
+ * @param[in]   p_measurement  Pointer to new running speed and cadence measurement.
+ *
+ * @return      NRF_SUCCESS on success, otherwise an error code.
+ */
+uint32_t ble_rscs_measurement_send(ble_rscs_t * p_rscs, ble_rscs_meas_t * p_measurement);
+
+#endif // BLE_RSCS_H__
+
+/** @} */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nordic/nrf-sdk/ble/ble_services/ble_sc_ctrlpt.h	Mon Jul 07 13:43:31 2014 +0100
@@ -0,0 +1,206 @@
+/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ *
+ */
+
+/** @file
+ *
+ * @defgroup ble_sdk_srv_sc_ctrlpt Speed and Cadence Control Point
+ * @{
+ * @ingroup ble_sdk_srv
+ * @brief Speed and Cadence Control Point module.
+ *
+ * @details This module implements the Speed and Cadence control point behavior. It is used
+ *          by the @ref ble_sdk_srv_csc module and the ble_sdk_srv_rsc module for control point
+ *          mechanisms like setting a cumulative value, Start an automatic calibration,
+ *          Update the sensor location or request the supported locations.
+ *
+ * @note Attention! 
+ *  To maintain compliance with Nordic Semiconductor ASA Bluetooth profile 
+ *  qualification listings, this section of source code must not be modified.
+ */
+
+#ifndef BLE_SC_CTRLPT_H__
+#define BLE_SC_CTRLPT_H__
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "ble.h"
+#include "ble_srv_common.h"
+#include "ble_sensor_location.h"
+
+#define BLE_SC_CTRLPT_MAX_LEN                                      19                     /**< maximum lenght for Speed and cadence control point characteristic value. */
+#define BLE_SC_CTRLPT_MIN_LEN                                      1                      /**< minimum length for Speed and cadence control point characteristic value. */
+
+// Forward declaration of the ble_sc_ctrlpt_t type.
+typedef struct ble_sc_ctrlpt_s ble_sc_ctrlpt_t;
+
+
+/**@brief Speed and Cadence Control Point event type. */
+typedef enum
+{
+    BLE_SC_CTRLPT_EVT_UPDATE_LOCATION,                                                    /**< rcvd update location opcode (the control point handles the change of location automatically, the event just informs the application in case it needs to adjust its algorithm). */
+    BLE_SC_CTRLPT_EVT_SET_CUMUL_VALUE,                                                    /**< rcvd set cumulative value opcode, it is then up to the application to use the new cumulative value. */
+    BLE_SC_CTRLPT_EVT_START_CALIBRATION,                                                  /**< rcvd start calibration opcode, the application needs, at the end ot the calibration to call ble_sc_ctrlpt_send_rsp. */
+} ble_sc_ctrlpt_evt_type_t;
+
+
+/**@brief Speed and Cadence Control point event. */
+typedef struct
+{
+    ble_sc_ctrlpt_evt_type_t evt_type;                                                    /**< Type of event. */
+    union
+    {
+        ble_sensor_location_t update_location;
+        uint32_t              cumulative_value;
+    }params;
+} ble_sc_ctrlpt_evt_t;
+
+
+/** Speed and Cadence Control Point operator code  (see RSC service specification)*/
+typedef enum {
+    BLE_SCPT_SET_CUMULATIVE_VALUE                   = 0x01,                               /**< Operator to set a given cumulative value. */
+    BLE_SCPT_START_AUTOMATIC_CALIBRATION            = 0x02,                               /**< Operator to start automatic calibration. */
+    BLE_SCPT_UPDATE_SENSOR_LOCATION                 = 0x03,                               /**< Operator to update the sensor location. */
+    BLE_SCPT_REQUEST_SUPPORTED_SENSOR_LOCATIONS     = 0x04,                               /**< Operator to request the supported sensor locations. */
+    BLE_SCPT_RESPONSE_CODE                          = 0x10,                               /**< Response Code. */
+} ble_scpt_operator_t;
+
+
+/** Speed and Cadence Control Point response parameter  (see RSC service specification)*/
+typedef enum {
+    BLE_SCPT_SUCCESS                                = 0x01,                               /**< Sucess Response. */
+    BLE_SCPT_OP_CODE_NOT_SUPPORTED                  = 0x02,                               /**< Error Response received opcode not supported. */
+    BLE_SCPT_INVALID_PARAMETER                      = 0x03,                               /**< Error Response received parameter invalid. */
+    BLE_SCPT_OPERATION_FAILED                       = 0x04,                               /**< Error Response operation failed. */
+} ble_scpt_response_t;
+
+
+/** Speed and Cadence Control Point procedure status (indicates is a procedure is in progress or not and which procedure is in progress*/
+typedef enum {
+    BLE_SCPT_NO_PROC_IN_PROGRESS                    = 0x00,                               /**< No procedure in progress. */
+    BLE_SCPT_AUTOMATIC_CALIB_IN_PROGRESS            = 0x01,                               /**< Automatic Calibration is in progress. */
+    BLE_SCPT_INDICATION_PENDING                     = 0x02,                               /**< Control Point Indication is pending. */
+    BLE_SCPT_IND_CONFIRM_PENDING                    = 0x03,                               /**< Waiting for the indication confirmation. */
+}ble_scpt_procedure_status_t;
+
+/**@brief Speed and Cadence Control point event handler type. */
+typedef ble_scpt_response_t (*ble_sc_ctrlpt_evt_handler_t) (ble_sc_ctrlpt_t * p_sc_ctrlpt,
+                                             ble_sc_ctrlpt_evt_t * p_evt);
+
+
+typedef struct{
+    ble_scpt_operator_t   opcode;
+    uint32_t              cumulative_value;
+    ble_sensor_location_t location;
+}ble_sc_ctrlpt_val_t;
+
+
+typedef struct{
+    ble_scpt_operator_t   opcode;
+    ble_scpt_response_t   status;
+    ble_sensor_location_t location_list[BLE_NB_MAX_SENSOR_LOCATIONS];
+}ble_sc_ctrlpt_rsp_t;
+
+
+
+#define BLE_SRV_SC_CTRLPT_SENSOR_LOCATIONS_OP_SUPPORTED  0x01                             /**< Support for sensor location related operations */
+#define BLE_SRV_SC_CTRLPT_CUM_VAL_OP_SUPPORTED           0x02                             /**< Support for setting cumulative value related operations */
+#define BLE_SRV_SC_CTRLPT_START_CALIB_OP_SUPPORTED       0x04                             /**< Support for starting calibration related operations */
+
+
+/**@brief Speed and Cadence Control Point init structure. This contains all options and data
+*         needed for initialization of the Speed and Cadence Control Point module. */
+typedef struct
+{
+    ble_srv_cccd_security_mode_t sc_ctrlpt_attr_md;                                       /**< Initial security level for cycling speed and cadence control point attribute */
+    uint8_t                      supported_functions;                                     /**< supported control point functionnalities see @ref BLE_SRV_SC_CTRLPT_SUPP_FUNC. */
+    uint16_t                     service_handle;                                          /**< Handle of the parent service (as provided by the BLE stack). */
+    ble_sc_ctrlpt_evt_handler_t  evt_handler;                                             /**< event handler */
+    ble_sensor_location_t        *list_supported_locations;                               /**< list of supported sensor locations.*/
+    uint8_t                      size_list_supported_locations;                           /**< number of supported sensor locations in the list.*/
+    uint16_t                     sensor_location_handle;                                  /**< handle for the sensor location characteristic (if sensor_location related operation are supported).*/
+    ble_srv_error_handler_t      error_handler;                                           /**< Function to be called in case of an error. */
+} ble_cs_ctrlpt_init_t;
+
+
+/**@brief Speed and Cadence Control Point response indication structure. */
+typedef struct
+{
+    ble_scpt_response_t          status;                                                  /**< control point response status .*/
+    uint8_t                      len;                                                     /**< control point response length .*/
+    uint8_t                      encoded_ctrl_rsp[BLE_SC_CTRLPT_MAX_LEN];                 /**< control point encoded response.*/
+}ble_sc_ctrlpt_resp_t;
+
+
+/**@brief Speed and Cadence Control Point structure. This contains various status information for
+ *        the Speed and Cadence Control Point behavior. */
+typedef struct ble_sc_ctrlpt_s
+{
+    uint8_t                      supported_functions;                                     /**< supported control point functionnalities see @ref BLE_SRV_SC_CTRLPT_SUPP_FUNC. */
+    uint16_t                     service_handle;                                          /**< Handle of the parent service (as provided by the BLE stack). */
+    ble_gatts_char_handles_t     sc_ctrlpt_handles;                                       /**< Handles related to the Speed and Cadence Control Point characteristic. */
+    uint16_t                     conn_handle;                                             /**< Handle of the current connection (as provided by the BLE stack, is BLE_CONN_HANDLE_INVALID if not in a connection). */
+    ble_sensor_location_t        list_supported_locations[BLE_NB_MAX_SENSOR_LOCATIONS];   /**< list of supported sensor locations.*/
+    uint8_t                      size_list_supported_locations;                           /**< number of supported sensor locations in the list.*/
+    ble_sc_ctrlpt_evt_handler_t  evt_handler;                                             /**< Handle of the parent service (as provided by the BLE stack). */
+    uint16_t                     sensor_location_handle;                                  /**< handle for the sensor location characteristic (if sensor_location related operation are supported).*/
+    ble_scpt_procedure_status_t  procedure_status;                                        /**< status of possible procedure*/
+    ble_srv_error_handler_t      error_handler;                                           /**< Function to be called in case of an error. */
+    ble_sc_ctrlpt_resp_t         response;                                                /**< pending response data.*/
+} ble_sc_ctrlpt_t;
+
+#define SCPT_OPCODE_POS                   0                                               /**< Request opcode position. */
+#define SCPT_PARAMETER_POS                1                                               /**< Request parameter position. */
+
+#define SCPT_RESPONSE_REQUEST_OPCODE_POS  1                                               /**< Response position of requested opcode. */
+#define SCPT_RESPONSE_CODE_POS            2                                               /**< Response position of response code. */
+#define SCPT_RESPONSE_PARAMETER           3                                               /**< Response position of response parameter. */
+
+#define SCPT_MIN_RESPONSE_SIZE            3                                               /**< Minimum size for control point response. */
+#define SCPT_MAX_RESPONSE_SIZE  (SCPT_MIN_RESPONSE_SIZE + NB_MAX_SENSOR_LOCATIONS)        /**< Maximum size for control point response. */
+
+
+/**@brief Function for Initializing the Speed and Cadence Control Point.
+ *
+ * @details Function for Initializing the Speed and Cadence Control Point.
+ * @param[in]   p_sc_ctrlpt   Speed and Cadence Control Point structure.
+ * @param[in]   p_cscs_init   Information needed to initialize the control point behavior.
+ *
+ * @return      NRF_SUCCESS on successful initialization of service, otherwise an error code.
+ */
+uint32_t ble_sc_ctrlpt_init(ble_sc_ctrlpt_t *            p_sc_ctrlpt,
+                            const ble_cs_ctrlpt_init_t * p_sc_ctrlpt_init);
+
+
+/**@brief Function for sending a control point response.
+ *
+ * @details Function for sending a control point response when the control point received was
+ *          BLE_SCPT_START_AUTOMATIC_CALIBRATION. To be called after the calibration procedure is finished.
+ *
+ * @param[in]   p_sc_ctrlpt      Speed and Cadence Control Point structure.
+ * @param[in]   response_status  status to include in the control point response.
+ */
+uint32_t ble_sc_ctrlpt_rsp_send(ble_sc_ctrlpt_t * p_sc_ctrlpt, ble_scpt_response_t response_status);
+
+
+/**@brief Speed and Cadence Control Point BLE stack event handler.
+ *
+ * @details Handles all events from the BLE stack of interest to the Speed and Cadence Control Point.
+ *
+ * @param[in]   p_sc_ctrlpt   Speed and Cadence Control Point structure.
+ * @param[in]   p_ble_evt  Event received from the BLE stack.
+ */
+void ble_sc_ctrlpt_on_ble_evt(ble_sc_ctrlpt_t * p_sc_ctrlpt, ble_evt_t * p_ble_evt);
+
+
+#endif // BLE_SC_CTRLPT_H__
+
+/** @} */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nordic/nrf-sdk/ble/ble_services/ble_sensor_location.h	Mon Jul 07 13:43:31 2014 +0100
@@ -0,0 +1,40 @@
+/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ *
+ */
+
+ /* Attention!
+*  To maintain compliance with Nordic Semiconductor ASA’s Bluetooth profile
+*  qualification listings, this section of source code must not be modified.
+*/
+ 
+#ifndef BLE_SENSOR_LOCATION_H__
+#define BLE_SENSOR_LOCATION_H__
+
+typedef enum {
+    BLE_SENSOR_LOCATION_OTHER        = 0 ,  /**<-- Other        */
+    BLE_SENSOR_LOCATION_TOP_OF_SHOE  = 1 ,  /**<-- Top of shoe  */
+    BLE_SENSOR_LOCATION_IN_SHOE      = 2 ,  /**<-- In shoe      */
+    BLE_SENSOR_LOCATION_HIP          = 3 ,  /**<-- Hip          */
+    BLE_SENSOR_LOCATION_FRONT_WHEEL  = 4 ,  /**<-- Front Wheel  */
+    BLE_SENSOR_LOCATION_LEFT_CRANK   = 5 ,  /**<-- Left Crank   */
+    BLE_SENSOR_LOCATION_RIGHT_CRANK  = 6 ,  /**<-- Right Crank  */
+    BLE_SENSOR_LOCATION_LEFT_PEDAL   = 7 ,  /**<-- Left Pedal   */
+    BLE_SENSOR_LOCATION_RIGHT_PEDAL  = 8 ,  /**<-- Right Pedal  */
+    BLE_SENSOR_LOCATION_FRONT_HUB    = 9 ,  /**<-- Front Hub    */
+    BLE_SENSOR_LOCATION_REAR_DROPOUT = 10,  /**<-- Rear Dropout */
+    BLE_SENSOR_LOCATION_CHAINSTAY    = 11,  /**<-- Chainstay    */
+    BLE_SENSOR_LOCATION_REAR_WHEEL   = 12,  /**<-- Rear Wheel   */
+    BLE_SENSOR_LOCATION_REAR_HUB     = 13,  /**<-- Rear Hub     */
+}ble_sensor_location_t;
+
+#define BLE_NB_MAX_SENSOR_LOCATIONS 14
+
+#endif // BLE_SENSOR_LOCATION_H__
--- a/nordic/nrf-sdk/ble/ble_services/ble_srv_common.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/ble/ble_services/ble_srv_common.h	Mon Jul 07 13:43:31 2014 +0100
@@ -23,7 +23,6 @@
 
 #include <stdint.h>
 #include <stdbool.h>
-#include "nordic_global.h"
 #include "ble_types.h"
 #include "app_util.h"
 #include "ble_gap.h"
@@ -143,7 +142,7 @@
 
 /**@brief Type definition for error handler function which will be called in case of an error in
  *        a service or a service library module. */
-typedef void (*ble_srv_error_handler_t)(uint32_t nrf_error);
+typedef void (*ble_srv_error_handler_t) (uint32_t nrf_error);
 
 /**@brief Value of a Report Reference descriptor. 
  *
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nordic/nrf-sdk/ble/ble_services/ble_tps.h	Mon Jul 07 13:43:31 2014 +0100
@@ -0,0 +1,76 @@
+/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ *
+ */
+
+/** @file
+ *
+ * @defgroup ble_sdk_srv_tps TX Power Service
+ * @{
+ * @ingroup ble_sdk_srv
+ * @brief TX Power Service module.
+ *
+ * @details This module implements the TX Power Service with the TX Power Level characteristic.
+ *          During initialization it adds the TX Power Service and TX Power Level characteristic
+ *          with the specified initial value to the BLE stack database.
+ *
+ *          It provides a function for letting the application update the TX Power Level
+ *          characteristic.
+ *
+ * @note Attention! 
+ *  To maintain compliance with Nordic Semiconductor ASA Bluetooth profile 
+ *  qualification listings, this section of source code must not be modified.
+ */
+
+#ifndef BLE_TPS_H__
+#define BLE_TPS_H__
+
+#include <stdint.h>
+#include "ble.h"
+#include "ble_srv_common.h"
+
+/**@brief TX Power Service init structure. This contains all options and data needed for
+ *        initialization of the service. */
+typedef struct
+{
+    int8_t                    initial_tx_power_level;   /**< Initial value of the TX Power Level characteristic (in dBm). */
+    ble_srv_security_mode_t   tps_attr_md;              /**< Initial Security Setting for TX Power Service Characteristics. */
+} ble_tps_init_t;
+
+/**@brief TX Power Service structure. This contains various status information for the service. */
+typedef struct
+{
+    uint16_t                  service_handle;           /**< Handle of TX Power Service (as provided by the BLE stack). */
+    ble_gatts_char_handles_t  tx_power_level_handles;   /**< Handles related to the TX Power Level characteristic. */
+} ble_tps_t;
+
+/**@brief Function for initializing the TX Power Service.
+ *
+ * @param[out]  p_tps       TX Power Service structure. This structure will have to be supplied by
+ *                          the application. It will be initialized by this function, and will later
+ *                          be used to identify this particular service instance.
+ * @param[in]   p_tps_init  Information needed to initialize the service.
+ *
+ * @return      NRF_SUCCESS on successful initialization of service, otherwise an error code.
+ */
+uint32_t ble_tps_init(ble_tps_t * p_hrs, const ble_tps_init_t * p_tps_init);
+
+/**@brief Function for setting the state of the Sensor Contact Detected bit.
+ *
+ * @param[in]   p_tps            TX Power Service structure.
+ * @param[in]   tx_power_level   New TX Power Level (unit dBm, range -100 to 20).
+ *
+ * @return      NRF_SUCCESS on success, otherwise an error code.
+ */
+uint32_t ble_tps_tx_power_level_set(ble_tps_t * p_tps, int8_t tx_power_level);
+
+#endif // BLE_TPS_H__
+
+/** @} */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nordic/nrf-sdk/ble/device_manager/device_manager.h	Mon Jul 07 13:43:31 2014 +0100
@@ -0,0 +1,839 @@
+/* Copyright (C) 2013 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ *
+ */
+
+/**
+ * @file device_manager.h
+ *
+ * @defgroup device_manager Device Manager
+ * @ingroup ble_sdk_lib
+ * @{
+ * @brief Device Manager Application Interface Abstraction.
+ *
+ * @details The Device Manager module manages Active and Bonded Peers. Management of peer includes
+ *          book keeping of contextual information like the Security Keys, GATT
+ *          configuration and any application specific information.
+ *
+ *          Active Peers are devices which are connected, and may or may not be bonded.
+ *          Bonded Peers are devices which are bonded, and may or may not be Active (Connected).
+ *          Active Bonded Peer refers to a device which is connected and bonded.
+ *
+ *          Paired Devices refers to peer devices that are connected and have necessary context
+ *          establishment/exchange for the current connection session. On disconnect,
+ *          all contextual information is flushed. For example, SMP Information Exchanged during
+ *          pairing and GATT Configuration is not retained on disconnection.
+ *
+ *          Note that this module allows management of contextual information but 
+ *          does not provide an interface for connection management. Therefore, entering connectible
+ *          mode, connection establishment, or disconnection of a link with peer is not in scope
+ *          of this module.
+ *
+ *          For bonded peers, the contextual information is required to be retained on disconnection
+ *          and power cycling. Persistent storage of contextual information is handled by the
+ *          module. This module categorizes the contextual information into 3 categories:
+ *             - <b>Bonding Information</b>
+ *               Bond information is the information exchanged between local and peer device to
+ *               establish a bond. It also includes peer identification information,
+ *               like the peer address or the IRK or both. From here on this category of information
+ *               is referred to as Device Context.
+ *             - <b>Service/Protocol Information</b>
+ *               Service/Protocol information is the information retained for the peer to save on one-time
+ *               procedures like the GATT Service Discovery procedures and Service Configurations.
+ *               It allows devices to resume data exchange on subsequent reconnection without having
+ *               to perform initial set-up procedures each time. From here on this category is
+ *               referred to as Service Context.
+ *             - <b>Application Information</b>
+ *               Application information is the context that the application would like to associate with
+ *               each of the bonded device. For example, if the application chooses to rank its peers
+ *               in order to manage them better, the rank information could be treated as
+ *               Application Information. This storage space is provided to save the application from
+ *               maintaining a mapping table with each Device Instance and Application Information.
+ *               However, if the application have no use for this, it is possible to not
+ *               use or employ this at compile time. From here on this category of information is
+ *               referred to as Application Context.
+ */
+
+
+#ifndef DEVICE_MANAGER_H__
+#define DEVICE_MANAGER_H__
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "sdk_common.h"
+#include "ble.h"
+#include "ble_gap.h"
+#include "device_manager_cnfg.h"
+
+/**
+ * @defgroup dm_service_cntext_types Service/Protocol Types
+ *
+ * @brief Describes the possible types of Service/Protocol Contexts for a bonded/peer device.
+ *
+ * @details Possible Service/Protocol context per peer device. The Device Manager provides the
+ *          functionality of persistently storing the Service/Protocol context and can automatically
+ *          load them when needed.
+ *          For example system attributes for a GATT Server. Based on the nature of the application, 
+ *          not all service types may be needed. The application can specify
+ *          only the service/protocol context it wants to use at the time of registration.
+ * @{
+ */
+#define DM_PROTOCOL_CNTXT_NONE         0x00  /**< No Service Context, this implies the application does not want to associate any service/protocol context with the peer device */
+#define DM_PROTOCOL_CNTXT_GATT_SRVR_ID 0x01  /**< GATT Server Service Context, this implies the application does associate GATT Server with the peer device and this information will be loaded when needed for a bonded device */
+#define DM_PROTOCOL_CNTXT_GATT_CLI_ID  0x02  /**< GATT Client Service Context, this implies the application does associate GATT Client with the peer device and this information will be loaded when needed for a bonded device */
+#define DM_PROTOCOL_CNTXT_ALL                                                                     \
+        (DM_PROTOCOL_CNTXT_GATT_SRVR_ID | DM_PROTOCOL_CNTXT_GATT_CLI_ID) /**< All Service/Protocol Context, this implies that the application wants to associate all Service/Protocol Information with the bonded device. This is configurable based on system requirements. If the application has only one type of service, this define could be altered to reflect the same.  */
+/** @} */
+
+
+/**
+ * @defgroup dm_events Device Manager Events
+ *
+ * @brief This section describes the device manager events that are notified to the application.
+ *
+ * @details The Device Manager notifies the application of various asynchronous events using the
+ *          asynchronous event notification callback. All events has been categorized into:
+ *          a. General.
+ *          b. Link Status.
+ *          c. Context Management.
+ *
+ *          In the callback, these events are notified along with handle that uniquely identifies:
+ *          application instance, active instance (if applicable), device instance
+ *          bonding instance, (if applicable) and service instance.
+ *          Not all events are pertaining to an active connection, for example a context deletion event could occur even if the peer
+ *          is not connected. Also, general category of events may not be pertaining to any specific peer.
+ *          See also \ref dm_event_cb_t and \ref dm_register.
+ * @{
+ */
+/**
+ * @defgroup general_events General Events
+ *
+ * @brief General or miscellaneous events.
+ *
+ * @details This category of events are general events not pertaining to a peer or context.
+ *
+ * @{
+ */
+#define DM_EVT_RFU   0x00 /**< Reserved for future use, is never notified. */
+#define DM_EVT_ERROR 0x01 /**< Device Manager Event Error. */
+/** @} */
+
+/**
+ * @defgroup link_status_events Link Status Events
+ *
+ * @brief Link Status Events.
+ *
+ * @details This category of events notify the application of the link status. Event result associated
+ *          with the event is provided along with the event in the callback to provide more details of
+ *          whether a procedure succeeded or failed and assist the application in decision making of
+ *          how to proceed. For example if a DM_DEVICE_CONNECT_IND is indicated with NRF_SUCCESS
+ *          result, the application may want to proceed with discovering and association with
+ *          service of the peer. However, if indicated with a failure result, the application may
+ *          want to take an alternate action such as reattempting to connect or go into a
+ *          sleep mode.
+ *
+ * @{
+ */
+#define DM_EVT_CONNECTION              0x11 /**< Indicates that link with the peer is established. */
+#define DM_EVT_DISCONNECTION           0x12 /**< Indicates that link with peer is torn down. */
+#define DM_EVT_SECURITY_SETUP          0x13 /**< Security procedure for link started indication */
+#define DM_EVT_SECURITY_SETUP_COMPLETE 0x14 /**< Security procedure for link completion indication. */
+#define DM_EVT_LINK_SECURED            0x15 /**< Indicates that link with the peer is secured. For bonded devices, subsequent reconnections with bonded peer will result only in this event when the link is secured and setup procedures will not occur unless the bonding information is either lost or deleted on either or both sides.  */
+#define DM_EVT_SECURITY_SETUP_REFRESH  0x16 /**< Indicates that the security on the link was re-established. */
+/** @} */
+
+/**
+ * @defgroup context_mgmt_events Context Management Events
+ *
+ * @brief Context Management Events.
+ *
+ * @details These events notify the application of the status of context loading and storing.
+ *
+ * @{
+ */
+#define DM_EVT_DEVICE_CONTEXT_LOADED   0x21 /**< Indicates that device context for a peer is loaded. */
+#define DM_EVT_DEVICE_CONTEXT_STORED   0x22 /**< Indicates that device context is stored persistently. */
+#define DM_EVT_DEVICE_CONTEXT_DELETED  0x23 /**< Indicates that device context is deleted. */
+#define DM_EVT_SERVICE_CONTEXT_LOADED  0x31 /**< Indicates that service context for a peer is loaded. */
+#define DM_EVT_SERVICE_CONTEXT_STORED  0x32 /**< Indicates that service context is stored persistently. */
+#define DM_EVT_SERVICE_CONTEXT_DELETED 0x33 /**< Indicates that service context is deleted. */
+#define DM_EVT_APPL_CONTEXT_LOADED     0x41 /**< Indicates that application context for a peer is loaded. */
+#define DM_EVT_APPL_CONTEXT_STORED     0x42 /**< Indicates that application context is stored persistently. */
+#define DM_EVT_APPL_CONTEXT_DELETED    0x43 /**< Indicates that application context is deleted. */
+/** @} */
+/** @} */
+
+#define DM_INVALID_ID 0xFF /**< Invalid instance idenitifer. */
+
+/**
+ * @defgroup dm_data_structure Device Manager Data Types
+ *
+ * @brief This section describes all the data types exposed by the module to the application.
+ * @{
+ */
+
+/**
+ * @brief Application Instance.
+ *
+ * @details Application instance uniquely identifies an application. The identifier is allocated by
+ *          the device manager when application registers with the module. The application is
+ *          expected to identify itself with this instance identifier when initiating subsequent
+ *          requests. Application should use the utility API \ref dm_application_instance_set in
+ *          order to set its application instance in dm_handle_t needed for all subsequent APIs.
+ *          See also \ref dm_register.
+ */
+typedef uint8_t dm_application_instance_t;
+
+/**
+ * @brief Connection Instance.
+ *
+ * @details Identifies connection instance for an active device. This instance is allocated by the 
+ *          device manager when a connection is established and is notified with DM_EVT_CONNECTION
+ *          with the event result NRF_SUCCESS.
+ */
+typedef uint8_t dm_connection_instance_t;
+
+/**
+ * @brief Device Instance.
+ *
+ * @details Uniquely identifies a bonded peer device. The peer device may or may not be connected.
+ *          In case of the central: The bonded device instance to identify the peer is allocated when bonding procedure is initiated by the central using dm_security_setup_req.
+ *          In case of the peripheral: When the bonding procedure is successful, the DM_EVT_SECURITY_SETUP_COMPLETE event with success event result, is received.
+ *          In case the module cannot add more bonded devices, no instance is allocated, this is indicated by an appropriate error code for the API/event as the case may be. Application can choose to disconnect the link.
+ */
+typedef uint8_t dm_device_instance_t;
+
+/**
+ * @brief Service Instance.
+ *
+ * @details Uniquely identifies a peer device. The peer device may or may not be connected. This
+ *          instance is allocated by the device manager when a device is bonded and is notified
+ *          when security procedures have been initiated.
+ *          Security Procedures initiation is notified with DM_SECURITY_SETUP_IND with
+ *          success event result. In case the event result indicates that the module cannot add more
+ *          bonded devices, no instance is allocated. Application can chose to disconnect the link.
+ */
+typedef uint8_t dm_service_instance_t;
+
+/**
+ * @brief Service/Protocol Type Identifier.
+ *
+ * @details Uniquely identifies a service or a protocol type. Service/Protocol Type identification
+ *          is needed as each service/protocol can have its own contextual data.
+ *          This allows the peer to access more than one service at a time. \ref dm_service_cntext_types describes the
+ *          list of services/protocols supported.
+ */
+typedef uint8_t service_type_t;
+
+/**
+ * @brief Device Handle used for unique identification of each peer.
+ *
+ * @details This data type is used to uniquely identify each peer device. A peer device could be
+ *          active and/or bonded. Therefore an instance for active and bonded is provided.
+ *          However, the application is expected to treat this is an opaque structure and use this for
+ *          all API interactions once stored on appropriate events.
+ *          See \ref dm_events.
+ */
+typedef struct device_handle
+{
+    dm_application_instance_t    appl_id;       /**< Identifies the application instances for the device that is being managed. */
+    dm_connection_instance_t     connection_id; /**< Identifies the active connection instance. */
+    dm_device_instance_t         device_id;     /**< Identifies peer instance in the data base. */
+    dm_service_instance_t        service_id;    /**< Service instance identifier. */
+} dm_handle_t;
+
+/**
+ * @brief Definition of Data Context.
+ *
+ * @details Defines contextual data format, it consists of context data length and pointer to data.
+ */
+typedef struct
+{
+    uint32_t  len;    /**< Length of data . */
+    uint8_t * p_data; /**< Pointer to contextual data, a copy is made of the data. */
+} dm_context_t;
+
+
+/**
+ * @brief Device Context.
+ *
+ * @details Defines "device context" type for a device managed by device manager.
+ */
+typedef dm_context_t dm_device_context_t;
+
+/**
+ * @brief Service Context.
+ *
+ * @details Service context data for a service identified by the 'service_type' field.
+ */
+typedef struct
+{
+    service_type_t service_type; /**< Identifies the service/protocol to which the context data is related. */
+    dm_context_t   context_data; /**< Contains length and pointer to context data */
+} dm_service_context_t;
+
+/**
+ * @brief Application context.
+ *
+ * @details The application context can be used by the application to map any application level
+ *          information that is to be mapped with a particular peer.
+ *          For bonded peers, this information will be stored by the bond manager persistently.
+ *          Note that the device manager treats this information as an
+ *          opaque block of bytes.
+ *          Necessary APIs to get and set this context for a peer have been provided.
+ */
+typedef dm_context_t dm_application_context_t;
+
+/**
+ * @brief Event parameters.
+ *
+ * @details Defines event parameters for each of the events notified by the module.
+ */
+typedef union
+{
+    ble_gap_evt_t            * p_gap_param;       /**< All events that are triggered in device manager as a result of GAP events, like connection, disconnection and security procedures are accompanied with GAP parameters. */
+    dm_application_context_t * p_app_context;     /**< All events that are associated with application context procedures of store, load, and deletion have this as event parameter. */
+    dm_service_context_t     * p_service_context; /**< All events that are associated with service context procedures of store, load and deletion have this as event parameter. */
+    dm_device_context_t      * p_device_context;  /**< All events that are associated with device context procedures of store, load and deletion have this as event parameter. */
+} dm_event_param_t;
+
+/**
+ * @brief Asynchronous events details notified to the application by the module.
+ *
+ * @details Defines event type along with event parameters notified to the application by the
+ *          module.
+ */
+typedef struct
+{
+    uint8_t          event_id;       /**< Identifies the event. See \ref dm_events for details on event types and their significance. */
+    dm_event_param_t event_param;    /**< Event parameters. Can be NULL if the event does not have any parameters. */
+    uint16_t         event_paramlen; /**< Length of the event parameters, is zero if the event does not have any parameters. */
+} dm_event_t;
+
+/**
+ * @brief Event notification callback registered by application with the module.
+ *
+ * @details Event notification callback registered by application with the module when registering
+ *          the module using \ref dm_register API.
+ *
+ * @param[in] p_handle   Identifies the peer for which the event is being notified.
+ * @param[in] p_event    Identifies the event, any associated parameters and parameter length.
+ *                       See \ref dm_events for details on event types and their significance.
+ * @param[in,out] event_result   Provide additional information on the event. 
+ *                      In addition to SDK error codes there is also a return value
+ *                      indicating if maximum number of connections has been reached when connecting or bonding.
+ *
+ * @retval NRF_SUCCESS on success, or a failure to indicate if it could handle the event
+ *         successfully. There is no action taken in case application returns a failure.
+ */
+typedef api_result_t (*dm_event_cb_t)(dm_handle_t const * p_handle,
+                                      dm_event_t const  * p_event,
+                                      api_result_t        event_result);
+
+/**
+ * @brief Initialization Parameters.
+ *
+ * @details Indicates the application parameters. Currently this only encompasses clearing
+ *          all persistent data.
+ */
+typedef struct
+{
+    bool clear_persistent_data; /**< Set to true in case the module should clear all persistent data. */
+} dm_init_param_t;
+
+/**
+ * @brief Application Registration Parameters.
+ *
+ * @details Parameters needed by the module when registering with it.
+ */
+typedef struct
+{
+    dm_event_cb_t        evt_handler;  /**< Event Handler to be registered. It will receive asynchronous notification from the module, see \ref dm_events for asynchronous events. */
+    uint8_t              service_type; /**< Bit mask identifying services that the application intends to support for all peers. */
+    ble_gap_sec_params_t sec_param;    /**< Security parameters to be used for the application. */
+} dm_application_param_t;
+
+/**
+ * @brief Defines possible security status/states.
+ *
+ * @details Defines possible security status/states of a link when requested by application using
+ *          the \ref dm_security_status_req.
+ */
+typedef enum
+{
+    NOT_ENCRYPTED,                  /**< The link does not security. */
+    ENCRYPTION_IN_PROGRESS, /**< Security is in progress of being established.*/
+    ENCRYPTED              /**< The link is secure.*/
+} dm_security_status_t;
+/** @} */
+
+/**
+ * @defgroup dm_api Device Module APIs
+ *
+ * @brief This section describes APIs exposed by the module.
+ *
+ * @details This section describes APIs exposed by the module. The APIs have been categorized to provide
+ *          better and specific look up for developers. Categories are:
+ *          a. Set up APIs.
+ *          b. Context Management APIs.
+ *          c. Utility APIs.
+ *
+ *          MSCs describe usage of these APIs. See @mscfile dm_api.dox
+ * @{
+ */
+/**
+ * @defgroup dm_setup_api Device Module Set-up APIs
+ *
+ * @brief Initialization & registration APIs that are pre-requisite for all other module procedures.
+ * @details This section describes the Module Initialization and Registration APIs needed to be set up by
+ *          the application before device manager can start managing devices and device contexts
+ *          for the application.
+ *
+ * @{
+ */
+
+/**
+ * @brief Module Initialization Routine.
+ *
+ * @details Function for initializing the module. Must called before any other APIs of the module are used.
+ *
+ * @param[in] p_init_param Initialization parameters.
+ *
+ * @retval NRF_SUCCESS On success, else an error code indicating reason for failure.
+ *
+ * @note It is mandatory that pstorage is initialized before initializing this module.
+ */
+api_result_t dm_init(dm_init_param_t const * p_init_param);
+
+/**
+ * @brief Function for registering the application.
+ *
+ * @details This routine is used by the application to register for asynchronous events with the
+ *          device manager. During registration the application also indicates the services that it
+ *          intends to support on this instance. It is possible to register multiple times with the
+ *          device manager. At least one instance shall be registered with the device manager after
+ *          the module has been initialized.
+ *          Maximum number of application instances device manager can support is determined
+ *          by DM_MAX_APPLICATIONS.
+ *
+ *          All applications must be registered before initiating or accepting connections from the peer.     
+ *
+ * @param[in]  p_appl_param    Application parameters.
+ * @param[out] p_appl_instance Application Instance Identifier in case registration is successful.
+ *
+ * @retval NRF_SUCCESS             On success, else an error code indicating reason for failure.
+ * @retval NRF_ERROR_INVALID_STATE If the API is called without module initialization.
+ * @retval NRF_ERROR_NO_MEM        If module cannot support more applications.
+ *
+ * @note Currently only one application instance is supported by the module.
+ */
+api_result_t dm_register(dm_application_instance_t    * p_appl_instance,
+                         dm_application_param_t const * p_appl_param);
+
+/**
+ * @brief Function for handling BLE events.
+ *
+ * @details BLE Event Handler for the module. This routine should be called from BLE stack event
+ *          dispatcher for the module to work as expected.
+ *
+ * @param[in] p_ble_evt BLE stack event being dispatched to the function.
+ *
+ */
+void dm_ble_evt_handler(ble_evt_t * p_ble_evt);
+
+/** @} */
+
+
+/**
+ * @defgroup dm_security_api APIs to set up or read status of security on a link.
+ *
+ * @brief This section describes APIs to set up Security. These APIs require that the peer is
+ *        connected before the procedures can be requested.
+ *
+ * @details This group allows application to request security procedures
+ *          or get the status of the security on a link.
+ * @{
+ */
+/**
+ * @brief Function for requesting setting up security on a link.
+ *
+ * @details This API initiates security procedures with a peer device.
+ *          @note For the GAP Central role, in case peer is not bonded, request to bond/pair is
+ *          initiated. If it is bonded, the link is re-encrypted using the existing bond information.
+ *          For the GAP peripheral role, a Slave security request is sent.
+ * @details If a pairing procedure is initiated successfully, application is notified of
+ *          @ref DM_EVT_SECURITY_SETUP_COMPLETE. A result indicating success or failure is notified along with the event.
+ *          In case the link is re-encrypted using existing bond information, @ref DM_EVT_LINK_SECURED is
+ *          notified to the application.
+ *
+ * @param[in] p_handle Identifies the link on which security is desired.
+ *
+ * @retval NRF_SUCCESS             On success, else an error code indicating reason for failure.
+ * @retval NRF_ERROR_INVALID_STATE If the API is called without module initialization and/or
+ *                                 application registration.
+ * @retval NRF_ERROR_NULL          If p_handle is NULL.
+ * @retval NRF_ERROR_INVALID_ADDR  If the peer is not identified by the handle provided by the application
+ *                                 or if the peer is not connected when this procedure is requested.
+ */
+api_result_t dm_security_setup_req(dm_handle_t * p_handle);
+
+/**
+ * @brief Function for reading the status of the security on a link.
+ *
+ * @details This API allows application to query status of security on a link.
+ *
+ * @param[in]  p_handle  Identifies the link on which security is desired.
+ * @param[out] p_status  Pointer where security status is provided to the application.
+ *                       See \ref dm_security_status_t for possible statuses that can be expected.
+ *
+ * @retval NRF_SUCCESS             Or appropriate error code indicating reason for failure.
+ * @retval NRF_ERROR_INVALID_STATE If the API is called without module initialization and/or
+ *                                 application registration.
+ * @retval NRF_ERROR_NULL          If p_handle or p_status is NULL.
+ * @retval NRF_ERROR_INVALID_ADDR  If peer is not identified by the handle provided by the application
+ *                                 or if peer is not connected when this procedure is requested.
+ */
+api_result_t dm_security_status_req(dm_handle_t const * p_handle, dm_security_status_t * p_status);
+
+/**
+ * @brief Function for creating the whitelist.
+ *
+ * @details This API allows application to create whitelist based on bonded peer devices in module
+ *          data base.
+ *
+ * @param[in]  p_handle       Identifies the application requesting whitelist creation.
+ * @param[in,out] p_whitelist Pointer where created whitelist is provided to the application.
+ *
+ * @note 'addr_count' and 'irk_count' fields of the structure should be populated with the maximum
+ *       number of devices that the application wishes to request in the whitelist. 
+ *       If the number of bonded devices is less than requested, the fields are updated with that number of devices.
+ *       If the number of devices are more than requested, the module will populate the list
+ *       with devices in the order the bond was established with the peer devices. Also, if this routine is
+ *       called when a connection exists with one or more peer devices,
+ *       those connected devices are not added to the whitelist.
+ *
+ * @retval NRF_SUCCESS             On success, else an error code indicating reason for failure.
+ * @retval NRF_ERROR_INVALID_STATE If the API is called without module initialization and/or
+ *                                 application registration.
+ * @retval NRF_ERROR_NULL          If p_handle or p_whitelist is NULL.
+ */
+api_result_t dm_whitelist_create(dm_application_instance_t const * p_handle,
+                                 ble_gap_whitelist_t             * p_whitelist);
+
+/** @} */
+
+
+/**
+ * @defgroup dm_cntxt_mgmt_api Context Management APIs
+ *
+ * @brief Utility APIs offered by the device manager to get information about the peer if and
+ *        when needed.
+ *
+ * @details This group of API allow the application to access information that is not required to be
+ *          maintained by the application but may be needed. Hence it is possible to get the
+ *          information from the module instead of mapping all the information with a device
+ *          context.
+ * @{
+ */
+
+api_result_t dm_device_add(dm_handle_t               * p_handle,
+                           dm_device_context_t const * p_context);
+                           
+/**
+ * @brief Function for deleting a peer device context and all related information from the database.
+ *
+ * @details Delete peer device context and all related information from database. If
+ *          this API returns NRF_SUCCESS, DM_EVT_DEVICE_CONTEXT_DELETED event is notified to the
+ *          application. Event result notified along with the event indicates success or failure
+ *          of this procedure.
+ *
+ * @param[in] p_handle Identifies the peer device to be deleted.
+ *
+ * @retval NRF_SUCCESS             on success, else an error code indicating reason for failure.
+ * @retval NRF_ERROR_INVALID_STATE In the API is called without module initialization and/or
+ *                                 application registration.
+ * @retval NRF_ERROR_NULL          If p_handle is NULL.
+ * @retval NRF_ERROR_INVALID_ADDR  If peer is not identified the handle provided by the application.
+ *
+ * @note Deleting device context results in deleting service and application context for the
+ *       bonded device. The respective events DM_EVT_SERVICE_CONTEXT_DELETED and
+ *       DM_EVT_APPL_CONTEXT_DELETED are not notified to the application.
+ */
+api_result_t dm_device_delete(dm_handle_t const * p_handle);
+
+/**
+ * @brief Function for deleting all peer device context and all related information from the database.
+ *
+ * @details Delete peer device context and all related information from database. If
+ *          this API returns NRF_SUCCESS, DM_EVT_DEVICE_CONTEXT_DELETED event is notified to the
+ *          application for each device that is deleted from the data base. Event result
+ *          notified along with the event indicates success or failure of this procedure.
+ *
+ * @param[in] p_handle Identifies application instance that is requesting
+ *                     the deletion of all bonded devices.
+ *
+ * @retval NRF_SUCCESS             On success, else an error code indicating reason for failure.
+ * @retval NRF_ERROR_INVALID_STATE If the API is called without module initialization and/or
+ *                                 application registration.
+ * @retval NRF_ERROR_NULL          If p_handle is NULL.
+ * @retval NRF_ERROR_INVALID_ADDR  If peer is not identified the handle provided by the application.
+ *
+ * @note Deleting device context results in deleting both service and application context for the
+ *       bonded device. The respective events DM_EVT_SERVICE_CONTEXT_DELETED and
+ *       DM_EVT_APPL_CONTEXT_DELETED are not notified to the application.
+ */
+api_result_t dm_device_delete_all(dm_application_instance_t const * p_handle);
+
+/**
+ * @brief Function for setting Service Context for a peer device identified by 'p_handle' parameter.
+ *
+ * @details This API allows application to Set Service Context for a peer device identified by the
+ *          'p_handle' parameter. This API is useful when the Service Context cannot be requested
+ *          from the SoftDevice, but needs to be assembled by the application or an another module.
+ *          (or when service context is exchanged in an out of band way.)
+ *          This API could also be used to trigger a storing of service context into persistent
+ *          memory. If this is desired, a NULL pointer could be passed to the p_context.
+ *
+ * @param[in] p_handle  Identifies peer device for which the procedure is requested.
+ * @param[in] p_context Service context being set. The context information includes length of
+ *                      data and pointer to the contextual data being set. The memory pointed to by
+ *                      the pointer to data is assumed to be resident when API is being called and
+ *                      can be freed or reused once the set procedure is complete. Set procedure
+ *                      completion is indicated by the event \ref DM_EVT_SERVICE_CONTEXT_STORED.
+ *                      The Event result is notified along with the event and indicates success or failure of
+ *                      this procedure.
+ *
+ * @retval NRF_SUCCESS             On success, else an error code indicating reason for failure.
+ * @retval NRF_ERROR_INVALID_STATE If the API is called without module initialization and/or
+ *                                 application registration.
+ * @retval NRF_ERROR_NULL          If p_handle is NULL.
+ * @retval NRF_ERROR_INVALID_ADDR  If the peer is not identified by the handle provided by the application.
+ */
+api_result_t dm_service_context_set(dm_handle_t const          * p_handle,
+                                    dm_service_context_t const * p_context);
+
+/**
+ * @brief Function for getting Service Context for a peer device identified by 'p_handle' parameter.
+ *
+ * @details Get Service Context for a peer device identified by the 'p_handle' parameter. If
+ *          this API returns NRF_SUCCESS, DM_EVT_SERVICE_CONTEXT_LOADED event is notified to the
+ *          application. The event result is notified along with the event indicates success or failure
+ *          of this procedure.
+ *
+ * @param[in] p_handle  Identifies peer device for which procedure is requested.
+ * @param[in] p_context Application context being requested. The context information includes length
+ *                      of the data and a pointer to the data. Note that requesting a 'get'
+ *                      of application does not need to provide memory, the pointer to data will be
+ *                      pointing to service data and hence no data movement is involved.
+ *
+ * @retval NRF_SUCCESS             On success, else an error code indicating reason for failure.
+ * @retval NRF_ERROR_INVALID_STATE In case API is called without module initialization and/or
+ *                                 application registration.
+ * @retval NRF_ERROR_NULL          If p_handle is NULL.
+ * @retval NRF_ERROR_INVALID_ADDR  If the peer is not identified by the handle provided by the application.
+ */
+api_result_t dm_service_context_get(dm_handle_t const    * p_handle,
+                                    dm_service_context_t * p_context);
+
+/**
+ * @brief Function for deleting a Service Context for a peer device identified by the 'p_handle' parameter.
+ *
+ * @details This API allows application to delete a Service Context identified for a peer device
+ *          identified by the 'p_handle' parameter. If this API returns NRF_SUCCESS,
+ *          DM_EVT_SERVICE_CONTEXT_DELETED event is notified to the application. 
+ *          Event result is notified along with the event and indicates success or failure of this
+ *          procedure.
+ *
+ * @param[in] p_handle Identifies peer device for which procedure is requested.
+ *
+ * @retval NRF_SUCCESS             On success, else an error code indicating reason for failure.
+ * @retval NRF_ERROR_INVALID_STATE If the API is called without module initialization and/or
+ *                                 application registration.
+ * @retval NRF_ERROR_NULL          If p_handle is NULL.
+ * @retval NRF_ERROR_INVALID_ADDR  If the peer is not identified by the handle provided by the application.
+ */
+api_result_t dm_service_context_delete(dm_handle_t const * p_handle);
+
+/**
+ * @brief Function for setting Application Context for a peer device identified by the 'p_handle' parameter.
+ *
+ * @details This application allows the setting of the application context for the peer device identified by
+ *          the 'p_handle'. Application context is stored persistently by the module and can be
+ *          requested by the application at any time using the \ref dm_application_context_get
+ *          API. Note that this procedure is permitted only for bonded devices. If the
+ *          device is not bonded, application context cannot be set. However, it is not mandatory
+ *          that the bonded device is connected when requesting this procedure.
+ *
+ * @param[in] p_handle  Identifies peer device for which procedure is requested.
+ *
+ * @param[in] p_context Application context being set. The context information includes length of the
+ *                      data and pointer to the contextual data being set. The memory pointed to by
+ *                      the data pointer is assumed to be resident when API is being called and
+ *                      can be freed or reused once the set procedure is complete. Set procedure
+ *                      completion is notified by the event \ref DM_EVT_APPL_CONTEXT_STORED.
+ *                      The event result is notified along with the event and indicates success or
+ *                      failure of this procedure.
+ *
+ * @retval NRF_SUCCESS             On success, else an error code indicating reason for failure.
+ * @retval NRF_ERROR_INVALID_STATE If the API is called without module initialization and/or
+ *                                 application registration.
+ * @retval NRF_ERROR_NULL          If p_handle and/or p_context is NULL.
+ * @retval NRF_ERROR_INVALID_ADDR  If peer is not identified the handle provided by the application.
+ *
+ * @note The API returns FEATURE_NOT_ENABLED in case DEVICE_MANAGER_APP_CONTEXT_SIZE is set to zero.
+ */
+api_result_t dm_application_context_set(dm_handle_t const              * p_handle,
+                                        dm_application_context_t const * p_context);
+
+/**
+ * @brief Function for getting Application Context for a peer device identified by the 'p_handle' parameter.
+ *
+ * @details Get Application Context for a peer device identified by the 'p_handle' parameter. If
+ *          this API returns NRF_SUCCESS, DM_EVT_APPL_CONTEXT_LOADED event is notified to the
+ *          application. Event result notified along with the event indicates success or failure
+ *          of this procedure.
+ *
+ * @param[in] p_handle  Identifies peer device for which procedure is requested.
+ * @param[in] p_context Application context being requested. The context information includes
+ *                      length of data and pointer to the contextual data is provided.
+ *
+ * @retval NRF_SUCCESS             On success, else an error code indicating reason for failure.
+ * @retval NRF_ERROR_INVALID_STATE If the API is called without module initialization and/or
+ *                                 application registration.
+ * @retval NRF_ERROR_NULL          If p_handle and/or p_context is NULL.
+ * @retval NRF_ERROR_INVALID_ADDR  If the peer is not identified by the handle provided by the application.
+ * @retval DM_NO_APP_CONTEXT       If no application context was set that can be fetched.
+ *
+ * @note The API returns FEATURE_NOT_ENABLED in case DEVICE_MANAGER_APP_CONTEXT_SIZE is set to
+ *       zero.
+ */
+api_result_t dm_application_context_get(dm_handle_t const        * p_handle,
+                                        dm_application_context_t * p_context);
+
+/**
+ * @brief Function for deleting Application Context for a peer device identified by the 'p_handle' parameter.
+ *
+ * @details Delete Application Context for a peer device identified by the 'p_handle' parameter. If
+ *          this API returns NRF_SUCCESS, DM_EVT_APPL_CONTEXT_DELETED event is notified to the
+ *          application. The event result notified along with the event and indicates success or failure
+ *          of this procedure.
+ *
+ * @param[in] p_handle Identifies peer device for which procedure is requested.
+ *
+ * @retval NRF_SUCCESS             On success, else an error code indicating reason for failure.
+ * @retval NRF_ERROR_INVALID_STATE If the API is called without module initialization and/or
+ *                                 application registration.
+ * @retval NRF_ERROR_NULL          If the p_handle is NULL.
+ * @retval NRF_ERROR_INVALID_ADDR  If peer is not identified the handle provided by the application.
+ * @retval DM_NO_APP_CONTEXT       If no application context was set that can be deleted.
+ *
+ * @note The API returns FEATURE_NOT_ENABLED if the DEVICE_MANAGER_APP_CONTEXT_SIZE is set to zero.
+ */
+api_result_t dm_application_context_delete(dm_handle_t const * p_handle);
+
+/** @} */
+
+
+/**
+ * @defgroup utility_api Utility APIs
+ * @{
+ * @brief This section describes the utility APIs offered by the module.
+ *
+ * @details APIs defined in this section are utility or assisting/helper APIs.
+ */
+/**
+ * @brief Function for Setting/Copying Application instance to Device Manager handle.
+ *
+ * @param[in]  p_appl_instance Application instance to be set.
+ * @param[out] p_handle        Device Manager handle for which the instance is to be copied.
+ *
+ * @retval NRF_SUCCESS             On success, else an error code indicating reason for failure.
+ * @retval NRF_ERROR_INVALID_STATE If the API is called without module initialization and/or
+ *                                 application registration.
+ * @retval NRF_ERROR_NULL          If p_handle and/or p_addr is NULL.
+ */
+api_result_t dm_application_instance_set(dm_application_instance_t const * p_appl_instance,
+                                         dm_handle_t                     * p_handle);
+
+/**
+ * @brief Function for getting a peer's device address.
+ *
+ * @param[in]  p_handle Identifies the peer device whose address is requested. Can not be NULL.
+ * @param[out] p_addr   Pointer where address is to be copied. Can not be NULL.
+ *
+ * @retval NRF_SUCCESS             On success, else an error code indicating reason for failure.
+ * @retval NRF_ERROR_INVALID_STATE If the API is called without module initialization and/or
+ *                                 application registration.
+ * @retval NRF_ERROR_NULL          If p_handle and/or p_addr is NULL.
+ * @retval NRF_ERROR_NOT_FOUND     If the peer could not be identified.
+ */
+api_result_t dm_peer_addr_get(dm_handle_t const * p_handle,
+                              ble_gap_addr_t    * p_addr);
+
+/**
+ * @brief Function for setting/updating a peer's device address.
+ *
+ * @param[in]  p_handle Identifies the peer device whose address is requested to be set/updated.
+ * @param[out] p_addr   Address to be set/updated.
+ *
+ * @retval NRF_SUCCESS             On success, else an error code indicating reason for failure.
+ * @retval NRF_ERROR_INVALID_STATE If the API is called without module initialization and/or
+ *                                 application registration.
+ * @retval NRF_ERROR_NULL          If p_handle and/or p_addr is NULL.
+ * @retval NRF_ERROR_INVALID_ADDR  If the peer is not identified by the handle provided by the application.
+ * @retval NRF_ERROR_INVALID_PARAM If this procedure is requested while connected to the peer or if the address
+ *                                 type was set to BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE.
+ *
+ * @note Setting or updating a peer's device address is permitted 
+ *       only for a peer that is bonded and disconnected.
+ * @note Updated address is reflected only after DM_EVT_DEVICE_CONTEXT_STORED is notified to the
+ *       application for this bonded device instance. In order to avoid abnormal behaviour, it is
+ *       recommended to not invite/initiate connections on the updated address unless this event
+ *       has been notified.
+ */
+api_result_t dm_peer_addr_set(dm_handle_t const    * p_handle,
+                              ble_gap_addr_t const * p_addr);
+
+/**
+ * @brief Function for initializing Device Manager handle.
+ *
+ * @param[in] p_handle Device Manager handle to be initialized.
+ *
+ * @retval NRF_SUCCESS    On success.
+ * @retval NRF_ERROR_NULL If p_handle is NULL.
+ *
+ * @note This routine is permitted before initialization of the module.
+ */
+api_result_t dm_handle_initialize(dm_handle_t * p_handle);
+
+#ifdef GAP_CENTRAL
+/**
+ * @brief Function for getting distributed keys for a device.
+ *
+ * @details This routine is used to get distributed keys with a bonded device. This API is currently
+ *          only available on S120 (GAP Central role).
+ *
+ * @param[in] p_handle Device Manager handle identifying the peer.
+ *
+ * @param[out] p_key_dist Pointer to distributed keys.
+ *
+ * @retval NRF_SUCCESS             On success, else an error code indicating reason for failure.
+ * @retval NRF_ERROR_INVALID_STATE If the API is called without module initialization and/or
+ *                                 application registration.
+ * @retval NRF_ERROR_NULL          If the p_handle and/or p_key_dist pointer is NULL.
+ * @retval NRF_ERROR_INVALID_ADDR  If the peer is not identified by the handle provided by the application.
+ */
+api_result_t dm_distributed_keys_get(dm_handle_t const    * p_handle,
+                                     ble_gap_sec_keyset_t * p_key_dist);
+#endif // GAP_CENTRAL
+/** @} */
+/** @} */
+/** @} */
+#endif // DEVICE_MANAGER_H__
+
--- a/nordic/nrf-sdk/ble/rpc/ble_rpc_cmd_decoder.h	Thu Jul 03 10:01:02 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
- *
- * The information contained herein is property of Nordic Semiconductor ASA.
- * Terms and conditions of usage are described in detail in NORDIC
- * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
- *
- * Licensees are granted free, non-transferable use of the information. NO
- * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
- * the file.
- *
- */
-
-/** @file
- *
- * @defgroup ble_rpc_cmd_decoder Command Decoder
- * @{
- * @ingroup ble_sdk_lib_serialization
- *
- * @brief   Decoder for serialized commands from Application Chip.
- *
- * @details This file contains declaration of common functions used for sending responses back to
- *          Application Chip after the command is processed, and function for processing commands
- *          received by the transport layer.
- */
-
-#ifndef BLE_RPC_CMD_DECODER_H__
-#define BLE_RPC_CMD_DECODER_H__
-
-#include <stdint.h>
-
-#define RPC_DECODER_LENGTH_CHECK(LEN, INDEX, CMD) if ( INDEX > LEN) \
-        return ble_rpc_cmd_resp_send(CMD, NRF_ERROR_INVALID_LENGTH);
-
-/**@brief Function for sending a Command Response packet to the Application Chip through the transport
- *        layer.
- *
- * @param[in] op_code          The op code of the command for which the Command Response is sent.
- * @param[in] status           The status field to be encoded into the Command Response.
- *
- * @retval NRF_SUCCESS         On successful write of Command Response, otherwise an error code.
- *                             If the transport layer returns an error code while sending
- *                             the Command Response, the same error code will be returned by this
- *                             function (see @ref hci_transport_pkt_write for the list of
- *                             error codes).
- */
-uint32_t ble_rpc_cmd_resp_send(uint8_t op_code, uint32_t status);
-
-/**@brief Function for sending a command response with additional data to the Application Chip through
- *        the transport layer.
- *
- * @param[in]   op_code        The op code of the command for which the Command Response is sent.
- * @param[in]   status         The status field to be encoded into the Command Response.
- * @param[in]   p_data         The data to be sent along with the status.
- * @param[in]   data_len       The length of the additional data.
- *
- * @retval      NRF_SUCCESS    On successful write of Command Response, otherwise an error code.
- *                             If the transport layer returns an error code while sending
- *                             the Command Response, the same error code will be returned by this
- *                             function (see @ref hci_transport_pkt_write for the list of
- *                             error codes).
- */
-uint32_t ble_rpc_cmd_resp_data_send(uint8_t               op_code,
-                                    uint8_t               status,
-                                    const uint8_t * const p_data,
-                                    uint16_t              data_len);
-
-/**@brief Function for scheduling an RPC command event to be processed in main-thread.
- *
- * @details     The function will read the arrived packet from the transport layer
- *              which is passed for decoding by the rpc_cmd_decoder module.
- *
- * @param[in]   p_event_data   Event data. This will be NULL as rpc_evt_schedule
- *                             does not set any data.
- * @param[in]   event_size     Event data size. This will be 0 as rpc_evt_schedule
- *                             does not set any data.
- */
-void ble_rpc_cmd_handle(void * p_event_data, uint16_t event_size);
-
-#endif // BLE_RPC_CMD_DECODER_H__
-
-/** @} */
--- a/nordic/nrf-sdk/ble/rpc/ble_rpc_cmd_decoder_gap.h	Thu Jul 03 10:01:02 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
- *
- * The information contained herein is property of Nordic Semiconductor ASA.
- * Terms and conditions of usage are described in detail in NORDIC
- * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
- *
- * Licensees are granted free, non-transferable use of the information. NO
- * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
- * the file.
- *
- */
-
-/** @file
- *
- * @defgroup ble_rpc_cmd_decoder_gap GAP Command Decoder
- * @{
- * @ingroup ble_sdk_lib_serialization
- *
- * @brief   Decoder for serialized GAP commands from Application Chip.
- *
- * @details This file contains the declaration of the function that decodes the serialized GAP
- *          commands from Application Chip and calls the appropriate BLE stack API.
- */
-
-#ifndef BLE_RPC_CMD_DECODER_GAP_H__
-#define BLE_RPC_CMD_DECODER_GAP_H__
-
-#include <stdint.h>
-
-/**@brief Function for processing the encoded GAP command from Application Chip.
- *
- * @details     This function will decode the encoded command and call the appropriate BLE Stack
- *              API. It will then create a Command Response packet with the return value from the
- *              stack API encoded in it and will send it to the transport layer for transmission to
- *              the application controller chip.
-
- * @param[in]   p_command      The encoded command.
- * @param[in]   op_code        Operation code of the command.
- * @param[in]   command_len    Length of the encoded command.
- *
- * @retval      NRF_SUCCESS    If the decoding of the command was successful, the soft device API
- *                             was called, and the command response was sent to peer, otherwise an
- *                             error code.
- *                             If the transport layer returns an error code while sending
- *                             the Command Response, the same error code will be returned by this
- *                             function (see @ref hci_transport_pkt_write for the list of
- *                             error codes).
- */
-uint32_t ble_rpc_cmd_gap_decode(uint8_t * p_command, uint8_t op_code, uint32_t command_len);
-
-#endif // BLE_RPC_CMD_DECODER_GAP_H__
-
-/** @} */
--- a/nordic/nrf-sdk/ble/rpc/ble_rpc_cmd_decoder_gatts.h	Thu Jul 03 10:01:02 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
- *
- * The information contained herein is property of Nordic Semiconductor ASA.
- * Terms and conditions of usage are described in detail in NORDIC
- * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
- *
- * Licensees are granted free, non-transferable use of the information. NO
- * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
- * the file.
- *
- */
-
-/** @file
- *
- * @defgroup ble_rpc_cmd_decoder_gatts GATTS Command Decoder
- * @{
- * @ingroup ble_sdk_lib_serialization
- *
- * @brief   Decoder for serialized GATTS commands from Application Chip.
- *
- * @details This file contains the declaration of the function that decodes the serialized GATTS
- *          commands from Application Chip and calls the appropriate BLE stack API.
- */
-
-#ifndef BLE_RPC_CMD_DECODER_GATTS_H__
-#define BLE_RPC_CMD_DECODER_GATTS_H__
-
-#include <stdint.h>
-
-/**@brief Function for processing the encoded GATTS command from application chip.
- *
- * @details     This function will decode the encoded command and call the appropriate BLE Stack
- *              API. It will then create a Command Response packet with the return value from the
- *              stack API encoded in it and will send it to the transport layer for transmission to
- *              the application controller chip.
-
- * @param[in]   p_command      The encoded command.
- * @param[in]   op_code        Operation code of the command.
- * @param[in]   command_len    Length of the encoded command.
- *
- * @retval      NRF_SUCCESS    If the decoding of the command was successful, the soft device API
- *                             was called, and the command response was sent to peer, otherwise an
- *                             error code.
- *                             If the transport layer returns an error code while sending
- *                             the Command Response, the same error code will be returned by this
- *                             function (see @ref hci_transport_pkt_write for the list of
- *                             error codes).
- */
-uint32_t ble_rpc_cmd_gatts_decode(uint8_t * p_command, uint8_t op_code, uint32_t command_len);
-
-#endif // BLE_RPC_CMD_DECODER_GATTS_H__
-
-/** @} */
--- a/nordic/nrf-sdk/ble/rpc/ble_rpc_cmd_encoder.h	Thu Jul 03 10:01:02 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
- *
- * The information contained herein is property of Nordic Semiconductor ASA.
- * Terms and conditions of usage are described in detail in NORDIC
- * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
- *
- * Licensees are granted free, non-transferable use of the information. NO
- * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
- * the file.
- *
- */
-
-/** @file
- *
- * @defgroup ble_rpc_cmd_encoder Command Encoder
- * @{
- * @ingroup ble_sdk_lib_serialization
- *
- * @brief   Encoder for serialized commands from Application Chip.
- *
- * @details This file contains the declaration of the functions that encode serialized commands
- *          from Application Chip.
- */
-
-#ifndef BLE_RPC_CMD_ENCODER_H__
-#define BLE_RPC_CMD_ENCODER_H__
-
-#include <stdint.h>
-#include "ble_rpc_defines.h"
-
-/**@brief Command response type. */
-typedef struct
-{
-    uint8_t  op_code;   /**< Operation code for which this response applies. */
-    uint32_t err_code;  /**< Error code received for this response applies. */
-} cmd_response_t;
-
-/**@brief Function for initializing the BLE S110 RPC Command Encoder module.
- *
- * @details This function uses the HCI Transport module, \ref hci_transport and executes
- *          \ref hci_transport_tx_done_register and \ref hci_transport_tx_alloc . All errors
- *          returned by those functions are passed on by this function.
- *
- * @retval NRF_SUCCESS      Upon success
- * @return                  Errors from \ref hci_transport  and \ref hci_transport_tx_alloc .
- */
-uint32_t ble_rpc_cmd_encoder_init(void);
-
-/**@brief Function for blocking in a loop, using WFE to allow low power mode, while awaiting a
- *        response from the connectivity chip.
- *
- * @param[in] op_code       The Operation Code for which a response message is expected.
- *
- * @return The decoded error code received from the connectivity chip.
- */
-uint32_t ble_rpc_cmd_resp_wait(uint8_t op_code);
-
-/**@brief Function for handling the command response packet.
- *
- * @details  This function will be called when a command response is received in the transport
- *           layer. The response is decoded and returned to the waiting caller.
- *
- * @param[in] p_packet      The packet from the transport layer.
- * @param[in] packet_length The length of the packet.
- */
-void ble_rpc_cmd_rsp_pkt_received(uint8_t * p_packet, uint16_t packet_length);
-
-#endif  // BLE_RPC_CMD_ENCODER_H__
-
-/**@} */
--- a/nordic/nrf-sdk/ble/rpc/ble_rpc_defines.h	Thu Jul 03 10:01:02 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
- *
- * The information contained herein is property of Nordic Semiconductor ASA.
- * Terms and conditions of usage are described in detail in NORDIC
- * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
- *
- * Licensees are granted free, non-transferable use of the information. NO
- * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
- * the file.
- *
- */
- 
-/** @file
- *
- * @defgroup rpc_cmd_defines Defines related to serialized BLE commands.
- * @{
- * @ingroup ble_sdk_lib
- *
- * @brief Defines for serialized BLE commands.
- *
- */
- 
-#ifndef BLE_RPC_DEFINES_H__
-#define BLE_RPC_DEFINES_H__
-
-#define RPC_CMD_OP_CODE_POS                     0                      /**< Position of the Op Code in the command buffer.*/
-#define RPC_CMD_DATA_POS                        1                      /**< Position of the data in the command buffer.*/
-
-#define RPC_CMD_RESP_PKT_TYPE_POS               0                      /**< Position of Packet type  in the command response buffer.*/
-#define RPC_CMD_RESP_OP_CODE_POS                1                      /**< Position of the Op Code in the command response buffer.*/
-#define RPC_CMD_RESP_STATUS_POS                 2                      /**< Position of the status field in the command response buffer.*/
-
-#define RPC_BLE_FIELD_LEN                       1                      /**< Optional field length size in bytes. */
-#define RPC_BLE_FIELD_PRESENT                   0x01                   /**< Value to indicate that an optional field is encoded in the serialized packet, e.g. white list. */
-#define RPC_BLE_FIELD_NOT_PRESENT               0x00                   /**< Value to indicate that an optional field is not encoded in the serialized packet. */
-
-#define RPC_ERR_CODE_SIZE                       4                      /**< BLE API err_code size in bytes. */
-#define BLE_PKT_TYPE_SIZE                       1                      /**< Packet type (@ref ble_rpc_pkt_type_t) field size in bytes. */
-#define BLE_OP_CODE_SIZE                        1                      /**< Operation code field size in bytes. */
-
-#define RPC_BLE_CMD_RESP_PKT_MIN_SIZE           6                      /**< Minimum length of a command response. */
-#define RPC_BLE_PKT_MAX_SIZE                    596                    /**< Maximum size for a BLE packet on the HCI Transport layer. This value is the hci_mem_pool buffer size minus the HCI Transport size. @note This value must be aligned with TX_BUF_SIZE in hci_mem_pool_internal.h. */
-
-/**@brief The types of packets. */
-typedef enum
-{
-    BLE_RPC_PKT_CMD,                                                   /**< Command packet type. */
-    BLE_RPC_PKT_RESP,                                                  /**< Command Response packet type. */
-    BLE_RPC_PKT_EVT,                                                   /**< Event packet type. */
-    BLE_RPC_PKT_TYPE_MAX                                               /**< Upper bound. */
-} ble_rpc_pkt_type_t;
-
-#endif // BLE_RPC_DEFINES_H__
-
-/** @} */
--- a/nordic/nrf-sdk/ble/rpc/ble_rpc_event_decoder.h	Thu Jul 03 10:01:02 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
- *
- * The information contained herein is property of Nordic Semiconductor ASA.
- * Terms and conditions of usage are described in detail in NORDIC
- * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
- *
- * Licensees are granted free, non-transferable use of the information. NO
- * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
- * the file.
- *
- */
-
-/** @file
- *
- * @defgroup ble_rpc_evt_decoder Event Decoder
- * @{
- * @ingroup ble_sdk_lib_serialization
- *
- * @brief   Decoder for serialized events from nRF51822.
- *
- * @details This file contains the declaration of the function that initializes the event decoder
- *          module and processes received events.
- */
-
-#ifndef BLE_RPC_EVT_DECODER_H__
-#define BLE_RPC_EVT_DECODER_H__
-
-#include <stdint.h>
-
-#ifndef SVCALL_AS_NORMAL_FUNCTION
-#error "The compiler define SVCALL_AS_NORMAL_FUNCTION is not defined."
-#endif
-
-
-/**@brief Function for pushing an encoded packet in the event decoder.
- *
- * @warning This function is not reentrant safe and should always be called from the same interrupt
- *          context.
- *
- * @param[in] p_event_packet       Pointer to the encoded event received.
- * @param[in] event_packet_length  Length of received packet.
- *
- * @retval NRF_SUCCESS       Upon success.
- * @retval NRF_ERROR_NO_MEM  Upon receive queue full.
- */
-uint32_t ble_rpc_event_pkt_received(uint8_t * p_event_packet, uint16_t event_packet_length);
-
-#endif // BLE_RPC_EVT_DECODER_H__
-
-/** @} **/
--- a/nordic/nrf-sdk/ble/rpc/ble_rpc_event_decoder_gap.h	Thu Jul 03 10:01:02 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
- *
- * The information contained herein is property of Nordic Semiconductor ASA.
- * Terms and conditions of usage are described in detail in NORDIC
- * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
- *
- * Licensees are granted free, non-transferable use of the information. NO
- * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
- * the file.
- *
- */
-
-/** @file
- *
- * @defgroup ble_rpc_evt_decoder_gap GAP Event Decoder
- * @{
- * @ingroup ble_sdk_lib_serialization
- *
- * @brief   Decoder for serialized GAP events from nRF51822.
- *
- * @details This file contains declarations of functions used for decoding GAP event packets
- *          received from the Connectivity Chip.
- *
- */
-
-#ifndef BLE_RPC_EVENT_DECODER_GAP_H__
-#define BLE_RPC_EVENT_DECODER_GAP_H__
-
-#include <stdint.h>
-#include "ble.h"
-
-/** @brief Function for decoding the length of a BLE GAP event.
- *
- * @param[in]   event_id        Event Id for the event to length decode.
- * @param[out]  p_event_length  The pointer for storing the decoded event length.
- */
-void ble_rpc_gap_evt_length_decode(uint8_t event_id, uint16_t * p_event_length);
-
-/** @brief Function for decoding a BLE GAP event.
- *
- * @param[out]  p_ble_evt       The pointer for storing the decoded event.
- * @param[in]   p_packet        The pointer to the encoded event.
- */
-void ble_rpc_gap_evt_packet_decode(ble_evt_t *           p_ble_evt,
-                                   uint8_t const * const p_packet);
-
-#endif // BLE_RPC_EVENT_DECODER_GAP_H__
-
-/** @} **/
--- a/nordic/nrf-sdk/ble/rpc/ble_rpc_event_decoder_gatts.h	Thu Jul 03 10:01:02 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
- *
- * The information contained herein is property of Nordic Semiconductor ASA.
- * Terms and conditions of usage are described in detail in NORDIC
- * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
- *
- * Licensees are granted free, non-transferable use of the information. NO
- * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
- * the file.
- *
- */
-
-/** @file
- *
- * @defgroup ble_rpc_evt_decoder_gatts GATTS Event Decoder
- * @{
- * @ingroup ble_sdk_lib_serialization
- *
- * @brief   Decoder for serialized GATT Server events from nRF51822.
- *
- * @details This file contains declarations of functions used for decoding GATTS event packets
- *          received from the Connectivity Chip.
- *
- */
-
-#ifndef BLE_RPC_EVENT_DECODER_GATTS_H__
-#define BLE_RPC_EVENT_DECODER_GATTS_H__
-
-#include <stdint.h>
-#include "ble.h"
-#include "ble_gatts.h"
-
-/** @brief Function for decoding the length of a BLE GATTS event. The decoded BLE GATTS event
- *         length will be returned in p_event_length.
- *
- * @param[in]   event_id        Event Id of the event, whose length is to be decoded.
- * @param[out]  p_event_length  The pointer for storing the decoded event length.
- * @param[in]   p_packet        The pointer to the encoded event.
- */
-void ble_rpc_gatts_evt_length_decode(uint8_t event_id, 
-                                     uint16_t * p_event_length,
-                                     uint8_t const * const p_packet);
-
-/** @brief Function for decoding a BLE GATTS event. The decoded BLE GATTS event will be returned in
- *         the memory pointed to by p_ble_evt.
- *
- * @param[out]  p_ble_evt       The pointer for storing the decoded event.
- * @param[in]   p_packet        The pointer to the encoded event.
- */
-void ble_rpc_gatts_evt_packet_decode(ble_evt_t * p_ble_evt,
-                                     uint8_t const * const p_packet);
-
-#endif // BLE_RPC_EVENT_DECODER_GATTS_H__
-
-/** @} **/
--- a/nordic/nrf-sdk/ble/rpc/ble_rpc_event_encoder.h	Thu Jul 03 10:01:02 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
- *
- * The information contained herein is property of Nordic Semiconductor ASA.
- * Terms and conditions of usage are described in detail in NORDIC
- * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
- *
- * Licensees are granted free, non-transferable use of the information. NO
- * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
- * the file.
- *
- */
-
-/** @file
- *
- * @defgroup ble_rpc_event_encoder Events Encoder
- * @{
- * @ingroup ble_sdk_lib_serialization
- *
- * @brief Event encoder for S110 SoftDevice serialization.
- *
- * @details This module provides a function for serializing S110 SoftDevice events.
- *
- */
-#ifndef BLE_RPC_EVENT_ENCODER_H__
-#define BLE_RPC_EVENT_ENCODER_H__
-
-#include "ble.h"
-
-/**@brief Function for encoding a @ref ble_evt_t. The function will pass the serialized byte stream to the
- *        transport layer after encoding.
- *
- * @param[in]   p_ble_evt    S110 SoftDevice event to serialize.
- */
-void ble_rpc_event_handle(ble_evt_t * p_ble_evt);
-
-#endif // BLE_RPC_EVENT_ENCODER_H__
-
-/** @} */
--- a/nordic/nrf-sdk/ble/rpc/ble_rpc_event_encoder_gap.h	Thu Jul 03 10:01:02 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
- *
- * The information contained herein is property of Nordic Semiconductor ASA.
- * Terms and conditions of usage are described in detail in NORDIC
- * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
- *
- * Licensees are granted free, non-transferable use of the information. NO
- * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
- * the file.
- *
- */
-
-/** @file
- *
- * @defgroup ble_rpc_event_encoder_gap GAP Event Encoder
- * @{
- * @ingroup ble_sdk_lib_serialization
- *
- * @brief Event encoder for S110 SoftDevice serialization.
- *
- * @details This module provides functions for serializing S110 SoftDevice events.
- *
- */
-#ifndef BLE_RPC_EVENT_ENCODER_GAP_H__
-#define BLE_RPC_EVENT_ENCODER_GAP_H__
-
-#include <stdint.h>
-#include <ble.h>
-
-/**@brief Function for encoding a @ref ble_evt_t GAP event.
- *
- * @param[in]   p_ble_evt    S110 SoftDevice event to serialize.
- * @param[out]  p_buffer     Pointer to a buffer for the encoded event.
- *
- * @return Number of bytes encoded.
- */
-uint32_t ble_rpc_evt_gap_encode(ble_evt_t * p_ble_evt, uint8_t * p_buffer);
-
-#endif // BLE_RPC_EVENT_ENCODER_GAP_H__
-
-/** @} */
--- a/nordic/nrf-sdk/ble/rpc/ble_rpc_event_encoder_gatts.h	Thu Jul 03 10:01:02 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
- *
- * The information contained herein is property of Nordic Semiconductor ASA.
- * Terms and conditions of usage are described in detail in NORDIC
- * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
- *
- * Licensees are granted free, non-transferable use of the information. NO
- * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
- * the file.
- *
- */
-
-/** @file
- *
- * @defgroup ble_rpc_event_encoder_gatts GATTS Events Encoder
- * @{
- * @ingroup ble_sdk_lib_serialization
- *
- * @brief Event encoder for S110 SoftDevice serialization.
- *
- * @details This module provides functions for serializing S110 SoftDevice events.
- *
- */
-#ifndef BLE_RPC_EVENT_ENCODER_GATTS_H__
-#define BLE_RPC_EVENT_ENCODER_GATTS_H__
-
-#include <stdint.h>
-#include <ble.h>
-
-/**@brief Function for encoding a @ref ble_evt_t GATTS event.
- *
- * @param[in]   p_ble_evt    S110 SoftDevice event to serialize.
- * @param[out]  p_buffer     Pointer to a buffer for the encoded event.
- *
- * @return Number of bytes encoded.
- */
-uint32_t ble_rpc_evt_gatts_encode(ble_evt_t * p_ble_evt, uint8_t * p_buffer);
-
-#endif // BLE_RPC_EVENT_ENCODER_GATTS_H__
-
-/** @} */
--- a/nordic/nrf-sdk/ble/rpc/ble_rpc_pkt_receiver.h	Thu Jul 03 10:01:02 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
- *
- * The information contained herein is property of Nordic Semiconductor ASA.
- * Terms and conditions of usage are described in detail in NORDIC
- * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
- *
- * Licensees are granted free, non-transferable use of the information. NO
- * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
- * the file.
- *
- */
-
-/** @file
- *
- * @defgroup rpc_pkt_receiver Packet Receiver
- * @{
- * @ingroup ble_sdk_lib_serialization
- *
- * @brief   This module is used for processing the Command Response packets and Event packets.
- */
-
-#ifndef BLE_RPC_PKT_RECEIVER_H__
-#define BLE_RPC_PKT_RECEIVER_H__
-
-#include <stdint.h>
-
-/**@brief Function for initializing the BLE S110 RPC Packet Receiver module.
- *
- * @return NRF_SUCCESS upon success, any other upon failure.
- */
-uint32_t ble_rpc_pkt_receiver_init(void);
-
-#endif
-
-/** @} **/
--- a/nordic/nrf-sdk/nordic_common.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/nordic_common.h	Mon Jul 07 13:43:31 2014 +0100
@@ -23,6 +23,7 @@
 #define SWAP(x) ((((x)&0xFF)<<8)|(((x)>>8)&0xFF))
 
 /** The upper 8 bits of a 16 bit value */
+//lint -emacro(572,MSB) // Suppress warning 572 "Excessive shift value"
 #define MSB(a) (((a) & 0xFF00) >> 8)
 /** The lower 8 bits (of a 16 bit value) */
 #define LSB(a) ((a) & 0xFF)
--- a/nordic/nrf-sdk/nrf_assert.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/nrf_assert.h	Mon Jul 07 13:43:31 2014 +0100
@@ -15,7 +15,6 @@
 #define NRF_ASSERT_H_
 
 #include <stdint.h>
-#include "nordic_global.h"
 
 #if defined(DEBUG_NRF) || defined(DEBUG_NRF_USER)
 
--- a/nordic/nrf-sdk/nrf_ecb.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/nrf_ecb.h	Mon Jul 07 13:43:31 2014 +0100
@@ -30,7 +30,6 @@
  */
 
 #include <stdint.h>
-#include "nordic_global.h"
 
 /**
  * Initialize and power on the ECB peripheral.
--- a/nordic/nrf-sdk/nrf_gpio.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/nrf_gpio.h	Mon Jul 07 13:43:31 2014 +0100
@@ -1,7 +1,6 @@
 #ifndef NRF_GPIO_H__
 #define NRF_GPIO_H__
 
-#include "nordic_global.h"
 #include "nrf51.h"
 #include "nrf51_bitfields.h"
 
@@ -91,7 +90,7 @@
         NRF_GPIO->PIN_CNF[pin_range_start] = (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos)
                                         | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos)
                                         | (GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos)
-                                        | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos)
+                                        | (GPIO_PIN_CNF_INPUT_Disconnect << GPIO_PIN_CNF_INPUT_Pos)
                                         | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);
     }
 }
@@ -136,7 +135,7 @@
     NRF_GPIO->PIN_CNF[pin_number] = (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos)
                                             | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos)
                                             | (GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos)
-                                            | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos)
+                                            | (GPIO_PIN_CNF_INPUT_Disconnect << GPIO_PIN_CNF_INPUT_Pos)
                                             | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);
 }
 
@@ -245,7 +244,19 @@
  */
 static __INLINE void nrf_gpio_pin_toggle(uint32_t pin_number)
 {
-    NRF_GPIO->OUT ^= (1UL << pin_number);
+    const uint32_t pin_bit   = 1UL << pin_number;
+    const uint32_t pin_state = ((NRF_GPIO->OUT >> pin_number) & 1UL);
+    
+    if (pin_state == 0)
+    {
+        // Current state low, set high.
+        NRF_GPIO->OUTSET = pin_bit;        
+    }
+    else
+    {
+        // Current state high, set low.    
+        NRF_GPIO->OUTCLR = pin_bit;       
+    }
 }
 
 /**
--- a/nordic/nrf-sdk/nrf_nvmc.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/nrf_nvmc.h	Mon Jul 07 13:43:31 2014 +0100
@@ -20,7 +20,6 @@
 #define NRF_NVMC_H__
 
 #include <stdint.h>
-#include "nordic_global.h"
 
 
 /**
--- a/nordic/nrf-sdk/nrf_temp.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/nrf_temp.h	Mon Jul 07 13:43:31 2014 +0100
@@ -13,7 +13,6 @@
 #ifndef NRF_TEMP_H__
 #define NRF_TEMP_H__
 
-#include "nordic_global.h"
 #include "nrf51.h"
 
 /**
--- a/nordic/nrf-sdk/s110/ble.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/s110/ble.h	Mon Jul 07 13:43:31 2014 +0100
@@ -18,7 +18,6 @@
 #ifndef BLE_H__
 #define BLE_H__
 
-#include "nordic_global.h"
 #include "ble_ranges.h"
 #include "ble_types.h"
 #include "ble_gap.h"
@@ -27,20 +26,31 @@
 #include "ble_gattc.h"
 #include "ble_gatts.h"
 
+/** @addtogroup BLE_COMMON_ENUMERATIONS Enumerations
+ * @{ */
+
 /**
  * @brief Common API SVC numbers.
  */
 enum BLE_COMMON_SVCS
 {
-  SD_BLE_EVT_GET  = BLE_SVC_BASE,       /**< Get an event from the pending events queue. */
+  SD_BLE_ENABLE = BLE_SVC_BASE,         /**< Enable and initialize the BLE stack */
+  SD_BLE_EVT_GET,                       /**< Get an event from the pending events queue. */
   SD_BLE_TX_BUFFER_COUNT_GET,           /**< Get the total number of available application transmission buffers from the stack. */
   SD_BLE_UUID_VS_ADD,                   /**< Add a Vendor Specific UUID. */
   SD_BLE_UUID_DECODE,                   /**< Decode UUID bytes. */
   SD_BLE_UUID_ENCODE,                   /**< Encode UUID bytes. */
-  SD_BLE_VERSION_GET,                   /**< Get the local version information (company id, LMP Version, LMP Subversion). */
+  SD_BLE_VERSION_GET,                   /**< Get the local version information (company id, Link Layer Version, Link Layer Subversion). */
   SD_BLE_USER_MEM_REPLY,                /**< User Memory Reply. */
+  SD_BLE_OPT_SET,                       /**< Set a BLE option. */
+  SD_BLE_OPT_GET,                       /**< Get a BLE option. */
 };
 
+/** @} */
+
+/** @addtogroup BLE_COMMON_DEFINES Defines
+ * @{ */
+
 /** @brief  Required pointer alignment for BLE Events.
 */
 #define BLE_EVTS_PTR_ALIGNMENT    4
@@ -55,6 +65,11 @@
 */
 #define BLE_UUID_VS_MAX_COUNT     10
 
+/** @} */
+
+/** @addtogroup BLE_COMMON_STRUCTURES Structures
+ * @{ */
+
 /**
  * @brief BLE Module Independent Event IDs.
  */
@@ -133,11 +148,40 @@
  */
 typedef struct
 {
-  uint8_t   version_number;             /**< LMP Version number for BT 4.0 spec is 6 (https://www.bluetooth.org/technical/assignednumbers/link_layer.htm). */
+  uint8_t   version_number;             /**< Link Layer Version number for BT 4.1 spec is 7 (https://www.bluetooth.org/en-us/specification/assigned-numbers/link-layer). */
   uint16_t  company_id;                 /**< Company ID, Nordic Semiconductor's company ID is 89 (0x0059) (https://www.bluetooth.org/apps/content/Default.aspx?doc_id=49708). */
-  uint16_t  subversion_number;          /**< LMP Sub Version number corresponds to the SoftDevice Config ID. */
+  uint16_t  subversion_number;          /**< Link Layer Sub Version number, corresponds to the SoftDevice Config ID or Firmware ID (FWID). */
 } ble_version_t;
 
+/**@brief Common BLE Option type, wrapping the module specific options. */
+typedef union
+{
+  ble_gap_opt_t     gap;            /**< GAP option, opt_id in BLE_GAP_OPT_* series. */
+} ble_opt_t;
+
+/**
+ * @brief BLE GATTS init options
+ */
+typedef struct
+{
+  ble_gatts_enable_params_t  gatts_enable_params; /**< GATTS init options @ref ble_gatts_enable_params_t. */  
+} ble_enable_params_t;
+
+/** @} */
+
+/** @addtogroup BLE_COMMON_FUNCTIONS Functions
+ * @{ */
+
+/**@brief Enable the bluetooth stack
+ *
+ * @param[in] p_ble_enable_params Pointer to ble_enable_params_t
+ *
+ * @details This call initializes the bluetooth stack, no other BLE related call can be called before this one has been executed.
+ *
+ * @return @ref NRF_SUCCESS BLE stack has been initialized successfully
+ * @return @ref NRF_ERROR_INVALID_ADDR Invalid or not sufficiently aligned pointer supplied.
+ */
+SVCALL(SD_BLE_ENABLE, uint32_t, sd_ble_enable(ble_enable_params_t * p_ble_enable_params));
 
 /**@brief Get an event from the pending events queue.
  *
@@ -295,6 +339,44 @@
  */
 SVCALL(SD_BLE_USER_MEM_REPLY, uint32_t, sd_ble_user_mem_reply(uint16_t conn_handle, ble_user_mem_block_t *p_block));
 
+
+/**@brief Set a BLE option.
+ *
+ * @details This call allows the application to set the value of an option.
+ *
+ * @param[in] opt_id Option ID.
+ * @param[in] p_opt Pointer to a ble_opt_t structure containing the option value.
+ *
+ * @retval ::NRF_SUCCESS  Option set successfully.
+ * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
+ * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
+ * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check parameter limits and constraints.
+ * @retval ::NRF_ERROR_INVALID_STATE Unable to set the parameter at this time.
+ * @retval ::NRF_ERROR_BUSY The stack is busy or the previous procedure has not completed.
+ */
+SVCALL(SD_BLE_OPT_SET, uint32_t, sd_ble_opt_set(uint32_t opt_id, ble_opt_t const *p_opt));
+
+
+/**@brief Get a BLE option.
+ *
+ * @details This call allows the application to retrieve the value of an option.
+ *
+ * @param[in] opt_id Option ID.
+ * @param[out] p_opt Pointer to a ble_opt_t structure to be filled in.
+ *
+ * @retval ::NRF_SUCCESS  Option retrieved successfully.
+ * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
+ * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
+ * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check parameter limits and constraints.
+ * @retval ::NRF_ERROR_INVALID_STATE Unable to retrieve the parameter at this time.
+ * @retval ::NRF_ERROR_BUSY The stack is busy or the previous procedure has not completed.
+ * @retval ::NRF_ERROR_NOT_SUPPORTED This option is not supported.
+ *
+ */
+SVCALL(SD_BLE_OPT_GET, uint32_t, sd_ble_opt_get(uint32_t opt_id, ble_opt_t *p_opt));
+
+/** @} */
+
 #endif /* BLE_H__ */
 
 /**
--- a/nordic/nrf-sdk/s110/ble_err.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/s110/ble_err.h	Mon Jul 07 13:43:31 2014 +0100
@@ -24,14 +24,14 @@
 #ifndef NRF_BLE_ERR_H__
 #define NRF_BLE_ERR_H__
 
-#include "nordic_global.h"
 #include "nrf_error.h"
 
 /* @defgroup BLE_ERRORS Error Codes
  * @{ */
-#define BLE_ERROR_INVALID_CONN_HANDLE    (NRF_ERROR_STK_BASE_NUM+0x001) /**< Invalid connection handle. */
-#define BLE_ERROR_INVALID_ATTR_HANDLE    (NRF_ERROR_STK_BASE_NUM+0x002) /**< Invalid attribute handle. */
-#define BLE_ERROR_NO_TX_BUFFERS          (NRF_ERROR_STK_BASE_NUM+0x003) /**< Buffer capacity exceeded. */
+#define BLE_ERROR_NOT_ENABLED            (NRF_ERROR_STK_BASE_NUM+0x001) /**< @ref sd_ble_enable has not been called. */
+#define BLE_ERROR_INVALID_CONN_HANDLE    (NRF_ERROR_STK_BASE_NUM+0x002) /**< Invalid connection handle. */
+#define BLE_ERROR_INVALID_ATTR_HANDLE    (NRF_ERROR_STK_BASE_NUM+0x003) /**< Invalid attribute handle. */
+#define BLE_ERROR_NO_TX_BUFFERS          (NRF_ERROR_STK_BASE_NUM+0x004) /**< Buffer capacity exceeded. */
 /** @} */
 
 
--- a/nordic/nrf-sdk/s110/ble_gap.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/s110/ble_gap.h	Mon Jul 07 13:43:31 2014 +0100
@@ -14,13 +14,15 @@
 #ifndef BLE_GAP_H__
 #define BLE_GAP_H__
 
-#include "nordic_global.h"
 #include "ble_types.h"
 #include "ble_ranges.h"
 #include "nrf_svc.h"
 
-/**
- * @brief GAP API SVC numbers.
+
+/**@addtogroup BLE_GAP_ENUMERATIONS Enumerations
+ * @{ */
+
+/**@brief GAP API SVC numbers.
  */
 enum BLE_GAP_SVCS
 {
@@ -43,53 +45,61 @@
   SD_BLE_GAP_AUTH_KEY_REPLY,                   /**< Reply with an authentication key. */
   SD_BLE_GAP_SEC_INFO_REPLY,                   /**< Reply with Security Information. */
   SD_BLE_GAP_CONN_SEC_GET,                     /**< Obtain connection security level. */
-  SD_BLE_GAP_RSSI_START,                       /**< Start reporting of changes in RSSI. */ 
-  SD_BLE_GAP_RSSI_STOP,                        /**< Stop reporting of changes in RSSI. */ 
+  SD_BLE_GAP_RSSI_START,                       /**< Start reporting of changes in RSSI. */
+  SD_BLE_GAP_RSSI_STOP,                        /**< Stop reporting of changes in RSSI. */
 };
-
+/**@} */
 
-/** @addtogroup BLE_GAP_DEFINES Defines
+/**@addtogroup BLE_GAP_DEFINES Defines
  * @{ */
 
-/** @defgroup BLE_ERRORS_GAP SVC return values specific to GAP
+/**@defgroup BLE_ERRORS_GAP SVC return values specific to GAP
  * @{ */
 #define BLE_ERROR_GAP_UUID_LIST_MISMATCH            (NRF_GAP_ERR_BASE + 0x000)  /**< UUID list does not contain an integral number of UUIDs. */
 #define BLE_ERROR_GAP_DISCOVERABLE_WITH_WHITELIST   (NRF_GAP_ERR_BASE + 0x001)  /**< Use of Whitelist not permitted with discoverable advertising. */
 #define BLE_ERROR_GAP_INVALID_BLE_ADDR              (NRF_GAP_ERR_BASE + 0x002)  /**< The upper two bits of the address do not correspond to the specified address type. */
-/** @} */
+/**@} */
 
 
-/** @defgroup BLE_GAP_ROLES GAP Roles
+/**@defgroup BLE_GAP_ROLES GAP Roles
  * @note Not explicitly used in peripheral API, but will be relevant for central API.
  * @{ */
 #define BLE_GAP_ROLE_INVALID     0x0            /**< Invalid Role. */
 #define BLE_GAP_ROLE_PERIPH      0x1            /**< Peripheral Role. */
 #define BLE_GAP_ROLE_CENTRAL     0x2            /**< Central Role. */
-/** @} */
+/**@} */
 
 
-/** @defgroup BLE_GAP_TIMEOUT_SOURCES GAP Timeout sources
+/**@defgroup BLE_GAP_TIMEOUT_SOURCES GAP Timeout sources
  * @{ */
 #define BLE_GAP_TIMEOUT_SRC_ADVERTISEMENT              0x00 /**< Advertisement timeout. */
 #define BLE_GAP_TIMEOUT_SRC_SECURITY_REQUEST           0x01 /**< Security request timeout. */
-/** @} */
+/**@} */
 
 
-/** @defgroup BLE_GAP_ADDR_TYPES GAP Address types
+/**@defgroup BLE_GAP_ADDR_TYPES GAP Address types
  * @{ */
 #define BLE_GAP_ADDR_TYPE_PUBLIC                        0x00 /**< Public address. */
 #define BLE_GAP_ADDR_TYPE_RANDOM_STATIC                 0x01 /**< Random Static address. */
 #define BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE     0x02 /**< Private Resolvable address. */
 #define BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE 0x03 /**< Private Non-Resolvable address. */
+/**@} */
+
+/**@defgroup BLE_GAP_ADDR_CYCLE_MODES GAP Address cycle modes
+ * @{ */
+#define BLE_GAP_ADDR_CYCLE_MODE_NONE      0x00 /**< Set addresses directly, no automatic address cycling. */
+#define BLE_GAP_ADDR_CYCLE_MODE_AUTO      0x01 /**< Automatically generate and update private addresses. */
 /** @} */
 
+/**@brief The default interval in seconds at which a private address is refreshed when address cycle mode is @ref BLE_GAP_ADDR_CYCLE_MODE_AUTO.  */
+#define BLE_GAP_DEFAULT_PRIVATE_ADDR_CYCLE_INTERVAL_S (60 * 15)
 
 /** @brief BLE address length. */
 #define BLE_GAP_ADDR_LEN            6
 
 
-/** @defgroup BLE_GAP_AD_TYPE_DEFINITIONS GAP Advertising and Scan Response Data format
- *  @note Found at https://www.bluetooth.org/Technical/AssignedNumbers/generic_access_profile.htm
+/**@defgroup BLE_GAP_AD_TYPE_DEFINITIONS GAP Advertising and Scan Response Data format
+ * @note Found at https://www.bluetooth.org/Technical/AssignedNumbers/generic_access_profile.htm
  * @{ */
 #define BLE_GAP_AD_TYPE_FLAGS                               0x01 /**< Flags for discoverability. */
 #define BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_MORE_AVAILABLE   0x02 /**< Partial list of 16 bit service UUIDs. */
@@ -109,15 +119,23 @@
 #define BLE_GAP_AD_TYPE_SLAVE_CONNECTION_INTERVAL_RANGE     0x12 /**< Slave Connection Interval Range. */
 #define BLE_GAP_AD_TYPE_SOLICITED_SERVICE_UUIDS_16BIT       0x14 /**< List of 16-bit Service Solicitation UUIDs. */
 #define BLE_GAP_AD_TYPE_SOLICITED_SERVICE_UUIDS_128BIT      0x15 /**< List of 128-bit Service Solicitation UUIDs. */
-#define BLE_GAP_AD_TYPE_SERVICE_DATA                        0x16 /**< Service Data. */
+#define BLE_GAP_AD_TYPE_SERVICE_DATA                        0x16 /**< Service Data - 16-bit UUID. */
 #define BLE_GAP_AD_TYPE_PUBLIC_TARGET_ADDRESS               0x17 /**< Public Target Address. */
 #define BLE_GAP_AD_TYPE_RANDOM_TARGET_ADDRESS               0x18 /**< Random Target Address. */
 #define BLE_GAP_AD_TYPE_APPEARANCE                          0x19 /**< Appearance. */
+#define BLE_GAP_AD_TYPE_ADVERTISING_INTERVAL                0x1A /**< Advertising Interval. */
+#define BLE_GAP_AD_TYPE_LE_BLUETOOTH_DEVICE_ADDRESS         0x1B /**< LE Bluetooth Device Address. */
+#define BLE_GAP_AD_TYPE_LE_ROLE                             0x1C /**< LE Role. */
+#define BLE_GAP_AD_TYPE_SIMPLE_PAIRING_HASH_C256            0x1D /**< Simple Pairing Hash C-256. */
+#define BLE_GAP_AD_TYPE_SIMPLE_PAIRING_RANDOMIZER_R256      0x1E /**< Simple Pairing Randomizer R-256. */
+#define BLE_GAP_AD_TYPE_SERVICE_DATA_32BIT_UUID             0x20 /**< Service Data - 32-bit UUID. */
+#define BLE_GAP_AD_TYPE_SERVICE_DATA_128BIT_UUID            0x21 /**< Service Data - 128-bit UUID. */
+#define BLE_GAP_AD_TYPE_3D_INFORMATION_DATA                 0x3D /**< 3D Information Data. */
 #define BLE_GAP_AD_TYPE_MANUFACTURER_SPECIFIC_DATA          0xFF /**< Manufacturer Specific Data. */
-/** @} */
+/**@} */
 
 
-/** @defgroup BLE_GAP_ADV_FLAGS GAP Advertisement Flags
+/**@defgroup BLE_GAP_ADV_FLAGS GAP Advertisement Flags
  * @{ */
 #define BLE_GAP_ADV_FLAG_LE_LIMITED_DISC_MODE         (0x01)   /**< LE Limited Discoverable Mode. */
 #define BLE_GAP_ADV_FLAG_LE_GENERAL_DISC_MODE         (0x02)   /**< LE General Discoverable Mode. */
@@ -126,71 +144,71 @@
 #define BLE_GAP_ADV_FLAG_LE_BR_EDR_HOST               (0x10)   /**< Simultaneous LE and BR/EDR, Host. */
 #define BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE   (BLE_GAP_ADV_FLAG_LE_LIMITED_DISC_MODE | BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED)   /**< LE Limited Discoverable Mode, BR/EDR not supported. */
 #define BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE   (BLE_GAP_ADV_FLAG_LE_GENERAL_DISC_MODE | BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED)   /**< LE General Discoverable Mode, BR/EDR not supported. */
-/** @} */
+/**@} */
 
 
-/** @defgroup BLE_GAP_ADV_INTERVALS GAP Advertising interval max and min
+/**@defgroup BLE_GAP_ADV_INTERVALS GAP Advertising interval max and min
  * @{ */
 #define BLE_GAP_ADV_INTERVAL_MIN        0x0020 /**< Minimum Advertising interval in 625 us units, i.e. 20 ms. */
 #define BLE_GAP_ADV_NONCON_INTERVAL_MIN 0x00A0 /**< Minimum Advertising interval in 625 us units for non connectable mode, i.e. 100 ms. */
 #define BLE_GAP_ADV_INTERVAL_MAX        0x4000 /**< Maximum Advertising interval in 625 us units, i.e. 10.24 s. */
- /** @}  */
+ /**@}  */
 
 
-/** @brief Maximum size of advertising data in octets. */
+/**@brief Maximum size of advertising data in octets. */
 #define  BLE_GAP_ADV_MAX_SIZE       31
 
 
-/** @defgroup BLE_GAP_ADV_TYPES GAP Advertising types
+/**@defgroup BLE_GAP_ADV_TYPES GAP Advertising types
  * @{ */
 #define BLE_GAP_ADV_TYPE_ADV_IND          0x00   /**< Connectable undirected. */
 #define BLE_GAP_ADV_TYPE_ADV_DIRECT_IND   0x01   /**< Connectable directed. */
 #define BLE_GAP_ADV_TYPE_ADV_SCAN_IND     0x02   /**< Scannable undirected. */
 #define BLE_GAP_ADV_TYPE_ADV_NONCONN_IND  0x03   /**< Non connectable undirected. */
-/** @} */
+/**@} */
 
 
-/** @defgroup BLE_GAP_ADV_FILTER_POLICIES GAP Advertising filter policies
+/**@defgroup BLE_GAP_ADV_FILTER_POLICIES GAP Advertising filter policies
  * @{ */
 #define BLE_GAP_ADV_FP_ANY                0x00   /**< Allow scan requests and connect requests from any device. */
 #define BLE_GAP_ADV_FP_FILTER_SCANREQ     0x01   /**< Filter scan requests with whitelist. */
 #define BLE_GAP_ADV_FP_FILTER_CONNREQ     0x02   /**< Filter connect requests with whitelist. */
 #define BLE_GAP_ADV_FP_FILTER_BOTH        0x03   /**< Filter both scan and connect requests with whitelist. */
-/** @} */
+/**@} */
 
 
-/** @defgroup BLE_GAP_ADV_TIMEOUT_VALUES GAP Advertising timeout values
+/**@defgroup BLE_GAP_ADV_TIMEOUT_VALUES GAP Advertising timeout values
  * @{ */
 #define BLE_GAP_ADV_TIMEOUT_LIMITED_MAX      180 /**< Maximum advertising time in limited discoverable mode (TGAP(lim_adv_timeout) = 180s in spec (Addendum 2)). */
 #define BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED  0 /**< Unlimited advertising in general discoverable mode. */
-/** @} */
+/**@} */
 
 
-/** @defgroup BLE_GAP_DISC_MODES GAP Discovery modes
+/**@defgroup BLE_GAP_DISC_MODES GAP Discovery modes
  * @{ */
 #define BLE_GAP_DISC_MODE_NOT_DISCOVERABLE  0x00   /**< Not discoverable discovery Mode. */
 #define BLE_GAP_DISC_MODE_LIMITED           0x01   /**< Limited Discovery Mode. */
 #define BLE_GAP_DISC_MODE_GENERAL           0x02   /**< General Discovery Mode. */
-/** @} */
+/**@} */
 
-/** @defgroup BLE_GAP_IO_CAPS GAP IO Capabilities
+/**@defgroup BLE_GAP_IO_CAPS GAP IO Capabilities
  * @{ */
 #define BLE_GAP_IO_CAPS_DISPLAY_ONLY      0x00   /**< Display Only. */
 #define BLE_GAP_IO_CAPS_DISPLAY_YESNO     0x01   /**< Display and Yes/No entry. */
 #define BLE_GAP_IO_CAPS_KEYBOARD_ONLY     0x02   /**< Keyboard Only. */
 #define BLE_GAP_IO_CAPS_NONE              0x03   /**< No I/O capabilities. */
 #define BLE_GAP_IO_CAPS_KEYBOARD_DISPLAY  0x04   /**< Keyboard and Display. */
-/** @} */
+/**@} */
 
 
-/** @defgroup BLE_GAP_AUTH_KEY_TYPES GAP Authentication Key Types
+/**@defgroup BLE_GAP_AUTH_KEY_TYPES GAP Authentication Key Types
  * @{ */
 #define BLE_GAP_AUTH_KEY_TYPE_NONE        0x00   /**< No key (may be used to reject). */
 #define BLE_GAP_AUTH_KEY_TYPE_PASSKEY     0x01   /**< 6-digit Passkey. */
 #define BLE_GAP_AUTH_KEY_TYPE_OOB         0x02   /**< Out Of Band data. */
-/** @} */
+/**@} */
 
-/** @defgroup BLE_GAP_SEC_STATUS GAP Security status
+/**@defgroup BLE_GAP_SEC_STATUS GAP Security status
  * @{ */
 #define BLE_GAP_SEC_STATUS_SUCCESS                0x00  /**< Successful parameters. */
 #define BLE_GAP_SEC_STATUS_TIMEOUT                0x01  /**< Procedure timed out. */
@@ -205,15 +223,15 @@
 #define BLE_GAP_SEC_STATUS_UNSPECIFIED            0x88  /**< Unspecified reason. */
 #define BLE_GAP_SEC_STATUS_REPEATED_ATTEMPTS      0x89  /**< Too little time elapsed since last attempt. */
 #define BLE_GAP_SEC_STATUS_INVALID_PARAMS         0x8A  /**< Invalid parameters. */
-/** @} */
+/**@} */
 
-/** @defgroup BLE_GAP_SEC_STATUS_SOURCES GAP Security status sources
+/**@defgroup BLE_GAP_SEC_STATUS_SOURCES GAP Security status sources
  * @{ */
 #define BLE_GAP_SEC_STATUS_SOURCE_LOCAL           0x00  /**< Local failure. */
 #define BLE_GAP_SEC_STATUS_SOURCE_REMOTE          0x01  /**< Remote failure. */
-/** @} */
+/**@} */
 
-/** @defgroup BLE_GAP_CP_LIMITS GAP Connection Parameters Limits
+/**@defgroup BLE_GAP_CP_LIMITS GAP Connection Parameters Limits
  * @{ */
 #define BLE_GAP_CP_MIN_CONN_INTVL_NONE           0xFFFF  /**< No new minimum connction interval specified in connect parameters. */
 #define BLE_GAP_CP_MIN_CONN_INTVL_MIN            0x0006  /**< Lowest mimimum connection interval permitted, in units of 1.25 ms, i.e. 7.5 ms. */
@@ -225,35 +243,38 @@
 #define BLE_GAP_CP_CONN_SUP_TIMEOUT_NONE         0xFFFF  /**< No new supervision timeout specified in connect parameters. */
 #define BLE_GAP_CP_CONN_SUP_TIMEOUT_MIN          0x000A  /**< Lowest supervision timeout permitted, in units of 10 ms, i.e. 100 ms. */
 #define BLE_GAP_CP_CONN_SUP_TIMEOUT_MAX          0x0C80  /**< Highest supervision timeout permitted, in units of 10 ms, i.e. 32 s. */
-/** @} */
+/**@} */
 
 
 /**@brief GAP device name maximum length. */
 #define BLE_GAP_DEVNAME_MAX_LEN           31
 
 
-/** @defgroup BLE_GAP_CONN_SEC_MODE_SET_MACROS GAP attribute security requirement setters
+/**@defgroup BLE_GAP_CONN_SEC_MODE_SET_MACROS GAP attribute security requirement setters
  *
  * See @ref ble_gap_conn_sec_mode_t.
  * @{ */
-/** @brief Set sec_mode pointed to by ptr to have no access rights.*/
+/**@brief Set sec_mode pointed to by ptr to have no access rights.*/
 #define BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(ptr)         do {(ptr)->sm = 0; (ptr)->lv = 0;} while(0)
-/** @brief Set sec_mode pointed to by ptr to require no protection, open link.*/
+/**@brief Set sec_mode pointed to by ptr to require no protection, open link.*/
 #define BLE_GAP_CONN_SEC_MODE_SET_OPEN(ptr)              do {(ptr)->sm = 1; (ptr)->lv = 1;} while(0)
-/** @brief Set sec_mode pointed to by ptr to require encryption, but no MITM protection.*/
+/**@brief Set sec_mode pointed to by ptr to require encryption, but no MITM protection.*/
 #define BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(ptr)       do {(ptr)->sm = 1; (ptr)->lv = 2;} while(0)
-/** @brief Set sec_mode pointed to by ptr to require encryption and MITM protection.*/
+/**@brief Set sec_mode pointed to by ptr to require encryption and MITM protection.*/
 #define BLE_GAP_CONN_SEC_MODE_SET_ENC_WITH_MITM(ptr)     do {(ptr)->sm = 1; (ptr)->lv = 3;} while(0)
-/** @brief Set sec_mode pointed to by ptr to require signing or encryption, no MITM protection needed.*/
+/**@brief Set sec_mode pointed to by ptr to require signing or encryption, no MITM protection needed.*/
 #define BLE_GAP_CONN_SEC_MODE_SET_SIGNED_NO_MITM(ptr)    do {(ptr)->sm = 2; (ptr)->lv = 1;} while(0)
-/** @brief Set sec_mode pointed to by ptr to require signing or encryption with MITM protection.*/
+/**@brief Set sec_mode pointed to by ptr to require signing or encryption with MITM protection.*/
 #define BLE_GAP_CONN_SEC_MODE_SET_SIGNED_WITH_MITM(ptr)  do {(ptr)->sm = 2; (ptr)->lv = 2;} while(0)
-/** @} */
+/**@} */
 
 
 /**@brief GAP Security Key Length. */
 #define BLE_GAP_SEC_KEY_LEN 16
 
+/**@brief GAP Passkey Length. */
+#define BLE_GAP_PASSKEY_LEN 6
+
 /**@brief Maximum amount of addresses in a whitelist. */
 #define BLE_GAP_WHITELIST_ADDR_MAX_COUNT (8)
 
@@ -262,14 +283,15 @@
  */
 #define BLE_GAP_WHITELIST_IRK_MAX_COUNT (8)
 
-/** @defgroup GAP_SEC_MODES GAP Security Modes
+/**@defgroup GAP_SEC_MODES GAP Security Modes
  * @{ */
 #define BLE_GAP_SEC_MODE 0x00 /**< No key (may be used to reject). */
-
-/** @} */
+/**@} */
 
+/**@} */
 
-/** @} */
+/**@addtogroup BLE_GAP_STRUCTURES Structures
+ * @{ */
 
 /**@brief Bluetooth Low Energy address. */
 typedef struct
@@ -312,16 +334,14 @@
 } ble_gap_conn_sec_mode_t;
 
 
-
 /**@brief GAP connection security status.*/
 typedef struct
 {
   ble_gap_conn_sec_mode_t sec_mode;           /**< Currently active security mode for this connection.*/
-  uint8_t                 encr_key_size;      /**< Length of currently active encryption key, 7 to 16 octets.*/
+  uint8_t                 encr_key_size;      /**< Length of currently active encryption key, 7 to 16 octets (only applicable for bonding procedures). */
 } ble_gap_conn_sec_t;
 
 
-
 /**@brief Identity Resolving Key. */
 typedef struct
 {
@@ -409,9 +429,7 @@
 } ble_gap_sign_info_t;
 
 
-
-/**
- * @brief GAP Event IDs.
+/**@brief GAP Event IDs.
  * Those IDs uniquely identify an event coming from the stack to the application.
  */
 enum BLE_GAP_EVTS
@@ -430,7 +448,20 @@
 };
 
 
-/** @brief Event data for connected event. */
+/**
+ * @brief GAP Option IDs.
+ * IDs that uniquely identify a GAP option.
+ */
+enum BLE_GAP_OPTS
+{
+  BLE_GAP_OPT_LOCAL_CONN_LATENCY  = BLE_GAP_OPT_BASE,    /**< Local connection latency. */
+  BLE_GAP_OPT_PASSKEY,                                   /**< Set passkey to be used during pairing. This option can be used to make the SoftDevice use an application provided passkey instead of generating a random passkey.*/
+  BLE_GAP_OPT_PRIVACY,                                   /**< Set or get custom IRK or custom private address cycle interval. */
+};
+/**@} */
+
+
+/**@brief Event data for connected event. */
 typedef struct
 {
   ble_gap_addr_t        peer_addr;              /**< Bluetooth address of the peer device. */
@@ -440,28 +471,28 @@
 } ble_gap_evt_connected_t;
 
 
-/** @brief Event data for disconnected event. */
+/**@brief Event data for disconnected event. */
 typedef struct
 {
   uint8_t reason;                               /**< HCI error code. */
 } ble_gap_evt_disconnected_t;
 
 
-/** @brief Event data for connection parameter update event. */
+/**@brief Event data for connection parameter update event. */
 typedef struct
 {
   ble_gap_conn_params_t conn_params;            /**<  GAP Connection Parameters. */
 } ble_gap_evt_conn_param_update_t;
 
 
-/** @brief Event data for security parameters request event. */
+/**@brief Event data for security parameters request event. */
 typedef struct
 {
   ble_gap_sec_params_t peer_params;             /**< Initiator Security Parameters. */
 } ble_gap_evt_sec_params_request_t;
 
 
-/** @brief Event data for securito info request event. */
+/**@brief Event data for security info request event. */
 typedef struct
 {
   ble_gap_addr_t peer_addr;                     /**< Bluetooth address of the peer device. */
@@ -472,22 +503,22 @@
 } ble_gap_evt_sec_info_request_t;
 
 
-/** @brief Event data for passkey display event. */
+/**@brief Event data for passkey display event. */
 typedef struct
 {
-  uint8_t passkey[6];                           /**< 6-digit passkey in ASCII ('0'-'9' digits only). */
+  uint8_t passkey[BLE_GAP_PASSKEY_LEN];         /**< 6-digit passkey in ASCII ('0'-'9' digits only). */
 } ble_gap_evt_passkey_display_t;
 
 
-/** @brief Event data for authentication key request event. */
+/**@brief Event data for authentication key request event. */
 typedef struct
 {
   uint8_t key_type;                             /**< See @ref BLE_GAP_AUTH_KEY_TYPES. */
 } ble_gap_evt_auth_key_request_t;
 
 
-/** @brief Security levels supported.
- *  @note See Bluetooth Specification Version 4.0 Volume 3, Chapter 10.
+/**@brief Security levels supported.
+ * @note See Bluetooth Specification Version 4.1 Volume 3, Part C, Chapter 10.
 */
 typedef struct
 {
@@ -497,7 +528,7 @@
 } ble_gap_sec_levels_t;
 
 
-/** @brief Keys that have been exchanged. */
+/**@brief Keys that have been exchanged. */
 typedef struct
 {
   uint8_t ltk       : 1;                        /**< Long Term Key. */
@@ -508,7 +539,7 @@
 } ble_gap_sec_keys_t;
 
 
-/** @brief Event data for authentication status event. */
+/**@brief Event data for authentication status event. */
 typedef struct
 {
   uint8_t               auth_status;            /**< Authentication status, see @ref BLE_GAP_SEC_STATUS. */
@@ -520,7 +551,7 @@
   struct periph_keys_t
   {
     ble_gap_enc_info_t    enc_info;             /**< Peripheral's Encryption information. */
-  } periph_keys;                                /**< Actual keys distributed from the Peripheral to the Central. */ 
+  } periph_keys;                                /**< Actual keys distributed from the Peripheral to the Central. */
   struct central_keys_t
   {
     ble_gap_irk_t         irk;                  /**< Central's IRK. */
@@ -529,28 +560,27 @@
 } ble_gap_evt_auth_status_t;
 
 
-/** @brief Event data for connection security update event. */
+/**@brief Event data for connection security update event. */
 typedef struct
 {
   ble_gap_conn_sec_t conn_sec;                  /**< Connection security level. */
 } ble_gap_evt_conn_sec_update_t;
 
 
-/** @brief Event data for timeout event. */
+/**@brief Event data for timeout event. */
 typedef struct
 {
   uint8_t src;                                  /**< Source of timeout event, see @ref BLE_GAP_TIMEOUT_SOURCES. */
 } ble_gap_evt_timeout_t;
 
 
-/** @brief Event data for advertisement report event. */
+/**@brief Event data for advertisement report event. */
 typedef struct
 {
   int8_t  rssi;                               /**< Received Signal Strength Indication in dBm. */
 } ble_gap_evt_rssi_changed_t;
 
 
-
 /**@brief GAP event callback event structure. */
 typedef struct
 {
@@ -573,16 +603,121 @@
 } ble_gap_evt_t;
 
 
+/**@brief Local connection latency option.
+ *
+ *         Local connection latency is a feature which enables the slave to improve
+ *         current consumption by ignoring the slave latency set by the peer. The
+ *         local connection latency can only be set to a multiple of the slave latency,
+ *         and cannot be longer than half of the supervision timeout.
+ *
+ *         Used with @ref sd_ble_opt_set to set the local connection latency. The
+ *         @ref sd_ble_opt_get is not supported for this option, but the actual
+ *         local connection latency (unless set to NULL) is set as a return parameter
+ *         when setting the option.
+ *
+ *  @note  The latency set will be truncated down to the closest slave latency event
+ *         multiple, or the nearest multiple before half of the supervision timeout.
+ *
+ *  @note  The local connection latency is default off, and needs to be set for new
+ *         connections and whenever the connection is updated.
+ *
+ *  @retval ::NRF_SUCCESS Set successfully.
+ *  @retval ::NRF_ERROR_NOT_SUPPORTED Get is not supported.
+ *  @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle parameter.
+ */
+typedef struct
+{
+  uint16_t   conn_handle;                       /**< Connection Handle */
+  uint16_t   requested_latency;                 /**< Requested local connection latency. */
+  uint16_t * p_actual_latency;                  /**< Pointer to storage for the actual local connection latency (can be set to NULL to skip return value). */
+} ble_gap_opt_local_conn_latency_t;
+
+
+/**@brief Passkey Option.
+ *
+ *        Structure containing the passkey to be used during pairing. This can be used with @ref
+ *        sd_ble_opt_set to make the SoftDevice use a pre-programmed passkey for authentication
+ *        instead of generating a random one.
+ *
+ * @note  @ref sd_ble_opt_get is not supported for this option.
+ *
+ */
+typedef struct
+{
+  uint8_t * p_passkey;                          /**< Pointer to 6-digit ASCII string (digit 0..9 only, no NULL termination) passkey to be used during pairing. If this is NULL, the SoftDevice will generate a random passkey if required.*/
+} ble_gap_opt_passkey_t;
+
+
+/**@brief Custom Privacy Options.
+ *
+ * @note The specified address cycle interval is used when the address cycle mode is
+ * @ref BLE_GAP_ADDR_CYCLE_MODE_AUTO. If 0 is given, the address will not be refreshed at any
+ * interval, and not at start of advertising. A new address can be generated manually by calling
+ * @ref sd_ble_gap_address_set with the same type again. The default interval is
+ * @ref BLE_GAP_DEFAULT_PRIVATE_ADDR_CYCLE_INTERVAL_S.
+ *
+ * @note If cycle mode is @ref BLE_GAP_ADDR_CYCLE_MODE_AUTO, the address will immediately be
+ * refreshed when this option is set.
+ */
+typedef struct
+{
+  ble_gap_irk_t * p_irk;        /**< When input: Pointer to custom IRK, or NULL to use/reset to the device's default IRK. When output: Pointer to where the current IRK is to be stored, or NULL to not read out the IRK. */
+  uint16_t        interval_s;   /**< When input: Custom private address cycle interval in seconds. When output: The current private address cycle interval. */
+} ble_gap_opt_privacy_t;
+
+
+/**@brief Option structure for GAP options. */
+typedef union
+{
+  ble_gap_opt_local_conn_latency_t local_conn_latency;  /**< Local connection latency. */
+  ble_gap_opt_passkey_t            passkey;             /**< Passkey to be used for pairing.*/
+  ble_gap_opt_privacy_t            privacy;             /**< Custom privacy options. */
+} ble_gap_opt_t;
+/**@} */
+
+
+/**@addtogroup BLE_GAP_FUNCTIONS Functions
+ * @{ */
+
 /**@brief Set local Bluetooth address.
  *
- * @param[in] p_addr Pointer to address structure.
+ * If the address cycle mode is @ref BLE_GAP_ADDR_CYCLE_MODE_AUTO, the address type is required to
+ * be @ref BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE or
+ * @ref BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE. The given address is ignored and the
+ * SoftDevice will generate a new private address automatically every time advertising is
+ * (re)started, and every @ref BLE_GAP_DEFAULT_PRIVATE_ADDR_CYCLE_INTERVAL_S seconds. If this API
+ * call is used again with the same parameters while advertising, the SoftDevice will immediately
+ * generate a new private address to replace the current address.
+ *
+ * If the application wishes to use a @ref BLE_GAP_ADDR_TYPE_PUBLIC or
+ * @ref BLE_GAP_ADDR_TYPE_RANDOM_STATIC address, the cycle mode must be
+ * @ref BLE_GAP_ADDR_CYCLE_MODE_NONE.
+ *
+ * If this API function is called while advertising, the softdevice will immediately update the
+ * advertising address without the need to stop advertising in the following cases:
+ *   - If the previously set address is of type @ref BLE_GAP_ADDR_TYPE_PUBLIC and the new address
+ *   is also of type @ref BLE_GAP_ADDR_TYPE_PUBLIC
+ *   - If the previously set address is not @ref BLE_GAP_ADDR_TYPE_PUBLIC and the new address is
+ *   also not @ref BLE_GAP_ADDR_TYPE_PUBLIC.
+ *
+ * If the address is changed from a @ref BLE_GAP_ADDR_TYPE_PUBLIC address to another type or from
+ * another type to a @ref BLE_GAP_ADDR_TYPE_PUBLIC address, the change will take effect the next
+ * time advertising is started.
+ *
+ * @note If the address cycle mode is @ref BLE_GAP_ADDR_CYCLE_MODE_NONE and the application is
+ *       using privacy, the application must take care to generate and set new private addresses
+ *       periodically to comply with the Privacy specification in Bluetooth Core Spec.
+ *
+ * @param[in] addr_cycle_mode Address cycle mode, see @ref BLE_GAP_ADDR_CYCLE_MODES.
+ * @param[in] p_addr          Pointer to address structure.
  *
  * @return @ref NRF_SUCCESS Address successfully set.
  * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
+ * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameters.
  * @return @ref BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid address.
  * @return @ref NRF_ERROR_BUSY The stack is busy, process pending events and retry.
  */
-SVCALL(SD_BLE_GAP_ADDRESS_SET, uint32_t, sd_ble_gap_address_set(ble_gap_addr_t const * const p_addr));
+SVCALL(SD_BLE_GAP_ADDRESS_SET, uint32_t, sd_ble_gap_address_set(uint8_t addr_cycle_mode, ble_gap_addr_t const * const p_addr));
 
 
 /**@brief Get local Bluetooth address.
@@ -599,9 +734,9 @@
  *
  * @note The format of the advertisement data will be checked by this call to ensure interoperability.
  *       Limitations imposed by this API call to the data provided include having a flags data type in the scan response data and
- *       duplicating the local name in the advertisement data and scan response data. 
+ *       duplicating the local name in the advertisement data and scan response data.
  *
- * @note: To clear the advertisement data and set it to a 0-length packet, simply provide a valid pointer (p_data/p_sr_data) with its corresponding 
+ * @note: To clear the advertisement data and set it to a 0-length packet, simply provide a valid pointer (p_data/p_sr_data) with its corresponding
  *        length (dlen/srdlen) set to 0.
  *
  * @note: The call will fail if p_data and p_sr_data are both NULL since this would have no effect.
@@ -863,7 +998,7 @@
 SVCALL(SD_BLE_GAP_CONN_SEC_GET, uint32_t, sd_ble_gap_conn_sec_get(uint16_t conn_handle, ble_gap_conn_sec_t * const p_conn_sec));
 
 
-/**@brief Start reporting the received signal strength to the application. 
+/**@brief Start reporting the received signal strength to the application.
  *
  * A new event is reported whenever the RSSI value changes, until @ref sd_ble_gap_rssi_stop is called.
  *
@@ -876,9 +1011,9 @@
 SVCALL(SD_BLE_GAP_RSSI_START, uint32_t, sd_ble_gap_rssi_start(uint16_t conn_handle));
 
 
-/**@brief Stop reporting the received singnal strength. 
+/**@brief Stop reporting the received singnal strength.
  *
- * An RSSI change detected before the call but not yet received by the application 
+ * An RSSI change detected before the call but not yet received by the application
  * may be reported after @ref sd_ble_gap_rssi_stop has been called.
  *
  * @param[in] conn_handle Connection handle.
@@ -888,6 +1023,7 @@
  * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  */
 SVCALL(SD_BLE_GAP_RSSI_STOP, uint32_t, sd_ble_gap_rssi_stop(uint16_t conn_handle));
+/**@} */
 
 #endif // BLE_GAP_H__
 
--- a/nordic/nrf-sdk/s110/ble_gatt.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/s110/ble_gatt.h	Mon Jul 07 13:43:31 2014 +0100
@@ -14,7 +14,6 @@
 #ifndef BLE_GATT_H__
 #define BLE_GATT_H__
 
-#include "nordic_global.h"
 #include "ble_types.h"
 #include "ble_ranges.h"
 
@@ -138,6 +137,9 @@
 
 /** @} */
 
+/** @addtogroup BLE_GATT_STRUCTURES Structures
+ * @{ */
+
 /**@brief GATT Characteristic Properties. */
 typedef struct
 {
@@ -161,6 +163,8 @@
 
 #endif // BLE_GATT_H__
 
+/** @} */
+
 /**
   @}
   @}
--- a/nordic/nrf-sdk/s110/ble_gattc.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/s110/ble_gattc.h	Mon Jul 07 13:43:31 2014 +0100
@@ -14,12 +14,13 @@
 #ifndef BLE_GATTC_H__
 #define BLE_GATTC_H__
 
-#include "nordic_global.h"
 #include "ble_gatt.h"
 #include "ble_types.h"
 #include "ble_ranges.h"
 #include "nrf_svc.h"
 
+/** @addtogroup BLE_GATTC_ENUMERATIONS Enumerations
+ * @{ */
 
 /**@brief GATTC API SVC numbers. */
 enum BLE_GATTC_SVCS
@@ -35,6 +36,8 @@
   SD_BLE_GATTC_HV_CONFIRM                                      /**< Handle Value Confirmation. */
 };
 
+/** @} */
+
 /** @addtogroup BLE_GATTC_DEFINES Defines
  * @{ */
 
@@ -48,6 +51,9 @@
 
 /** @} */
 
+/** @addtogroup BLE_GATTC_STRUCTURES Structures
+ * @{ */
+
 /**@brief Operation Handle Range. */
 typedef struct
 {
@@ -94,9 +100,9 @@
 /**@brief Write Parameters. */
 typedef struct
 {
-  uint8_t    write_op;                 /**< Write Operation to be performed, see BLE_GATT_WRITE_OPS. */
+  uint8_t    write_op;                 /**< Write Operation to be performed, see @ref BLE_GATT_WRITE_OPS. */
   uint16_t   handle;                   /**< Handle to the attribute to be written. */
-  uint16_t   offset;                   /**< Offset in bytes. */
+  uint16_t   offset;                   /**< Offset in bytes. @note For WRITE_CMD and WRITE_REQ, offset must be 0. */
   uint16_t   len;                      /**< Length of data in bytes. */
   uint8_t*   p_value;                  /**< Pointer to the value data. */
   uint8_t    flags;                    /**< Flags, see @ref BLE_GATT_EXEC_WRITE_FLAGS. */
@@ -226,7 +232,10 @@
     ble_gattc_evt_timeout_t                     timeout;                    /**< Timeout Event Parameters. */
   } params;                                                                 /**< Event Parameters. @note Only valid if @ref gatt_status == BLE_GATT_STATUS_SUCCESS. */
 } ble_gattc_evt_t;
+/** @} */
 
+/** @addtogroup BLE_GATTC_FUNCTIONS Functions
+ * @{ */
 
 /**@brief Initiate or continue a GATT Primary Service Discovery procedure.
  *
@@ -387,6 +396,7 @@
  */
 SVCALL(SD_BLE_GATTC_HV_CONFIRM, uint32_t, sd_ble_gattc_hv_confirm(uint16_t conn_handle, uint16_t handle));
 
+/** @} */
 
 #endif /* BLE_GATTC_H__ */
 
--- a/nordic/nrf-sdk/s110/ble_gatts.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/s110/ble_gatts.h	Mon Jul 07 13:43:31 2014 +0100
@@ -14,7 +14,6 @@
 #ifndef BLE_GATTS_H__
 #define BLE_GATTS_H__
 
-#include "nordic_global.h"
 #include "ble_types.h"
 #include "ble_ranges.h"
 #include "ble_l2cap.h"
@@ -22,6 +21,8 @@
 #include "ble_gatt.h"
 #include "nrf_svc.h"
 
+/** @addtogroup BLE_GATTS_ENUMERATIONS Enumerations
+ * @{ */
 
 /**
  * @brief GATTS API SVC numbers.
@@ -41,6 +42,7 @@
   SD_BLE_GATTS_SYS_ATTR_GET,                     /**< Get updated persistent system attributes after terminating a connection. */
 };
 
+/** @} */
 
 /** @addtogroup BLE_GATTS_DEFINES Defines
  * @{ */
@@ -110,6 +112,17 @@
 
 /** @} */
 
+/** @addtogroup BLE_GATTS_STRUCTURES Structures
+ * @{ */
+
+/**
+ * @brief BLE GATTS init options
+ */
+typedef struct
+{
+  uint8_t   service_changed:1;             /**< Include the Service Changed characteristic in the local attributes. */
+} ble_gatts_enable_params_t;
+
 /**@brief Attribute metadata. */
 typedef struct
 {
@@ -298,6 +311,10 @@
   } params;
 } ble_gatts_evt_t;
 
+/** @} */
+
+/** @addtogroup BLE_GATTS_FUNCTIONS Functions
+ * @{ */
 
 /**@brief Add a service declaration to the local server ATT table.
  *
@@ -386,7 +403,7 @@
  * @param[in] handle    Attribute handle.
  * @param[in] offset    Offset in bytes to write from.
  * @param[in,out] p_len Length in bytes to be written, length in bytes written after successful return.
- * @param[in] p_value   Pointer to a buffer (at least len bytes long) containing the desired attribute value.
+ * @param[in] p_value   Pointer to a buffer (at least len bytes long) containing the desired attribute value. If value is stored in user memory, only the attribute length is updated when p_value == NULL.
  *
  * @return @ref NRF_SUCCESS Successfully set the value of the attribute.
  * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
@@ -540,6 +557,7 @@
  */ 
 SVCALL(SD_BLE_GATTS_SYS_ATTR_GET, uint32_t, sd_ble_gatts_sys_attr_get(uint16_t conn_handle, uint8_t * const p_sys_attr_data, uint16_t* const p_len)); 
 
+/** @} */
 
 #endif // BLE_GATTS_H__
 
--- a/nordic/nrf-sdk/s110/ble_l2cap.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/s110/ble_l2cap.h	Mon Jul 07 13:43:31 2014 +0100
@@ -14,12 +14,14 @@
 #ifndef BLE_L2CAP_H__
 #define BLE_L2CAP_H__ 
 
-#include "nordic_global.h"
 #include "ble_types.h"
 #include "ble_ranges.h"
 #include "ble_err.h"
 #include "nrf_svc.h"
 
+/**@addtogroup BLE_L2CAP_ENUMERATIONS Enumerations
+ * @{ */
+
 /**@brief L2CAP API SVC numbers. */
 enum BLE_L2CAP_SVCS 
 {
@@ -28,6 +30,8 @@
   SD_BLE_L2CAP_TX                                  /**< Transmit a packet. */
 };
 
+/** @} */
+
 /**@addtogroup BLE_L2CAP_DEFINES Defines
  * @{ */
 
@@ -50,6 +54,9 @@
 
 /** @} */
 
+/**@addtogroup BLE_L2CAP_STRUCTURES Structures
+ * @{ */
+
 /**@brief Packet header format for L2CAP transmission. */
 typedef struct
 {
@@ -128,6 +135,7 @@
  */
 SVCALL(SD_BLE_L2CAP_TX, uint32_t, sd_ble_l2cap_tx(uint16_t conn_handle, ble_l2cap_header_t const * const p_header, uint8_t const * const p_data));
 
+/** @} */
 
 #endif // BLE_L2CAP_H__
 
--- a/nordic/nrf-sdk/s110/ble_ranges.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/s110/ble_ranges.h	Mon Jul 07 13:43:31 2014 +0100
@@ -64,6 +64,23 @@
 #define BLE_L2CAP_EVT_BASE     0x70
 #define BLE_L2CAP_EVT_LAST     0x8F       /* Total: 32.  */
 
+#define BLE_OPT_INVALID        0x00       /**< Invalid BLE Option. */
+
+#define BLE_OPT_BASE           0x01       /**< Common BLE Option base. */
+#define BLE_OPT_LAST           0x1F       /**< Total: 31. */
+
+#define BLE_GAP_OPT_BASE       0x20       /**< GAP BLE Option base. */
+#define BLE_GAP_OPT_LAST       0x3F       /**< Total: 32. */
+
+#define BLE_GATTC_OPT_BASE     0x40       /**< GATTC BLE Option base. */
+#define BLE_GATTC_OPT_LAST     0x5F       /**< Total: 32. */
+
+#define BLE_GATTS_OPT_BASE     0x60       /**< GATTS BLE Option base. */
+#define BLE_GATTS_OPT_LAST     0x7F       /**< Total: 32. */
+
+#define BLE_L2CAP_OPT_BASE     0x80       /**< L2CAP BLE Option base. */
+#define BLE_L2CAP_OPT_LAST     0x9F       /**< Total: 32.  */
+
 #endif /* BLE_RANGES_H__ */
 
 /**
--- a/nordic/nrf-sdk/s110/ble_types.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/s110/ble_types.h	Mon Jul 07 13:43:31 2014 +0100
@@ -18,7 +18,6 @@
 #define BLE_TYPES_H__
 
 #include <stdint.h>
-#include "nordic_global.h"
 
 /** @addtogroup BLE_COMMON_DEFINES Defines
  * @{ */
@@ -68,8 +67,8 @@
 /** @defgroup BLE_APPEARANCES Bluetooth Appearance values
  *  @note Retrieved from http://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.gap.appearance.xml
  * @{ */
-#define BLE_APPEARANCE_UNKNOWN                              0   /**< Unknown. */
-#define BLE_APPEARANCE_GENERIC_PHONE                        64  /**< Generic Phone. */
+#define BLE_APPEARANCE_UNKNOWN                                0 /**< Unknown. */
+#define BLE_APPEARANCE_GENERIC_PHONE                         64 /**< Generic Phone. */
 #define BLE_APPEARANCE_GENERIC_COMPUTER                     128 /**< Generic Computer. */
 #define BLE_APPEARANCE_GENERIC_WATCH                        192 /**< Generic Watch. */
 #define BLE_APPEARANCE_WATCH_SPORTS_WATCH                   193 /**< Watch: Sports Watch. */
@@ -108,6 +107,15 @@
 #define BLE_APPEARANCE_CYCLING_CADENCE_SENSOR              1155 /**< Cycling: Cadence Sensor. */
 #define BLE_APPEARANCE_CYCLING_POWER_SENSOR                1156 /**< Cycling: Power Sensor. */
 #define BLE_APPEARANCE_CYCLING_SPEED_CADENCE_SENSOR        1157 /**< Cycling: Speed and Cadence Sensor. */
+#define BLE_APPEARANCE_GENERIC_PULSE_OXIMETER              3136 /**< Generic Pulse Oximeter. */
+#define BLE_APPEARANCE_PULSE_OXIMETER_FINGERTIP            3137 /**< Fingertip (Pulse Oximeter subtype). */
+#define BLE_APPEARANCE_PULSE_OXIMETER_WRIST_WORN           3138 /**< Wrist Worn(Pulse Oximeter subtype). */
+#define BLE_APPEARANCE_GENERIC_WEIGHT_SCALE                3200 /**< Generic Weight Scale. */
+#define BLE_APPEARANCE_GENERIC_OUTDOOR_SPORTS_ACT          5184 /**< Generic Outdoor Sports Activity. */
+#define BLE_APPEARANCE_OUTDOOR_SPORTS_ACT_LOC_DISP         5185 /**< Location Display Device (Outdoor Sports Activity subtype). */
+#define BLE_APPEARANCE_OUTDOOR_SPORTS_ACT_LOC_AND_NAV_DISP 5186 /**< Location and Navigation Display Device (Outdoor Sports Activity subtype). */
+#define BLE_APPEARANCE_OUTDOOR_SPORTS_ACT_LOC_POD          5187 /**< Location Pod (Outdoor Sports Activity subtype). */
+#define BLE_APPEARANCE_OUTDOOR_SPORTS_ACT_LOC_AND_NAV_POD  5188 /**< Location and Navigation Pod (Outdoor Sports Activity subtype). */
 /** @} */
 
 /** @brief Set .type and .uuid fields of ble_uuid_struct to specified uuid value. */
@@ -135,6 +143,9 @@
 
 /** @} */
 
+/** @addtogroup BLE_TYPES_STRUCTURES Structures
+ * @{ */
+
 /** @brief 128 bit UUID values. */
 typedef struct
 { 
@@ -148,7 +159,7 @@
     uint8_t     type; /**< UUID type, see @ref BLE_UUID_TYPES. If type is BLE_UUID_TYPE_UNKNOWN, the value of uuid is undefined. */
 } ble_uuid_t;
 
-
+/** @} */
 
 #endif /* BLE_TYPES_H__ */
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nordic/nrf-sdk/s110/nrf_mbr.h	Mon Jul 07 13:43:31 2014 +0100
@@ -0,0 +1,155 @@
+/*
+ * Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is confidential property of Nordic Semiconductor. The use,
+ * copying, transfer or disclosure of such information is prohibited except by express written
+ * agreement with Nordic Semiconductor.
+ *
+ */
+/**
+  @defgroup nrf_mbr_api Master Boot Record API
+  @{
+     
+  @brief APIs for updating SoftDevice and BootLoader
+ 
+*/
+
+/* Header guard */
+#ifndef NRF_MBR_H__
+#define NRF_MBR_H__
+
+#include "nrf_svc.h"
+#include <stdint.h>
+
+
+/** @addtogroup NRF_MBR_DEFINES Defines
+ * @{ */
+
+/**@brief MBR SVC Base number. */
+#define MBR_SVC_BASE 0x18   
+/** @} */
+
+/** @addtogroup NRF_MBR_ENUMS Enumerations
+ * @{ */
+
+/**@brief nRF Master Boot Record API SVC numbers. */
+enum NRF_MBR_SVCS
+{
+  SD_MBR_COMMAND = MBR_SVC_BASE, /**< ::sd_mbr_command */
+};
+
+/**@brief Possible values for ::sd_mbr_command_t.command */
+enum NRF_MBR_COMMANDS
+{
+  SD_MBR_COMMAND_COPY_BL,               /**< Copy a new a new BootLoader. @see sd_mbr_command_copy_bl_t */
+  SD_MBR_COMMAND_COPY_SD,               /**< Copy a new SoftDevice. @see ::sd_mbr_command_copy_sd_t*/
+  SD_MBR_COMMAND_INIT_SD,               /**< Init forwarding interrupts to SD, and run reset function in SD*/
+  SD_MBR_COMMAND_COMPARE,               /**< This command works like memcmp. @see ::sd_mbr_command_compare_t*/
+  SD_MBR_COMMAND_VECTOR_TABLE_BASE_SET, /**< Start forwarding all exception to this address @see ::sd_mbr_command_vector_table_base_set_t*/
+};
+
+/** @} */
+
+/** @addtogroup NRF_MBR_TYPES Types
+ * @{ */
+
+/**@brief This command copies part of a new SoftDevice
+ * The destination area is erased before copying. 
+ * If dst is in the middle of a flash page, that whole flash page will be erased.
+ * If (dst+len) is in the middle of a flash page, that whole flash page will be erased.
+ * 
+ * The user of this function is responsible for setting the PROTENSET registers.
+ * 
+ * @retval ::NRF_SUCCESS indicates that the contents of the memory blocks where copied correctly.
+ * @retval ::NRF_ERROR_INTERNAL indicates that the contents of the memory blocks where not verified correctly after copying.
+ */
+typedef struct
+{
+  uint32_t *src;  /**< Pointer to the source of data to be copied.*/
+  uint32_t *dst;  /**< Pointer to the destination where the content is to be copied.*/
+  uint32_t len;   /**< Number of 32 bit words to copy. Must be a multiple of 256 words*/
+}sd_mbr_command_copy_sd_t;
+
+
+/**@brief This command works like memcmp, but takes the length in words.
+ *
+ * @retval ::NRF_SUCCESS indicates that the contents of both memory blocks are equal.
+ * @retval ::NRF_ERROR_NULL indicates that the contents of the memory blocks are not equal.
+ */
+typedef struct
+{
+  uint32_t *ptr1; /**< Pointer to block of memory */
+  uint32_t *ptr2; /**< Pointer to block of memory */
+  uint32_t len;   /**< Number of 32 bit words to compare*/
+}sd_mbr_command_compare_t;
+
+
+/**@brief This command copies a new BootLoader.
+ *  With this command, destination of BootLoader is always the address written in NRF_UICR->BOOTADDR.
+ *
+ *  Destination is erased by this function.
+ *  If (destination+bl_len) is in the middle of a flash page, that whole flash page will be erased.
+ *
+ *  This function will use PROTENSET to protect the flash that is not intended to be written.
+ * 
+ *  On Success, this function will not return. It will start the new BootLoader from reset-vector as normal.
+ *
+ * @retval ::NRF_ERROR_INVALID_STATE indicates that something was wrong.
+ * @retval ::NRF_ERROR_INTERNAL indicates an internal error that should not happen.
+ * @retval ::NRF_ERROR_FORBIDDEN if NRF_UICR->BOOTADDR is not set
+ * @retval ::NRF_ERROR_INVALID_LENGTH is invalid.
+ */
+typedef struct
+{
+  uint32_t *bl_src;  /**< Pointer to the source of the Bootloader to be be copied.*/
+  uint32_t bl_len;   /**< Number of 32 bit words to copy for BootLoader */
+}sd_mbr_command_copy_bl_t;
+
+/**@brief Sets the base address of the interrupt vector table for interrupts forwarded from the MBR
+ * 
+ * Once this function has been called, this address is where the MBR will start to forward interrupts to after a reset.
+ *
+ * To restore default forwarding thiss function should be called with @param address set to 0.
+ * The MBR will then start forwarding to interrupts to the adress in NFR_UICR->BOOTADDR or to the SoftDevice if the BOOTADDR is not set.
+ *
+ * @retval ::NRF_SUCCESS
+ */
+typedef struct
+{ 
+  uint32_t address; /**< The base address of the interrupt vector table for forwarded interrupts.*/
+}sd_mbr_command_vector_table_base_set_t;
+
+typedef struct
+{
+  uint32_t command;  /**< type of command to be issued see @ref NRF_MBR_COMMANDS. */
+  union 
+  {
+    sd_mbr_command_copy_sd_t copy_sd;  /**< Parameters for copy*/
+    sd_mbr_command_copy_bl_t copy_bl;  /**< Parameters for copy SoftDevice and BootLoader*/
+    sd_mbr_command_compare_t compare;  /**< Parameters for verify*/
+    sd_mbr_command_vector_table_base_set_t base_set; /**< Parameters for vector table base set.*/
+  } params;
+}sd_mbr_command_t;
+
+/** @} */
+
+/** @addtogroup NRF_MBR_FUNCTIONS Functions
+ * @{ */
+
+/**@brief Issue Master Boot Record commands
+ *
+ * Commands used when updating a SoftDevice and bootloader
+ *
+ * @param[in]  param Pointer to a struct describing the command
+ *
+ *@note for retvals see ::sd_mbr_command_copy_sd_t ::sd_mbr_command_copy_bl_t ::sd_mbr_command_compare_t
+
+*/
+SVCALL(SD_MBR_COMMAND, uint32_t, sd_mbr_command(sd_mbr_command_t* param));
+
+/** @} */
+#endif // NRF_MBR_H__
+
+/**
+  @}
+*/
--- a/nordic/nrf-sdk/s110/nrf_sdm.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/s110/nrf_sdm.h	Mon Jul 07 13:43:31 2014 +0100
@@ -18,7 +18,6 @@
 #ifndef NRF_SDM_H__
 #define NRF_SDM_H__
 
-#include "nordic_global.h"
 #include "nrf_svc.h"
 #include "nrf51.h"
 #include "nrf_soc.h"
@@ -28,7 +27,7 @@
  * @{ */
 
 /**@brief SoftDevice Manager SVC Base number. */
-#define SDM_SVC_BASE 0x10   
+#define SDM_SVC_BASE  (0x10)
 
 /** @} */
 
@@ -41,7 +40,7 @@
   SD_SOFTDEVICE_ENABLE = SDM_SVC_BASE, /**< ::sd_softdevice_enable */
   SD_SOFTDEVICE_DISABLE,               /**< ::sd_softdevice_disable */
   SD_SOFTDEVICE_IS_ENABLED,            /**< ::sd_softdevice_is_enabled */
-  SD_SOFTDEVICE_FORWARD_TO_APPLICATION,/**< ::sd_softdevice_forward_to_application */
+  SD_SOFTDEVICE_VECTOR_TABLE_BASE_SET, /**< ::sd_softdevice_vector_table_base_set */
   SVC_SDM_LAST                         /**< Placeholder for last SDM SVC */
 };
 
@@ -63,6 +62,11 @@
   NRF_CLOCK_LFCLKSRC_RC_250_PPM_2000MS_CALIBRATION,       /**< LFCLK RC oscillator, 2000ms calibration interval.*/
   NRF_CLOCK_LFCLKSRC_RC_250_PPM_4000MS_CALIBRATION,       /**< LFCLK RC oscillator, 4000ms calibration interval.*/
   NRF_CLOCK_LFCLKSRC_RC_250_PPM_8000MS_CALIBRATION,       /**< LFCLK RC oscillator, 8000ms calibration interval.*/
+  NRF_CLOCK_LFCLKSRC_RC_250_PPM_TEMP_1000MS_CALIBRATION,  /**< LFCLK RC oscillator. Temperature checked every 1000ms, if changed above a threshold, a calibration is done.*/
+  NRF_CLOCK_LFCLKSRC_RC_250_PPM_TEMP_2000MS_CALIBRATION,  /**< LFCLK RC oscillator. Temperature checked every 2000ms, if changed above a threshold, a calibration is done.*/
+  NRF_CLOCK_LFCLKSRC_RC_250_PPM_TEMP_4000MS_CALIBRATION,  /**< LFCLK RC oscillator. Temperature checked every 4000ms, if changed above a threshold, a calibration is done.*/
+  NRF_CLOCK_LFCLKSRC_RC_250_PPM_TEMP_8000MS_CALIBRATION,  /**< LFCLK RC oscillator. Temperature checked every 8000ms, if changed above a threshold, a calibration is done.*/
+  NRF_CLOCK_LFCLKSRC_RC_250_PPM_TEMP_16000MS_CALIBRATION, /**< LFCLK RC oscillator. Temperature checked every 16000ms, if changed above a threshold, a calibration is done.*/
 };
 
 /** @} */
@@ -144,16 +148,15 @@
  */
 SVCALL(SD_SOFTDEVICE_IS_ENABLED, uint32_t, sd_softdevice_is_enabled(uint8_t * p_softdevice_enabled));
 
-/**@brief Start forwarding interrupts to application.
+/**@brief Sets the base address of the interrupt vector table for interrupts forwarded from the SoftDevice
  * 
- * This function is only intended to be called when a bootloader is enabled is used.
- * The bootloader should call this right before it starts the application. 
- * It is recommended that all interrupt sources are off when this is called, 
- * or you could end up having interrupts in the application being executed before main() of the application.
+ * This function is only intended to be called when a bootloader is enabled.
  *
+ * @param[in] address The base address of the interrupt vector table for forwarded interrupts.
+ 
  * @retval ::NRF_SUCCESS
  */
-SVCALL(SD_SOFTDEVICE_FORWARD_TO_APPLICATION, uint32_t, sd_softdevice_forward_to_application(void)); 
+SVCALL(SD_SOFTDEVICE_VECTOR_TABLE_BASE_SET, uint32_t, sd_softdevice_vector_table_base_set(uint32_t address)); 
 
 /** @} */
 
--- a/nordic/nrf-sdk/s110/nrf_soc.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/s110/nrf_soc.h	Mon Jul 07 13:43:31 2014 +0100
@@ -7,11 +7,11 @@
  */
  
 /**
-  @defgroup nrf_soc_api SoC Library API
-  @{
-  
-  @brief APIs for the SoC library.
-  
+ * @defgroup nrf_soc_api SoC Library API
+ * @{
+ * 
+ * @brief APIs for the SoC library.
+ * 
 */
 
 #ifndef NRF_SOC_H__
@@ -19,7 +19,6 @@
 
 #include <stdint.h>
 #include <stdbool.h>
-#include "nordic_global.h"
 #include "nrf_svc.h"
 #include "nrf51.h"
 #include "nrf51_bitfields.h"
@@ -29,19 +28,32 @@
  * @{ */
 
 /**@brief The number of the lowest SVC number reserved for the SoC library. */
-#define SOC_SVC_BASE 0x20
+#define SOC_SVC_BASE               (0x20)
+#define SOC_SVC_BASE_NOT_AVAILABLE (0x23)
 
 /**@brief Guranteed time for application to process radio inactive notification. */
-#define NRF_RADIO_NOTIFICATION_INACTIVE_GUARANTEED_TIME_US   (62)
+#define NRF_RADIO_NOTIFICATION_INACTIVE_GUARANTEED_TIME_US  (62)
+
+/**@brief The minimum allowed timeslot extension time. */
+#define NRF_RADIO_MINIMUM_TIMESLOT_LENGTH_EXTENSION_TIME_US (200)
+
+#define SOC_ECB_KEY_LENGTH            (16)                       /**< ECB key length. */
+#define SOC_ECB_CLEARTEXT_LENGTH      (16)                       /**< ECB cleartext length. */
+#define SOC_ECB_CIPHERTEXT_LENGTH     (SOC_ECB_CLEARTEXT_LENGTH) /**< ECB ciphertext length. */
 
-#define SOC_ECB_KEY_LENGTH                   (16)                       /**< ECB key length. */
-#define SOC_ECB_CLEARTEXT_LENGTH             (16)                       /**< ECB cleartext length. */
-#define SOC_ECB_CIPHERTEXT_LENGTH            (SOC_ECB_CLEARTEXT_LENGTH) /**< ECB ciphertext length. */
+#define SD_EVT_IRQn                   (SWI2_IRQn)        /**< SoftDevice Event IRQ number. Used for both protocol events and SoC events. */
+#define SD_EVT_IRQHandler             (SWI2_IRQHandler)  /**< SoftDevice Event IRQ handler. Used for both protocol events and SoC events. */
+#define RADIO_NOTIFICATION_IRQn       (SWI1_IRQn)        /**< The radio notification IRQ number. */
+#define RADIO_NOTIFICATION_IRQHandler (SWI1_IRQHandler)  /**< The radio notification IRQ handler. */
 
-#define SD_EVT_IRQn                   (SWI2_IRQn)       /**< SoftDevice Event IRQ number. Used for both protocol events and SoC events. */
-#define SD_EVT_IRQHandler             (SWI2_IRQHandler) /**< SoftDevice Event IRQ handler. Used for both protocol events and SoC events. */
-#define RADIO_NOTIFICATION_IRQn       (SWI1_IRQn)       /**< The radio notification IRQ number. */
-#define RADIO_NOTIFICATION_IRQHandler (SWI1_IRQHandler) /**< The radio notification IRQ handler. */
+#define NRF_RADIO_LENGTH_MIN_US       (100)               /**< The shortest allowed radio timeslot, in microseconds. */
+#define NRF_RADIO_LENGTH_MAX_US       (100000)            /**< The longest allowed radio timeslot, in microseconds. */
+
+#define NRF_RADIO_DISTANCE_MAX_US         (128000000UL - 1UL) /**< The longest timeslot distance, in microseconds, allowed for the distance parameter (see @ref nrf_radio_request_normal_t) in the request. */
+
+#define NRF_RADIO_EARLIEST_TIMEOUT_MAX_US (128000000UL - 1UL) /**< The longest timeout, in microseconds, allowed when requesting the earliest possible timeslot. */
+
+#define NRF_RADIO_START_JITTER_US     (2)                 /**< The maximum jitter in NRF_RADIO_CALLBACK_SIGNAL_TYPE_START relative to the requested start time. */
 
 /** @} */
 
@@ -51,7 +63,10 @@
 /**@brief The SVC numbers used by the SVC functions in the SoC library. */
 enum NRF_SOC_SVCS
 {
-  SD_MUTEX_NEW = SOC_SVC_BASE,
+  SD_FLASH_PAGE_ERASE = SOC_SVC_BASE,
+  SD_FLASH_WRITE,
+  SD_FLASH_PROTECT,
+  SD_MUTEX_NEW = SOC_SVC_BASE_NOT_AVAILABLE,
   SD_MUTEX_ACQUIRE,
   SD_MUTEX_RELEASE,
   SD_NVIC_ENABLEIRQ,
@@ -94,14 +109,11 @@
   SD_PPI_GROUP_GET,
   SD_RADIO_NOTIFICATION_CFG_SET,
   SD_ECB_BLOCK_ENCRYPT,
-  SD_RESERVED1,
-  SD_RESERVED2,
-  SD_RESERVED3,
+  SD_RADIO_SESSION_OPEN,
+  SD_RADIO_SESSION_CLOSE,
+  SD_RADIO_REQUEST,
   SD_EVT_GET,
   SD_TEMP_GET,
-  SD_FLASH_ERASE_PAGE,
-  SD_FLASH_WRITE,
-  SD_FLASH_PROTECT,
   SVC_SOC_LAST
 };
 
@@ -170,15 +182,15 @@
 /**@brief SoC Events. */
 enum NRF_SOC_EVTS
 {
-  NRF_EVT_HFCLKSTARTED,                       /**< Event indicating that the HFCLK has started. */
-  NRF_EVT_POWER_FAILURE_WARNING,              /**< Event indicating that a power failure warning has occurred. */
-  NRF_EVT_FLASH_OPERATION_SUCCESS,            /**< Event indicating that the ongoing flash operation has completed successfully. */
-  NRF_EVT_FLASH_OPERATION_ERROR,              /**< Event indicating that the ongoing flash operation has timed out with an error. */
-  NRF_EVT_RESERVED1,
-  NRF_EVT_RESERVED2,
-  NRF_EVT_RESERVED3,
-  NRF_EVT_RESERVED4,
-  NRF_EVT_RESERVED5,
+  NRF_EVT_HFCLKSTARTED,                         /**< Event indicating that the HFCLK has started. */
+  NRF_EVT_POWER_FAILURE_WARNING,                /**< Event indicating that a power failure warning has occurred. */
+  NRF_EVT_FLASH_OPERATION_SUCCESS,              /**< Event indicating that the ongoing flash operation has completed successfully. */
+  NRF_EVT_FLASH_OPERATION_ERROR,                /**< Event indicating that the ongoing flash operation has timed out with an error. */
+  NRF_EVT_RADIO_BLOCKED,                        /**< Event indicating that a radio timeslot was blocked. */
+  NRF_EVT_RADIO_CANCELED,                       /**< Event indicating that a radio timeslot was canceled by SoftDevice. */
+  NRF_EVT_RADIO_SIGNAL_CALLBACK_INVALID_RETURN, /**< Event indicating that a radio signal callback handler return was invalid. */
+  NRF_EVT_RADIO_SESSION_IDLE,                   /**< Event indicating that a radio session is idle. */
+  NRF_EVT_RADIO_SESSION_CLOSED,                 /**< Event indicating that a radio session is closed. */
   NRF_EVT_NUMBER_OF_EVTS
 };
 
@@ -210,13 +222,116 @@
 /**@brief Radio notification types. */
 typedef uint8_t nrf_radio_notification_type_t;
 
+/** @brief The Radio signal callback types. */
+enum NRF_RADIO_CALLBACK_SIGNAL_TYPE
+{
+  NRF_RADIO_CALLBACK_SIGNAL_TYPE_START,            /**< This signal indicates the start of the radio timeslot. */
+  NRF_RADIO_CALLBACK_SIGNAL_TYPE_TIMER0,            /**< This signal indicates the NRF_TIMER0 interrupt. */
+  NRF_RADIO_CALLBACK_SIGNAL_TYPE_RADIO,             /**< This signal indicates the NRF_RADIO interrupt. */
+  NRF_RADIO_CALLBACK_SIGNAL_TYPE_EXTEND_FAILED,     /**< This signal indicates extend action failed. */
+  NRF_RADIO_CALLBACK_SIGNAL_TYPE_EXTEND_SUCCEEDED   /**< This signal indicates extend action succeeded. */
+};
+
+/** @brief The actions requested by the signal callback.
+ *
+ *  This code gives the SOC instructions about what action to take when the signal callback has
+ *  returned.
+ */
+enum NRF_RADIO_SIGNAL_CALLBACK_ACTION
+{
+  NRF_RADIO_SIGNAL_CALLBACK_ACTION_NONE,            /**< Return without action. */
+  NRF_RADIO_SIGNAL_CALLBACK_ACTION_EXTEND,          /**< Request an extension of the current timeslot (maximum execution time for this action is when the extension succeeded). */
+  NRF_RADIO_SIGNAL_CALLBACK_ACTION_END,             /**< End the current radio timeslot. */
+  NRF_RADIO_SIGNAL_CALLBACK_ACTION_REQUEST_AND_END  /**< Request a new radio timeslot and end the current timeslot. */
+};
+
+/**@brief Radio timeslot high frequency clock source configuration. */
+enum NRF_RADIO_HFCLK_CFG
+{
+  NRF_RADIO_HFCLK_CFG_DEFAULT,                      /**< Use the currently selected oscillator as HF clock source during the timeslot (i.e. the source is not specified). */
+  NRF_RADIO_HFCLK_CFG_FORCE_XTAL,                   /**< Force external crystal to be used as HF clock source during whole the timeslot. */
+};
+
+/** @brief Radio timeslot priorities. */
+enum NRF_RADIO_PRIORITY
+{
+  NRF_RADIO_PRIORITY_HIGH,                          /**< High (equal priority as the normal connection priority of the SoftDevice stack(s)). */
+  NRF_RADIO_PRIORITY_NORMAL,                        /**< Normal (equal priority as the priority of secondary activites of the SoftDevice stack(s)). */
+};
+
+/** @brief Radio timeslot request type. */
+enum NRF_RADIO_REQUEST_TYPE
+{
+  NRF_RADIO_REQ_TYPE_EARLIEST,                      /**< Request timeslot as early as possible. This should always be used for the first request in a session. */
+  NRF_RADIO_REQ_TYPE_NORMAL                         /**< Normal timeslot request. */
+};
+
+/** @brief Parameters for a request for a timeslot as early as possible. */
+typedef struct
+{
+  uint8_t       hfclk;                              /**< High frequency clock source, see @ref NRF_RADIO_HFCLK_CFG. */
+  uint8_t       priority;                           /**< The radio timeslot priority, see @ref NRF_RADIO_PRIORITY. */
+  uint32_t      length_us;                          /**< The radio timeslot length (in the range 100 to 100,000] microseconds). */
+  uint32_t      timeout_us;                         /**< Longest acceptable delay until the start of the requested timeslot (up to @ref NRF_RADIO_EARLIEST_TIMEOUT_MAX_US microseconds). */
+} nrf_radio_request_earliest_t;
+
+/** @brief Parameters for a normal radio request. */
+typedef struct
+{
+  uint8_t       hfclk;                              /**< High frequency clock source, see @ref NRF_RADIO_HFCLK_CFG. */
+  uint8_t       priority;                           /**< The radio timeslot priority, see @ref NRF_RADIO_PRIORITY. */
+  uint32_t      distance_us;                        /**< Distance from the start of the previous radio timeslot (up to @ref NRF_RADIO_DISTANCE_MAX_US microseconds). */
+  uint32_t      length_us;                          /**< The radio timeslot length (in the range [100..100,000] microseconds). */
+} nrf_radio_request_normal_t;
+
+/** @brief Radio request parameters. */
+typedef struct
+{
+  uint8_t                         request_type;     /**< Type of request, see @ref NRF_RADIO_REQUEST_TYPE. */
+  union
+  {
+    nrf_radio_request_earliest_t  earliest;         /**< Parameters for a request for a timeslot as early as possible. */
+    nrf_radio_request_normal_t    normal;           /**< Parameters for a normal radio request. */
+  } params;
+} nrf_radio_request_t;
+
+/**@brief Return parameters of the radio timeslot signal callback. */
+typedef struct
+{
+  uint8_t               callback_action;            /**< The action requested by the application when returning from the signal callback, see @ref NRF_RADIO_SIGNAL_CALLBACK_ACTION. */
+  union
+  {
+    struct
+    {
+      nrf_radio_request_t * p_next;                 /**< The request parameters for the next radio timeslot. */
+    } request;                                      /**< Additional parameters for return_code @ref NRF_RADIO_SIGNAL_CALLBACK_ACTION_REQUEST_AND_END. */
+    struct
+    {
+      uint32_t              length_us;              /**< Requested extension of the timeslot duration (microseconds) (for minimum time see @ref NRF_RADIO_MINIMUM_TIMESLOT_LENGTH_EXTENSION_TIME_US). */
+    } extend;                                       /**< Additional parameters for return_code @ref NRF_RADIO_SIGNAL_CALLBACK_ACTION_EXTEND. */
+  } params;
+} nrf_radio_signal_callback_return_param_t;
+
+/**@brief The radio signal callback type.
+ *
+ * @note In case of invalid return parameters, the radio timeslot will automatically end
+ *       immediately after returning from the signal callback and the
+ *       @ref NRF_EVT_RADIO_SIGNAL_CALLBACK_INVALID_RETURN event will be sent.
+ * @note The returned struct pointer must remain valid after the signal callback
+ *       function returns. For instance, this means that it must not point to a stack variable.
+ *
+ * @param[in] signal_type Type of signal, see @ref NRF_RADIO_CALLBACK_SIGNAL_TYPE.
+ *
+ * @return Pointer to structure containing action requested by the application.
+ */
+typedef nrf_radio_signal_callback_return_param_t * (*nrf_radio_signal_callback_t) (uint8_t signal_type);
 
 /**@brief AES ECB data structure */
 typedef struct
 {
-  uint8_t key[SOC_ECB_KEY_LENGTH];                /**< Encryption key. */
-  uint8_t cleartext[SOC_ECB_CLEARTEXT_LENGTH];    /**< Clear Text data. */
-  uint8_t ciphertext[SOC_ECB_CIPHERTEXT_LENGTH];  /**< Cipher Text data. */
+  uint8_t key[SOC_ECB_KEY_LENGTH];                  /**< Encryption key. */
+  uint8_t cleartext[SOC_ECB_CLEARTEXT_LENGTH];      /**< Clear Text data. */
+  uint8_t ciphertext[SOC_ECB_CIPHERTEXT_LENGTH];    /**< Cipher Text data. */
 } nrf_ecb_hal_data_t;
 
 /** @} */
@@ -386,12 +501,12 @@
 SVCALL(SD_RAND_APPLICATION_BYTES_AVAILABLE, uint32_t, sd_rand_application_bytes_available_get(uint8_t * p_bytes_available));
 
 /**@brief Get random bytes from the application pool.
-
-  @param[out]  p_buff  Pointer to unit8_t buffer for storing the bytes.
-  @param[in]   length  Number of bytes to take from pool and place in p_buff.
-
-  @retval ::NRF_SUCCESS The requested bytes were written to p_buff.
-  @retval ::NRF_ERROR_SOC_RAND_NOT_ENOUGH_VALUES No bytes were written to the buffer, because there were not enough bytes available.
+ *
+ * @param[out]  p_buff  Pointer to unit8_t buffer for storing the bytes.
+ * @param[in]   length  Number of bytes to take from pool and place in p_buff.
+ *
+ * @retval ::NRF_SUCCESS The requested bytes were written to p_buff.
+ * @retval ::NRF_ERROR_SOC_RAND_NOT_ENOUGH_VALUES No bytes were written to the buffer, because there were not enough bytes available.
 */
 SVCALL(SD_RAND_APPLICATION_GET_VECTOR, uint32_t, sd_rand_application_vector_get(uint8_t * p_buff, uint8_t length));
 
@@ -751,7 +866,7 @@
  * @retval ::NRF_ERROR_FORBIDDEN     Tried to erase a protected page.
  * @retval ::NRF_SUCCESS             The command was accepted.
  */
-SVCALL(SD_FLASH_ERASE_PAGE, uint32_t, sd_flash_page_erase(uint32_t page_number));
+SVCALL(SD_FLASH_PAGE_ERASE, uint32_t, sd_flash_page_erase(uint32_t page_number));
 
 
 /**@brief Flash Protection set
@@ -768,11 +883,76 @@
  */
 SVCALL(SD_FLASH_PROTECT, uint32_t, sd_flash_protect(uint32_t protenset0, uint32_t protenset1));
 
+/**@brief Opens a session for radio requests.
+ *
+ * @note Only one session can be open at a time.
+ * @note p_radio_signal_callback(NRF_RADIO_CALLBACK_SIGNAL_TYPE_START) will be called when the radio timeslot
+ *       starts. From this point the NRF_RADIO and NRF_TIMER0 peripherals can be freely accessed
+ *       by the application.
+ * @note p_radio_signal_callback(NRF_RADIO_CALLBACK_SIGNAL_TYPE_TIMER0) is called whenever the NRF_TIMER0
+ *       interrupt occurs.
+ * @note p_radio_signal_callback(NRF_RADIO_CALLBACK_SIGNAL_TYPE_RADIO) is called whenever the NRF_RADIO
+ *       interrupt occurs.
+ * @note p_radio_signal_callback() will be called at ARM interrupt priority level 0. This
+ *       implies that none of the sd_* API calls can be used from p_radio_signal_callback().
+ *
+ * @param[in] p_radio_signal_callback The signal callback.
+ *
+ * @retval ::NRF_ERROR_INVALID_ADDR p_radio_signal_callback is an invalid function pointer.
+ * @retval ::NRF_ERROR_BUSY If session cannot be opened.
+ * @retval ::NRF_ERROR_INTERNAL If a new session could not be opened due to an internal error.
+ * @retval ::NRF_SUCCESS Otherwise.
+ */
+ SVCALL(SD_RADIO_SESSION_OPEN, uint32_t, sd_radio_session_open(nrf_radio_signal_callback_t p_radio_signal_callback));
+
+/**@brief Closes a session for radio requests.
+ *
+ * @note Any current radio timeslot will be finished before the session is closed.
+ * @note If a radio timeslot is scheduled when the session is closed, it will be canceled.
+ * @note The application cannot consider the session closed until the NRF_EVT_RADIO_SESSION_CLOSED
+ *       event is received.
+ *
+ * @retval ::NRF_ERROR_FORBIDDEN If session not opened.
+ * @retval ::NRF_ERROR_BUSY If session is currently being closed.
+ * @retval ::NRF_SUCCESS Otherwise.
+ */
+ SVCALL(SD_RADIO_SESSION_CLOSE, uint32_t, sd_radio_session_close(void));
+
+ /**@brief Requests a radio timeslot.
+ *
+ * @note The timing of the radio timeslot is specified by p_request->distance_us. For the first
+ *       request in a session, p_request->distance_us is required to be 0 by convention, and
+ *       the timeslot is scheduled at the first possible opportunity. All following radio timeslots are
+ *       requested with a distance of p_request->distance_us measured from the start of the
+ *       previous radio timeslot.
+ * @note A too small p_request->distance_us will lead to a NRF_EVT_RADIO_BLOCKED event.
+ * @note Timeslots scheduled too close will lead to a NRF_EVT_RADIO_BLOCKED event.
+ * @note See the SoftDevice Specification for more on radio timeslot scheduling, distances and lengths.
+ * @note If an opportunity for the first radio timeslot is not found before 100ms after the call to this
+ *       function, it is not scheduled, and instead a NRF_EVT_RADIO_BLOCKED event is sent.
+ *       The application may then try to schedule the first radio timeslot again.
+ * @note Successful requests will result in nrf_radio_signal_callback_t(NRF_RADIO_CALLBACK_SIGNAL_TYPE_START).
+ *       Unsuccessful requests will result in a NRF_EVT_RADIO_BLOCKED event, see @ref NRF_SOC_EVTS.
+ * @note The jitter in the start time of the radio timeslots is +/- NRF_RADIO_START_JITTER_US us.
+ * @note The nrf_radio_signal_callback_t(NRF_RADIO_CALLBACK_SIGNAL_TYPE_START) call has a latency relative to the
+ *       specified radio timeslot start, but this does not affect the actual start time of the timeslot.
+ * @note NRF_TIMER0 is reset at the start of the radio timeslot, and is clocked at 1MHz from the high frequency
+ *       (16 MHz) clock source. If p_request->hfclk_force_xtal is true, the high frequency clock is 
+ *       guaranteed to be clocked from the external crystal.
+ * @note The SoftDevice will neither access the NRF_RADIO peripheral nor the NRF_TIMER0 peripheral
+ *       during the radio timeslot.
+ *
+ * @param[in] p_request Pointer to the request parameters.
+ *
+ * @retval ::NRF_ERROR_FORBIDDEN If session not opened or the session is not IDLE.
+ * @retval ::NRF_ERROR_INVALID_ADDR If the p_request pointer is invalid.
+ * @retval ::NRF_ERROR_INVALID_PARAM If the parameters of p_request are not valid.
+ * @retval ::NRF_SUCCESS Otherwise.
+ */
+ SVCALL(SD_RADIO_REQUEST, uint32_t, sd_radio_request(nrf_radio_request_t * p_request ));
 
 /** @} */
 
 #endif // NRF_SOC_H__
 
-/**
-  @}
- */
+/**@} */
--- a/nordic/nrf-sdk/s110/nrf_svc.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/s110/nrf_svc.h	Mon Jul 07 13:43:31 2014 +0100
@@ -1,8 +1,6 @@
 #ifndef NRF_SVC__
 #define NRF_SVC__
 
-#include "nordic_global.h"
-
 #ifdef SVCALL_AS_NORMAL_FUNCTION
 #define SVCALL(number, return_type, signature) return_type signature
 #else
--- a/nordic/nrf-sdk/s110/softdevice_assert.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/s110/softdevice_assert.h	Mon Jul 07 13:43:31 2014 +0100
@@ -14,7 +14,6 @@
 #define SOFTDEVICE_ASSERT_H_
 
 #include <stdint.h>
-#include "nordic_global.h"
 
 /** @brief This function handles assertions.
  *
--- a/nordic/nrf-sdk/sd_common/ant_stack_handler_types.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/sd_common/ant_stack_handler_types.h	Mon Jul 07 13:43:31 2014 +0100
@@ -14,7 +14,7 @@
  *
  * @defgroup ant_stack_handler_types Types definitions for ANT support in SoftDevice handler.
  * @{
- * @ingroup  app_common
+ * @ingroup  softdevice_handler
  * @brief    This file contains the declarations of types required for ANT stack support. These
  *           types will be defined when the preprocessor define ANT_STACK_SUPPORT_REQD is defined.
  */
@@ -25,7 +25,6 @@
 #ifdef ANT_STACK_SUPPORT_REQD
 
 #include <stdlib.h>
-#include "nordic_global.h"
 
 #define ANT_STACK_EVT_MSG_BUF_SIZE      32                                                /**< Size of ANT event message buffer. This will be provided to the SoftDevice while fetching an event. */
 #define ANT_STACK_EVT_STRUCT_SIZE       (sizeof(ant_evt_t))                               /**< Size of the @ref ant_evt_t structure. This will be used by the @ref softdevice_handler.h to internal event buffer size needed. */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nordic/nrf-sdk/sd_common/app_util_platform.h	Mon Jul 07 13:43:31 2014 +0100
@@ -0,0 +1,110 @@
+/* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ *
+ */
+
+/**@file
+ *
+ * @defgroup app_util_platform Utility Functions and Definitions (Platform)
+ * @{
+ * @ingroup app_common
+ *
+ * @brief Various types and definitions available to all applications when using SoftDevice.
+ */
+
+#ifndef APP_UTIL_PLATFORM_H__
+#define APP_UTIL_PLATFORM_H__
+
+#include <stdint.h>
+#include "compiler_abstraction.h"
+#include "nrf51.h"
+#include "app_error.h"
+
+/**@brief The interrupt priorities available to the application while the SoftDevice is active. */
+typedef enum
+{
+    APP_IRQ_PRIORITY_HIGH = 1,
+    APP_IRQ_PRIORITY_LOW  = 3
+} app_irq_priority_t;
+
+#define NRF_APP_PRIORITY_THREAD    4                    /**< "Interrupt level" when running in Thread Mode. */
+
+/**@cond NO_DOXYGEN */
+#define EXTERNAL_INT_VECTOR_OFFSET 16
+/**@endcond */
+
+#define PACKED(TYPE) __packed TYPE
+
+/**@brief Macro for entering a critical region.
+ *
+ * @note Due to implementation details, there must exist one and only one call to
+ *       CRITICAL_REGION_EXIT() for each call to CRITICAL_REGION_ENTER(), and they must be located
+ *       in the same scope.
+ */
+#define CRITICAL_REGION_ENTER()                                                             \
+    {                                                                                       \
+        uint8_t IS_NESTED_CRITICAL_REGION = 0;                                              \
+        uint32_t CURRENT_INT_PRI = current_int_priority_get();                              \
+        if (CURRENT_INT_PRI != APP_IRQ_PRIORITY_HIGH)                                       \
+        {                                                                                   \
+            uint32_t ERR_CODE = sd_nvic_critical_region_enter(&IS_NESTED_CRITICAL_REGION);  \
+            if (ERR_CODE == NRF_ERROR_SOFTDEVICE_NOT_ENABLED)                               \
+            {                                                                               \
+                __disable_irq();                                                            \
+            }                                                                               \
+            else                                                                            \
+            {                                                                               \
+                APP_ERROR_CHECK(ERR_CODE);                                                  \
+            }                                                                               \
+        }        
+    
+/**@brief Macro for leaving a critical region.
+ *
+ * @note Due to implementation details, there must exist one and only one call to
+ *       CRITICAL_REGION_EXIT() for each call to CRITICAL_REGION_ENTER(), and they must be located
+ *       in the same scope.
+ */
+#define CRITICAL_REGION_EXIT()                                                              \
+        if (CURRENT_INT_PRI != APP_IRQ_PRIORITY_HIGH)                                       \
+        {                                                                                   \
+            uint32_t ERR_CODE;                                                              \
+            __enable_irq();                                                                 \
+            ERR_CODE = sd_nvic_critical_region_exit(IS_NESTED_CRITICAL_REGION);             \
+            if (ERR_CODE != NRF_ERROR_SOFTDEVICE_NOT_ENABLED)                               \
+            {                                                                               \
+                APP_ERROR_CHECK(ERR_CODE);                                                  \
+            }                                                                               \
+        }                                                                                   \
+    }
+        
+/**@brief Function for finding the current interrupt level.
+ *
+ * @return   Current interrupt level.
+ * @retval   APP_IRQ_PRIORITY_HIGH    We are running in Application High interrupt level.
+ * @retval   APP_IRQ_PRIORITY_LOW     We are running in Application Low interrupt level.
+ * @retval   APP_IRQ_PRIORITY_THREAD  We are running in Thread Mode.
+ */
+static __INLINE uint8_t current_int_priority_get(void)
+{
+    uint32_t isr_vector_num = (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk);
+    if (isr_vector_num > 0)
+    {
+        int32_t irq_type = ((int32_t)isr_vector_num - EXTERNAL_INT_VECTOR_OFFSET);
+        return (NVIC_GetPriority((IRQn_Type)irq_type) & 0xFF);
+    }
+    else
+    {
+        return NRF_APP_PRIORITY_THREAD;
+    }
+}
+
+#endif // APP_UTIL_PLATFORM_H__
+
+/** @} */
--- a/nordic/nrf-sdk/sd_common/ble_stack_handler_types.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/sd_common/ble_stack_handler_types.h	Mon Jul 07 13:43:31 2014 +0100
@@ -14,7 +14,7 @@
  *
  * @defgroup ble_stack_handler_types Types definitions for BLE support in SoftDevice handler.
  * @{
- * @ingroup  app_common
+ * @ingroup  softdevice_handler
  * @brief    This file contains the declarations of types required for BLE stack support. These
  *           types will be defined when the preprocessor define BLE_STACK_SUPPORT_REQD is defined.
  */
@@ -22,8 +22,6 @@
 #ifndef BLE_STACK_HANDLER_TYPES_H__
 #define BLE_STACK_HANDLER_TYPES_H__
 
-#include "nordic_global.h"
-
 #ifdef BLE_STACK_SUPPORT_REQD
 
 #include <stdlib.h>
--- a/nordic/nrf-sdk/sd_common/softdevice_handler.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/sd_common/softdevice_handler.h	Mon Jul 07 13:43:31 2014 +0100
@@ -33,7 +33,7 @@
 #define SOFTDEVICE_HANDLER_H__
 
 #include <stdlib.h>
-#include "nordic_global.h"
+#include "nordic_common.h"
 #include "nrf_sdm.h"
 #include "app_error.h"
 #include "app_scheduler.h"
--- a/nordic/nrf-sdk/system_nrf51.h	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/nrf-sdk/system_nrf51.h	Mon Jul 07 13:43:31 2014 +0100
@@ -1,16 +1,32 @@
-/* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved.
+/* Copyright (c) 2013, Nordic Semiconductor ASA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *   * Redistributions of source code must retain the above copyright notice, this
+ *     list of conditions and the following disclaimer.
+ *
+ *   * Redistributions in binary form must reproduce the above copyright notice,
+ *     this list of conditions and the following disclaimer in the documentation
+ *     and/or other materials provided with the distribution.
  *
- * The information contained herein is property of Nordic Semiconductor ASA.
- * Terms and conditions of usage are described in detail in NORDIC
- * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *   * Neither the name of Nordic Semiconductor ASA nor the names of its
+ *     contributors may be used to endorse or promote products derived from
+ *     this software without specific prior written permission.
  *
- * Licensees are granted free, non-transferable use of the information. NO
- * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
- * the file.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  */
-
-
 #ifndef SYSTEM_NRF51_H
 #define SYSTEM_NRF51_H
 
@@ -19,7 +35,6 @@
 #endif
 
 #include <stdint.h>
-#include "nordic_global.h"
 
 
 extern uint32_t SystemCoreClock;    /*!< System Clock Frequency (Core Clock)  */
--- a/nordic/softdevice_handler.cpp	Thu Jul 03 10:01:02 2014 +0100
+++ b/nordic/softdevice_handler.cpp	Mon Jul 07 13:43:31 2014 +0100
@@ -21,7 +21,7 @@
 
 #if defined(ANT_STACK_SUPPORT_REQD) && defined(BLE_STACK_SUPPORT_REQD)
     #include "ant_interface.h"
-#elif defined(ANT_STACK_SUPPORT_REQD) 
+#elif defined(ANT_STACK_SUPPORT_REQD)
     #include "ant_interface.h"
 #elif defined(BLE_STACK_SUPPORT_REQD)
     #include "ble.h"
@@ -96,7 +96,7 @@
 
             // Pull event from SOC.
             err_code = sd_evt_get(&evt_id);
-            
+
             if (err_code == NRF_ERROR_NOT_FOUND)
             {
                 no_more_soc_evts = true;
@@ -205,7 +205,7 @@
     {
         return NRF_ERROR_INVALID_PARAM;
     }
-    
+
     // Check that buffer is correctly aligned.
     if (!is_word_aligned(p_evt_buffer))
     {
@@ -214,28 +214,58 @@
 
     m_evt_buffer = (uint8_t *)p_evt_buffer;
 #else
-    // The variable p_evt_buffer is not needed if neither BLE Stack nor ANT stack support is 
+    // The variable p_evt_buffer is not needed if neither BLE Stack nor ANT stack support is
     // required.
     UNUSED_PARAMETER(p_evt_buffer);
 #endif
 
-#if defined (BLE_STACK_SUPPORT_REQD)     
+#if defined (BLE_STACK_SUPPORT_REQD)
     m_ble_evt_buffer_size = evt_buffer_size;
 #else
     // The variable evt_buffer_size is not needed if BLE Stack support is NOT required.
     UNUSED_PARAMETER(evt_buffer_size);
 #endif
-    
+
     m_evt_schedule_func = evt_schedule_func;
 
     // Initialize SoftDevice.
-   
+
     err_code = sd_softdevice_enable(clock_source, softdevice_assertion_handler);
     if (err_code != NRF_SUCCESS)
     {
         return err_code;
     }
 
+    /**
+     * Using this call, the application can select whether to include the
+     * Service Changed characteristic in the GATT Server. The default in all
+     * previous releases has been to include the Service Changed characteristic,
+     * but this affects how GATT clients behave. Specifically, it requires
+     * clients to subscribe to this attribute and not to cache attribute handles
+     * between connections unless the devices are bonded. If the application
+     * does not need to change the structure of the GATT server attributes at
+     * runtime this adds unnecessary complexity to the interaction with peer
+     * clients. If the SoftDevice is enabled with the Service Changed
+     * Characteristics turned off, then clients are allowed to cache attribute
+     * handles making applications simpler on both sides.
+     */
+    ble_enable_params_t enableParams = {
+        .gatts_enable_params = {
+            .service_changed = 0
+        }
+    };
+    if ((err_code = sd_ble_enable(&enableParams)) != NRF_SUCCESS) {
+        return err_code;
+    }
+
+    ble_gap_addr_t addr;
+    if ((err_code = sd_ble_gap_address_get(&addr)) != NRF_SUCCESS) {
+        return err_code;
+    }
+    if ((err_code = sd_ble_gap_address_set(BLE_GAP_ADDR_CYCLE_MODE_NONE, &addr)) != NRF_SUCCESS) {
+        return err_code;
+    }
+
     m_softdevice_enabled = true;
     // Enable BLE event interrupt (interrupt priority has already been set by the stack).
     return sd_nvic_EnableIRQ(SWI2_IRQn);
@@ -245,7 +275,7 @@
 uint32_t softdevice_handler_sd_disable(void)
 {
     uint32_t err_code = sd_softdevice_disable();
- 
+
     m_softdevice_enabled = !(err_code == NRF_SUCCESS);
 
     return err_code;