From fef25e3fbc1b7f55359af14d6c6ad0f8a52c8ab3 Mon Sep 17 00:00:00 2001 From: Skjerve Date: Fri, 9 May 2014 10:39:48 +0200 Subject: [PATCH 1/4] Adding draft ANCS example --- .../examples/ble_ANCS_template/ANCS_setup.xml | 287 +++++++ .../alert_level_characteristic.h | 55 ++ .../BLE/examples/ble_ANCS_template/ancs.cpp | 50 ++ .../BLE/examples/ble_ANCS_template/ancs.h | 30 + .../ble_ANCS_template/ble_ANCS_template.ino | 727 ++++++++++++++++++ .../ble_ANCS_template/immediate_alert.cpp | 52 ++ .../ble_ANCS_template/immediate_alert.h | 63 ++ .../examples/ble_ANCS_template/link_loss.cpp | 58 ++ .../examples/ble_ANCS_template/link_loss.h | 74 ++ .../run_me_compile_xml_to_nRF8001_setup.bat | 6 + .../BLE/examples/ble_ANCS_template/services.h | 289 +++++++ .../ble_ANCS_template/services_lock.h | 293 +++++++ .../ble_ANCS_template/ublue_setup.gen.out.txt | 155 ++++ 13 files changed, 2139 insertions(+) create mode 100644 libraries/BLE/examples/ble_ANCS_template/ANCS_setup.xml create mode 100644 libraries/BLE/examples/ble_ANCS_template/alert_level_characteristic.h create mode 100644 libraries/BLE/examples/ble_ANCS_template/ancs.cpp create mode 100644 libraries/BLE/examples/ble_ANCS_template/ancs.h create mode 100644 libraries/BLE/examples/ble_ANCS_template/ble_ANCS_template.ino create mode 100644 libraries/BLE/examples/ble_ANCS_template/immediate_alert.cpp create mode 100644 libraries/BLE/examples/ble_ANCS_template/immediate_alert.h create mode 100644 libraries/BLE/examples/ble_ANCS_template/link_loss.cpp create mode 100644 libraries/BLE/examples/ble_ANCS_template/link_loss.h create mode 100644 libraries/BLE/examples/ble_ANCS_template/run_me_compile_xml_to_nRF8001_setup.bat create mode 100644 libraries/BLE/examples/ble_ANCS_template/services.h create mode 100644 libraries/BLE/examples/ble_ANCS_template/services_lock.h create mode 100644 libraries/BLE/examples/ble_ANCS_template/ublue_setup.gen.out.txt diff --git a/libraries/BLE/examples/ble_ANCS_template/ANCS_setup.xml b/libraries/BLE/examples/ble_ANCS_template/ANCS_setup.xml new file mode 100644 index 0000000..4db6a69 --- /dev/null +++ b/libraries/BLE/examples/ble_ANCS_template/ANCS_setup.xml @@ -0,0 +1,287 @@ + + + + 1 + nRF8001_Dx + + TX Power + 1804 + + TX Power Level + 2a07 + 0 + 0 + 1 + 1 + false + + false + false + false + false + false + + true + true + + 0 + + + + + Immediate Alert + 1802 + + Alert Level + 2a06 + + 0 + 1 + 1 + false + + true + false + false + false + false + + false + true + + 0 + + + + + Link Loss Alert + 1803 + + Alert Level + 2a06 + 0 + 0 + 1 + 1 + false + + false + true + false + false + false + + false + true + + 0 + + + + + Battery + 180f + + Battery Level + 2a19 + 64 + 0 + 1 + 1 + false + + false + false + true + false + false + + true + false + + 0 + + + + + Immediate Alert + 1802 + + Alert Level + 2a06 + 0 + 0 + 1 + 1 + false + + false + true + false + false + false + false + + true + + 0 + + + + + Device Information + 180a + + Hardware Revision String + 2a27 + + 0 + 9 + 2 + false + + false + false + false + false + false + + true + false + + 0 + + + + + ANCS + f431 + + Notification Source + 120d + + 0 + 20 + 1 + false + + false + false + false + true + false + false + + false + + 0 + + + + Control Point + d8f3 + + 0 + 20 + 1 + false + + false + false + true + false + false + false + + false + + 0 + + + + Data Source + c6e9 + + 0 + 20 + 1 + false + + false + false + false + true + false + false + + false + + 0 + + + + + ANCS Rusk + 0 + false + 3 + 0240 + 1 + 0 + 0 + 600 + 99 + 7 + 16 + 10 + 10 + 0 + 2c40 + 2c40 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 400 + 800 + 0 + 600 + true + true + + f431 + + + + 19 + 4002 + + + 18 + + + + + + 1 + 1 + 3 + 0 + 0 + 0 + 0 + true + + + 220 + 10 + 1000 + 0 + 0 + 1280 + + diff --git a/libraries/BLE/examples/ble_ANCS_template/alert_level_characteristic.h b/libraries/BLE/examples/ble_ANCS_template/alert_level_characteristic.h new file mode 100644 index 0000000..c3cfd97 --- /dev/null +++ b/libraries/BLE/examples/ble_ANCS_template/alert_level_characteristic.h @@ -0,0 +1,55 @@ +/* Copyright (c) 2014, Nordic Semiconductor ASA + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* Attention! +* To maintain compliance with Nordic Semiconductor ASA's Bluetooth profile +* qualification listings, this section of source code must not be modified. +*/ + +#ifndef ALERT_LEVEL_CHARACTERISTIC_H +#define ALERT_LEVEL_CHARACTERISTIC_H + +/** @file + * @brief + */ + +/** @defgroup alert_level_characteristic alert_level_characteristic +* @{ +* @ingroup services +* +* @brief alert_level_characteristic : defines possibles alert levels. +* +*/ + +/** Possible Alert Levels*/ +typedef enum alert_level_t +{ + /** No alert*/ + ALERT_LEVEL_NO_ALERT = 0, + /** Mild/moderate alert*/ + ALERT_LEVEL_MILD_ALERT = 1, + /** high alert*/ + ALERT_LEVEL_HIGH_ALERT = 2, +}alert_level_t; + +/** @} */ + +#endif // ALERT_LEVEL_CHARACTERISTIC_H diff --git a/libraries/BLE/examples/ble_ANCS_template/ancs.cpp b/libraries/BLE/examples/ble_ANCS_template/ancs.cpp new file mode 100644 index 0000000..d08be66 --- /dev/null +++ b/libraries/BLE/examples/ble_ANCS_template/ancs.cpp @@ -0,0 +1,50 @@ +/* Copyright (c) 2014, Nordic Semiconductor ASA + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include "services.h" +#include "lib_aci.h" +#include "ancs.h" + + +void ancs_evt_rcvd(uint8_t pipe_num, uint8_t *buffer) +{ + switch (pipe_num) + { + case PIPE_ANCS_NOTIFICATION_SOURCE_RX : + Serial.print(F("PIPE_ANCS_NOTIFICATION_SOURCE_RX: ")); + for(uint8_t counter = 0; counter <= 20; counter++) + { + Serial.write(buffer[counter]); //uint8_t file_name[20]; + } + Serial.println(); + break; + + case PIPE_ANCS_DATA_SOURCE_RX : + Serial.print(F("PIPE_ANCS_DATA_SOURCE_RX: ")); + for(uint8_t counter = 0; counter <= ACI_PIPE_RX_DATA_MAX_LEN; counter++) + { + Serial.write(buffer[counter]); //uint8_t file_name[20]; + } + Serial.println(); + break; + } +} diff --git a/libraries/BLE/examples/ble_ANCS_template/ancs.h b/libraries/BLE/examples/ble_ANCS_template/ancs.h new file mode 100644 index 0000000..ac46979 --- /dev/null +++ b/libraries/BLE/examples/ble_ANCS_template/ancs.h @@ -0,0 +1,30 @@ +/* Copyright (c) 2014, Nordic Semiconductor ASA + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + + #include + + /** @brief Function to handle reception of data for ANCS. + * @details Call this function on the ACI_EVT_DATA_RECEIVED event. This function checks if the data received is for ANCS. + * If so it prints the received data to the Serial interface. + * @param pipe_num Pipe which has received data. + * @param buffer Pointer to the received data. + */ + void ancs_evt_rcvd(uint8_t pipe_num, uint8_t *buffer); diff --git a/libraries/BLE/examples/ble_ANCS_template/ble_ANCS_template.ino b/libraries/BLE/examples/ble_ANCS_template/ble_ANCS_template.ino new file mode 100644 index 0000000..3a7569a --- /dev/null +++ b/libraries/BLE/examples/ble_ANCS_template/ble_ANCS_template.ino @@ -0,0 +1,727 @@ +/* Copyright (c) 2014, Nordic Semiconductor ASA + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + + +/** @defgroup ble_proximity_template ble_proximity_template +@{ +@ingroup projects +@brief Empty project that can be used as a template for new proximity projects. + +@details +This project is a firmware template for new proximity projects. +The project will run correctly in its current state. +With this project you have a starting point for adding your own application functionality. + +The following instructions describe the steps to be made on the Windows PC: + + -# Install the Master Control Panel on your computer. Connect the Master Emulator + (nRF2739) and make sure the hardware drivers are installed. + +-# You can use the nRF proximity app in the Apple iOS app store with this proximity template app + +Note: Pin #8 on Arduino -> PAIRING CLEAR pin: Connect to 3.3v to clear the pairing + + * + * Click on the "Serial Monitor" button on the Arduino IDE to reset the Arduino and start the application. + * The setup() function is called first and is called only once for each reset of the Arduino. + * The loop() function as the name implies is called in a loop. + * + * The setup() and loop() function are called in this way. + * main() + * { + * setup(); + * while(1) + * { + * loop(); + * } + * } + * + */ +#include +#include +#include + +#include +#include "immediate_alert.h" +#include "link_loss.h" +#include "ancs.h" +#include + +/** +Put the nRF8001 setup in the RAM of the nRF8001. +*/ +#include "services.h" +/** +Include the services_lock.h to put the setup in the OTP memory of the nRF8001. +This would mean that the setup cannot be changed once put in. +However this removes the need to do the setup of the nRF8001 on every reset. +*/ + + +#ifdef SERVICES_PIPE_TYPE_MAPPING_CONTENT + static services_pipe_type_mapping_t + services_pipe_type_mapping[NUMBER_OF_PIPES] = SERVICES_PIPE_TYPE_MAPPING_CONTENT; +#else + #define NUMBER_OF_PIPES 0 + static services_pipe_type_mapping_t * services_pipe_type_mapping = NULL; +#endif + +/* Store the setup for the nRF8001 in the flash of the AVR to save on RAM */ +static hal_aci_data_t setup_msgs[NB_SETUP_MESSAGES] PROGMEM = SETUP_MESSAGES_CONTENT; + +// aci_struct that will contain +// total initial credits +// current credit +// current state of the aci (setup/standby/active/sleep) +// open remote pipe pending +// close remote pipe pending +// Current pipe available bitmap +// Current pipe closed bitmap +// Current connection interval, slave latency and link supervision timeout +// Current State of the the GATT client (Service Discovery) +// Status of the bond (R) Peer address +static struct aci_state_t aci_state; + +/* +Temporary buffers for sending ACI commands +*/ +static hal_aci_evt_t aci_data; +static hal_aci_data_t aci_cmd; + +/* +We will store the bonding info for the nRF8001 in the EEPROM/Flash of the MCU to recover from a power loss situation +*/ +static bool bonded_first_time = true; + +/* +Timing change state variable +*/ +static bool timing_change_done = false; + + +/*************NOTE********** +Scroll to the end of the file and read the loop() and setup() functions. +The loop/setup functions is the equivalent of the main() function +*/ + +/* Define how assert should function in the BLE library */ +void __ble_assert(const char *file, uint16_t line) +{ + Serial.print("ERROR "); + Serial.print(file); + Serial.print(": "); + Serial.print(line); + Serial.print("\n"); + while(1); +} + +/* +Read the Dymamic data from the EEPROM and send then as ACI Write Dynamic Data to the nRF8001 +This will restore the nRF8001 to the situation when the Dynamic Data was Read out +*/ +aci_status_code_t bond_data_restore(aci_state_t *aci_stat, uint8_t eeprom_status, bool *bonded_first_time_state) +{ + aci_evt_t *aci_evt; + uint8_t eeprom_offset_read = 1; + uint8_t write_dyn_num_msgs = 0; + uint8_t len =0; + + + // Get the number of messages to write for the eeprom_status + write_dyn_num_msgs = eeprom_status & 0x7F; + + //Read from the EEPROM + while(1) + { + len = EEPROM.read(eeprom_offset_read); + eeprom_offset_read++; + aci_cmd.buffer[0] = len; + + for (uint8_t i=1; i<=len; i++) + { + aci_cmd.buffer[i] = EEPROM.read(eeprom_offset_read); + eeprom_offset_read++; + } + //Send the ACI Write Dynamic Data + if (!hal_aci_tl_send(&aci_cmd)) + { + Serial.println(F("bond_data_restore: Cmd Q Full")); + return ACI_STATUS_ERROR_INTERNAL; + } + + //Spin in the while loop waiting for an event + while (1) + { + if (lib_aci_event_get(aci_stat, &aci_data)) + { + aci_evt = &aci_data.evt; + + if (ACI_EVT_CMD_RSP != aci_evt->evt_opcode) + { + //Got something other than a command response evt -> Error + Serial.print(F("bond_data_restore: Expected cmd rsp evt. Got: 0x")); + Serial.println(aci_evt->evt_opcode, HEX); + return ACI_STATUS_ERROR_INTERNAL; + } + else + { + write_dyn_num_msgs--; + + //ACI Evt Command Response + if (ACI_STATUS_TRANSACTION_COMPLETE == aci_evt->params.cmd_rsp.cmd_status) + { + //Set the state variables correctly + *bonded_first_time_state = false; + aci_stat->bonded = ACI_BOND_STATUS_SUCCESS; + + delay(10); + + return ACI_STATUS_TRANSACTION_COMPLETE; + } + if (0 >= write_dyn_num_msgs) + { + //should have returned earlier + return ACI_STATUS_ERROR_INTERNAL; + } + if (ACI_STATUS_TRANSACTION_CONTINUE == aci_evt->params.cmd_rsp.cmd_status) + { + //break and write the next ACI Write Dynamic Data + break; + } + } + } + } + } +} + + +/* +This function is specific to the atmega328 +@params ACI Command Response Evt received from the Read Dynmaic Data +*/ +void bond_data_store(aci_evt_t *evt) +{ + static int eeprom_write_offset = 1; + + //Write it to non-volatile storage + EEPROM.write( eeprom_write_offset, evt->len -2 ); + eeprom_write_offset++; + + EEPROM.write( eeprom_write_offset, ACI_CMD_WRITE_DYNAMIC_DATA); + eeprom_write_offset++; + + for (uint8_t i=0; i< (evt->len-3); i++) + { + EEPROM.write( eeprom_write_offset, evt->params.cmd_rsp.params.padding[i]); + eeprom_write_offset++; + } +} + +bool bond_data_read_store(aci_state_t *aci_stat) +{ + /* + The size of the dynamic data for a specific Bluetooth Low Energy configuration + is present in the ublue_setup.gen.out.txt generated by the nRFgo studio as "dynamic data size". + */ + bool status = false; + aci_evt_t * aci_evt = NULL; + uint8_t read_dyn_num_msgs = 0; + + //Start reading the dynamic data + lib_aci_read_dynamic_data(); + read_dyn_num_msgs++; + + while (1) + { + if (true == lib_aci_event_get(aci_stat, &aci_data)) + { + aci_evt = &aci_data.evt; + + if (ACI_EVT_CMD_RSP != aci_evt->evt_opcode ) + { + //Got something other than a command response evt -> Error + status = false; + break; + } + + if (ACI_STATUS_TRANSACTION_COMPLETE == aci_evt->params.cmd_rsp.cmd_status) + { + //Store the contents of the command response event in the EEPROM + //(len, cmd, seq-no, data) : cmd ->Write Dynamic Data so it can be used directly + bond_data_store(aci_evt); + + //Set the flag in the EEPROM that the contents of the EEPROM is valid + EEPROM.write(0, 0x80|read_dyn_num_msgs ); + //Finished with reading the dynamic data + status = true; + + break; + } + + if (!(ACI_STATUS_TRANSACTION_CONTINUE == aci_evt->params.cmd_rsp.cmd_status)) + { + //We failed the read dymanic data + //Set the flag in the EEPROM that the contents of the EEPROM is invalid + EEPROM.write(0, 0x00); + + status = false; + break; + } + else + { + //Store the contents of the command response event in the EEPROM + // (len, cmd, seq-no, data) : cmd ->Write Dynamic Data so it can be used directly when re-storing the dynamic data + bond_data_store(aci_evt); + + //Read the next dynamic data message + lib_aci_read_dynamic_data(); + read_dyn_num_msgs++; + } + + } + } + return status; +} + + + + +void aci_loop() +{ + // We enter the if statement only when there is a ACI event available to be processed + if (lib_aci_event_get(&aci_state, &aci_data)) + { + aci_evt_t * aci_evt; + + aci_evt = &aci_data.evt; + switch(aci_evt->evt_opcode) + { + /** + As soon as you reset the nRF8001 you will get an ACI Device Started Event + */ + case ACI_EVT_DEVICE_STARTED: + { + aci_state.data_credit_total = aci_evt->params.device_started.credit_available; + switch(aci_evt->params.device_started.device_mode) + { + case ACI_DEVICE_SETUP: + /** + When the device is in the setup mode + */ + Serial.println(F("Evt Device Started: Setup")); + if (ACI_STATUS_TRANSACTION_COMPLETE != do_aci_setup(&aci_state)) + { + Serial.println(F("Error in ACI Setup")); + } + break; + + case ACI_DEVICE_STANDBY: + Serial.println(F("Evt Device Started: Standby")); + if (aci_evt->params.device_started.hw_error) + { + delay(20); //Magic number used to make sure the HW error event is handled correctly. + } + else + { + //Manage the bond in EEPROM of the AVR + { + uint8_t eeprom_status = 0; + eeprom_status = EEPROM.read(0); + if (eeprom_status != 0x00) + { + Serial.println(F("Previous Bond present. Restoring")); + Serial.println(F("Using existing bond stored in EEPROM.")); + Serial.println(F(" To delete the bond stored in EEPROM, connect Pin 6 to 3.3v and Reset.")); + Serial.println(F(" Make sure that the bond on the phone/PC is deleted as well.")); + //We must have lost power and restarted and must restore the bonding infromation using the ACI Write Dynamic Data + if (ACI_STATUS_TRANSACTION_COMPLETE == bond_data_restore(&aci_state, eeprom_status, &bonded_first_time)) + { + Serial.println(F("Bond restored successfully")); + } + else + { + Serial.println(F("Bond restore failed. Delete the bond and try again.")); + } + } + } + + // Start bonding as all proximity devices need to be bonded to be usable + if (ACI_BOND_STATUS_SUCCESS != aci_state.bonded) + { + lib_aci_bond(180/* in seconds */, 0x0050 /* advertising interval 50ms*/); + Serial.println(F("No Bond present in EEPROM.")); + Serial.println(F("Advertising started : Waiting to be connected and bonded")); + } + else + { + //connect to an already bonded device + //Use lib_aci_direct_connect for faster re-connections with PC, not recommended to use with iOS/OS X + lib_aci_connect(100/* in seconds */, 0x0020 /* advertising interval 20ms*/); + Serial.println(F("Already bonded : Advertising started : Waiting to be connected")); + } + } + break; + } + } + break; //ACI Device Started Event + + case ACI_EVT_CMD_RSP: + //If an ACI command response event comes with an error -> stop + if (ACI_STATUS_SUCCESS != aci_evt->params.cmd_rsp.cmd_status) + { + //ACI ReadDynamicData and ACI WriteDynamicData will have status codes of + //TRANSACTION_CONTINUE and TRANSACTION_COMPLETE + //all other ACI commands will have status code of ACI_STATUS_SCUCCESS for a successful command + Serial.print(F("ACI Command ")); + Serial.println(aci_evt->params.cmd_rsp.cmd_opcode, HEX); + Serial.print(F("Evt Cmd respone: Status ")); + Serial.println(aci_evt->params.cmd_rsp.cmd_status, HEX); + } + if (ACI_CMD_GET_DEVICE_VERSION == aci_evt->params.cmd_rsp.cmd_opcode) + { + //Store the version and configuration information of the nRF8001 in the Hardware Revision String Characteristic + lib_aci_set_local_data(&aci_state, PIPE_DEVICE_INFORMATION_HARDWARE_REVISION_STRING_SET, + (uint8_t *)&(aci_evt->params.cmd_rsp.params.get_device_version), sizeof(aci_evt_cmd_rsp_params_get_device_version_t)); + } + break; + + case ACI_EVT_CONNECTED: + Serial.println(F("Evt Connected")); + aci_state.data_credit_available = aci_state.data_credit_total; + timing_change_done = false; + /* + Get the device version of the nRF8001 and store it in the Hardware Revision String + */ + lib_aci_device_version(); + break; + + case ACI_EVT_BOND_STATUS: + aci_state.bonded = aci_evt->params.bond_status.status_code; + break; + + case ACI_EVT_PIPE_STATUS: + Serial.println(F("Evt Pipe Status")); + //Link is encrypted when the PIPE_LINK_LOSS_ALERT_ALERT_LEVEL_RX_ACK_AUTO is available + if ((false == timing_change_done) && + lib_aci_is_pipe_available(&aci_state, PIPE_LINK_LOSS_ALERT_ALERT_LEVEL_RX_ACK_AUTO)) + { + lib_aci_change_timing_GAP_PPCP(); // change the timing on the link as specified in the nRFgo studio -> nRF8001 conf. -> GAP. + // Used to increase or decrease bandwidth + timing_change_done = true; + } + // The pipe will be available only in an encrpyted link to the phone + if ((ACI_BOND_STATUS_SUCCESS == aci_state.bonded) && + (lib_aci_is_pipe_available(&aci_state, PIPE_LINK_LOSS_ALERT_ALERT_LEVEL_RX_ACK_AUTO)) && + (lib_aci_is_pipe_available(&aci_state, PIPE_IMMEDIATE_ALERT_ALERT_LEVEL_RX))) + { + //Note: This may be called multiple times after the Arduino has connected to the right phone + //Serial.println(F("phone Detected.")); + //Serial.println(F("Do more stuff here. when your phone is detected")); + } + + //Open ANCS Notification Source when possible + if (lib_aci_is_pipe_closed(&aci_state, PIPE_ANCS_NOTIFICATION_SOURCE_RX)) + { + Serial.println(F("Opening PIPE_ANCS_NOTIFICATION_SOURCE_RX")); + lib_aci_open_remote_pipe(&aci_state, PIPE_ANCS_NOTIFICATION_SOURCE_RX); + } + //else if (lib_aci_is_pipe_available(&aci_state, PIPE_ANCS_NOTIFICATION_SOURCE_RX)) + //{ + //Serial.println(F("PIPE_ANCS_NOTIFICATION_SOURCE_RX is available")); + //} + + //Open ANCS Data Source when it is available + else if (lib_aci_is_pipe_closed(&aci_state, PIPE_ANCS_DATA_SOURCE_RX)) + { + Serial.println(F("Opening PIPE_ANCS_DATA_SOURCE_RX")); + lib_aci_open_remote_pipe(&aci_state, PIPE_ANCS_DATA_SOURCE_RX); + } + else if ((lib_aci_is_pipe_available(&aci_state, PIPE_ANCS_DATA_SOURCE_RX)) + && (lib_aci_is_pipe_available(&aci_state, PIPE_ANCS_NOTIFICATION_SOURCE_RX))) + { + //Serial.println(F("PIPE_ANCS_DATA_SOURCE_RX is available")); + Serial.println(F("ANCS notification pipes are enabled")); + } + + break; + + case ACI_EVT_TIMING: + Serial.println(F("Evt link connection interval changed")); + //Disconnect as soon as we are bonded and required pipes are available + //This is used to store the bonding info on disconnect and then re-connect to verify the bond + if((ACI_BOND_STATUS_SUCCESS == aci_state.bonded) && + (true == bonded_first_time) && + (GAP_PPCP_MAX_CONN_INT >= aci_state.connection_interval) && + (GAP_PPCP_MIN_CONN_INT <= aci_state.connection_interval) && //Timing change already done: Provide time for the the peer to finish + (lib_aci_is_pipe_available(&aci_state, PIPE_LINK_LOSS_ALERT_ALERT_LEVEL_RX_ACK_AUTO)) && + (lib_aci_is_pipe_available(&aci_state, PIPE_IMMEDIATE_ALERT_ALERT_LEVEL_RX))) + { + lib_aci_disconnect(&aci_state, ACI_REASON_TERMINATE); + } + break; + + case ACI_EVT_DISCONNECTED: + Serial.println(F("Evt Disconnected. Link Lost or Advertising timed out")); + if (ACI_BOND_STATUS_SUCCESS == aci_state.bonded) + { + if (ACI_STATUS_EXTENDED == aci_evt->params.disconnected.aci_status) //Link was disconnected + { + if (bonded_first_time) + { + bonded_first_time = false; + //Store away the dynamic data of the nRF8001 in the Flash or EEPROM of the MCU + // so we can restore the bond information of the nRF8001 in the event of power loss + if (bond_data_read_store(&aci_state)) + { + Serial.println(F("Dynamic Data read and stored successfully")); + } + } + if (0x24 == aci_evt->params.disconnected.btle_status) + { + //The error code appears when phone or Arduino has deleted the pairing/bonding information. + //The Arduino stores the bonding information in EEPROM, which is deleted only by + // the user action of connecting pin 6 to 3.3v and then followed by a reset. + //While deleting bonding information delete on the Arduino and on the phone. + Serial.println(F("phone/Arduino has deleted the bonding/pairing information")); + } + + proximity_disconect_evt_rcvd (aci_evt->params.disconnected.btle_status); + } + lib_aci_connect(180/* in seconds */, 0x0100 /* advertising interval 100ms*/); + Serial.println(F("Using existing bond stored in EEPROM.")); + Serial.println(F(" To delete the bond stored in EEPROM, connect Pin 6 to 3.3v and Reset.")); + Serial.println(F(" Make sure that the bond on the phone/PC is deleted as well.")); + Serial.println(F("Advertising started. Connecting.")); + } + else + { + //There is no existing bond. Try to bond. + lib_aci_bond(180/* in seconds */, 0x0050 /* advertising interval 50ms*/); + Serial.println(F("Advertising started. Bonding.")); + } + break; + + case ACI_EVT_DATA_RECEIVED: + Serial.print(F("Pipe #")); + Serial.print(aci_evt->params.data_received.rx_data.pipe_number, DEC); + Serial.print(F("-> ")); + Serial.println(aci_evt->params.data_received.rx_data.aci_data[0], DEC); + link_loss_pipes_updated_evt_rcvd(aci_evt->params.data_received.rx_data.pipe_number, + &aci_evt->params.data_received.rx_data.aci_data[0]); + //ancs_evt_rcvd(aci_evt->params.data_received.rx_data.pipe_number, + // &aci_evt->params.data_received.rx_data.aci_data[0]); + if (PIPE_ANCS_NOTIFICATION_SOURCE_RX==aci_evt->params.data_received.rx_data.pipe_number) + { + Serial.print(F("PIPE_ANCS_NOTIFICATION_SOURCE_RX: ")); + for(uint8_t counter = 0; counter <= 20; counter++) + { + Serial.write(aci_evt->params.data_received.rx_data.aci_data[counter]); //uint8_t file_name[20]; + } + Serial.println(); + } + else if (PIPE_ANCS_DATA_SOURCE_RX==aci_evt->params.data_received.rx_data.pipe_number) + { + Serial.print(F("PIPE_ANCS_DATA_SOURCE_RX: ")); + for(uint8_t counter = 0; counter <= 20; counter++) + { + Serial.write(aci_evt->params.data_received.rx_data.aci_data[counter]); //uint8_t file_name[20]; + } + Serial.println(); + } + break; + + case ACI_EVT_DATA_CREDIT: + aci_state.data_credit_available = aci_state.data_credit_available + aci_evt->params.data_credit.credit; + break; + + case ACI_EVT_PIPE_ERROR: + //See the appendix in the nRF8001 Product Specication for details on the error codes + Serial.print(F("ACI Evt Pipe Error: Pipe #:")); + Serial.print(aci_evt->params.pipe_error.pipe_number, DEC); + Serial.print(F(" Pipe Error Code: 0x")); + Serial.println(aci_evt->params.pipe_error.error_code, HEX); + + //Increment the credit available as the data packet was not sent. + //The pipe error also represents the Attribute protocol Error Response sent from the peer and that should not be counted + //for the credit. + if (ACI_STATUS_ERROR_PEER_ATT_ERROR != aci_evt->params.pipe_error.error_code) + { + aci_state.data_credit_available++; + } + break; + + case ACI_EVT_HW_ERROR: + Serial.print(F("HW error: ")); + Serial.println(aci_evt->params.hw_error.line_num, DEC); + + for(uint8_t counter = 0; counter <= (aci_evt->len - 3); counter++) + { + Serial.write(aci_evt->params.hw_error.file_name[counter]); //uint8_t file_name[20]; + } + Serial.println(); + + //Manage the bond in EEPROM of the AVR + { + uint8_t eeprom_status = 0; + eeprom_status = EEPROM.read(0); + if (eeprom_status != 0x00) + { + Serial.println(F("Previous Bond present. Restoring")); + Serial.println(F("Using existing bond stored in EEPROM.")); + Serial.println(F(" To delete the bond stored in EEPROM, connect Pin 6 to 3.3v and Reset.")); + Serial.println(F(" Make sure that the bond on the phone/PC is deleted as well.")); + //We must have lost power and restarted and must restore the bonding infromation using the ACI Write Dynamic Data + if (ACI_STATUS_TRANSACTION_COMPLETE == bond_data_restore(&aci_state, eeprom_status, &bonded_first_time)) + { + Serial.println(F("Bond restored successfully")); + } + else + { + Serial.println(F("Bond restore failed. Delete the bond and try again.")); + } + } + } + + // Start bonding as all proximity devices need to be bonded to be usable + if (ACI_BOND_STATUS_SUCCESS != aci_state.bonded) + { + lib_aci_bond(180/* in seconds */, 0x0050 /* advertising interval 50ms*/); + Serial.println(F("No Bond present in EEPROM.")); + Serial.println(F("Advertising started : Waiting to be connected and bonded")); + } + else + { + //connect to an already bonded device + //Use lib_aci_direct_connect for faster re-connections with PC, not recommended to use with iOS/OS X + lib_aci_connect(100/* in seconds */, 0x0020 /* advertising interval 20ms*/); + Serial.println(F("Already bonded : Advertising started : Waiting to be connected")); + } + break; + + } + } + else + { + //Serial.println(F("No ACI Events available")); + // No event in the ACI Event queue and if there is no event in the ACI command queue the arduino can go to sleep + // Arduino can go to sleep now + // Wakeup from sleep from the RDYN line + } +} + +void alert_level_print(alert_level_t level) +{ + switch (level) + { + case ALERT_LEVEL_NO_ALERT: + Serial.println(F("NO_ALERT")); + break; + + case ALERT_LEVEL_MILD_ALERT: + Serial.println(F("MILD_ALERT")); + break; + + case ALERT_LEVEL_HIGH_ALERT: + Serial.println(F("HIGH_ALERT")); + break; + } +} + +void immediate_alert_hook(alert_level_t level) +{ + Serial.println(F("Immediate Alert: Alert level = ")); + alert_level_print(level); +} + +void link_loss_alert_hook(alert_level_t level) +{ + Serial.println(F("Link Loss Alert: Alert level = ")); + alert_level_print(level); +} + +/* +Description: + + PAIRING CLEAR pin: Connect to 3.3v to clear the pairing + if (0x01 == digitalRead(6)) + { + //Clear the pairing + Serial.println(F("Pairing/Bonding info cleared from EEPROM.")); + Serial.println(F("Remove the wire on Pin 6 and reset the board for normal operation.")); + //Address. Value + EEPROM.write(0, 0); + while(1) {}; + } +} + + +void loop() +{ + aci_loop(); +} + + diff --git a/libraries/BLE/examples/ble_ANCS_template/immediate_alert.cpp b/libraries/BLE/examples/ble_ANCS_template/immediate_alert.cpp new file mode 100644 index 0000000..ad4cb5c --- /dev/null +++ b/libraries/BLE/examples/ble_ANCS_template/immediate_alert.cpp @@ -0,0 +1,52 @@ +/* Copyright (c) 2014, Nordic Semiconductor ASA + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* Attention! +* To maintain compliance with Nordic Semiconductor ASA's Bluetooth profile +* qualification listings, this section of source code must not be modified. +*/ + +#include +#include "lib_aci.h" +#include "services.h" +#include "alert_level_characteristic.h" +#include "immediate_alert.h" + + +void immediate_alert_pipes_updated_evt_rcvd(uint8_t pipe_num, uint8_t *buffer) +{ + switch (pipe_num) + { + case PIPE_IMMEDIATE_ALERT_ALERT_LEVEL_RX : + immediate_alert_hook((alert_level_t)buffer[0]); + break; + } +} + +/* This function returns true if the immediate alert service is available at the master. + The user of this function may decide take appropriate action (if needed) based of the + return value of this function. */ + +bool is_immediate_alert_service_available_at_master(aci_state_t * aci_stat) +{ + return lib_aci_is_pipe_available(aci_stat, PIPE_IMMEDIATE_ALERT_ALERT_LEVEL_TX_1); + +} diff --git a/libraries/BLE/examples/ble_ANCS_template/immediate_alert.h b/libraries/BLE/examples/ble_ANCS_template/immediate_alert.h new file mode 100644 index 0000000..79eeea9 --- /dev/null +++ b/libraries/BLE/examples/ble_ANCS_template/immediate_alert.h @@ -0,0 +1,63 @@ +/* Copyright (c) 2014, Nordic Semiconductor ASA + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* Attention! +* To maintain compliance with Nordic Semiconductor ASA's Bluetooth profile +* qualification listings, this section of source code must not be modified. +*/ + +#include +#include "alert_level_characteristic.h" + +/** @defgroup immediate_alert immediate_alert +* @{ +* @ingroup services +* +* @brief immediate_alert service implementation. +* +* +*/ + +#ifndef IMMEDIATE_ALERT_H__ +#define IMMEDIATE_ALERT_H__ + +/** @brief Callback on immediate alert. + * @details This function is called when an immediate alert characteristic value is updated. + * Implement this function to have your application behave according to the alert level of the immediate alert. + * @param level : Level of the immediate alert (see @ref alert_level_characteristic to view possible values). + */ +extern void immediate_alert_hook(alert_level_t level); + +/** @brief Function to handle reception of data for immediate_alert. + * @details Call this function on the ACI_EVT_DATA_RECEIVED event. This function checks if the data received is for immediate_alert. + * If so it triggers the immediate alert with the received level. + * @param pipe_num Pipe which has received data. + * @param buffer Pointer to the received data. + */ +void immediate_alert_pipes_updated_evt_rcvd(uint8_t pipe_num, uint8_t *buffer); + +/** @brief Function to check if the immediate alert service is available at master side. + * @details Returns the return value of lib_aci_is_pipe_available(PIPE_IMMEDIATE_ALERT_ALERT_LEVEL_TX_1). + */ +bool is_immediate_alert_service_available_at_master(aci_state_t * aci_stat); +#endif//IMMEDIATE_ALERT_H__ +/** @} */ + diff --git a/libraries/BLE/examples/ble_ANCS_template/link_loss.cpp b/libraries/BLE/examples/ble_ANCS_template/link_loss.cpp new file mode 100644 index 0000000..6fa7831 --- /dev/null +++ b/libraries/BLE/examples/ble_ANCS_template/link_loss.cpp @@ -0,0 +1,58 @@ +/* Copyright (c) 2014, Nordic Semiconductor ASA + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* Attention! +* To maintain compliance with Nordic Semiconductor ASA's Bluetooth profile +* qualification listings, this section of source code must not be modified. +*/ + + +#include +#include "alert_level_characteristic.h" +#include "services.h" +#include "lib_aci.h" +#include "link_loss.h" + +/*link loss Service */ +volatile alert_level_t alert_handle_on_link_loss; + +void link_loss_init(void) +{ + alert_handle_on_link_loss = ALERT_LEVEL_NO_ALERT; +} + +void proximity_disconect_evt_rcvd(uint8_t disconnect_reason) +{ + if ((DISCONNECT_REASON_CX_CLOSED_BY_PEER_DEVICE != disconnect_reason)&&(DISCONNECT_REASON_CX_CLOSED_BY_LOCAL_DEVICE != disconnect_reason)) + { + link_loss_alert_hook(alert_handle_on_link_loss); + } +} + +void link_loss_pipes_updated_evt_rcvd(uint8_t pipe_num, uint8_t *buffer) +{ + switch (pipe_num) + { + case PIPE_LINK_LOSS_ALERT_ALERT_LEVEL_RX_ACK_AUTO : + alert_handle_on_link_loss = (alert_level_t)buffer[0]; + break; + } +} diff --git a/libraries/BLE/examples/ble_ANCS_template/link_loss.h b/libraries/BLE/examples/ble_ANCS_template/link_loss.h new file mode 100644 index 0000000..5a5e5d0 --- /dev/null +++ b/libraries/BLE/examples/ble_ANCS_template/link_loss.h @@ -0,0 +1,74 @@ +/* Copyright (c) 2014, Nordic Semiconductor ASA + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* Attention! +* To maintain compliance with Nordic Semiconductor ASA's Bluetooth profile +* qualification listings, this section of source code must not be modified. +*/ + +#ifndef LINK_LOSS_H +#define LINK_LOSS_H + + +/** @defgroup link_loss link_loss +* @{ +* @ingroup services +* +* @brief Link Loss Service (for proximity profile) implementation. +* +* +*/ + + +#include +#include "alert_level_characteristic.h" + +/** @brief Callback on link_loss alert. + * @details This function is called when a link loss alert characteristic value is updated. + * Implement this function to have your application behave according to the alert level of the link loss alert. + * @param level Level of the link_loss alert (see @ref alert_level_characteristic to view possible values). + */ +extern void link_loss_alert_hook(alert_level_t level); + + +/** Function to be initialize the link_loss service (set the alert on link_loss to NO_ALERT).*/ +void link_loss_init(void); + + +/** @brief Function to handle disconnect event. + * @details Call this function on the ACI_EVT_DISCONNECTED event. This function checks the reason for disconnect + * and if it matches a link loss situation, triggers a link_loss event. + * @param disconnect_reason Reason for disconnect event (given with the disconnect event). + */ +void proximity_disconect_evt_rcvd(uint8_t disconnect_reason); + +/** @brief Function to handle reception of data for link_loss. + * @details Call this function on the ACI_EVT_DATA_RECEIVED event. This function checks if the data received is for link_loss. + * If so, it memorizes the alert level received to use it for the next link_loss event. + * @param pipe_num Pipe which has received data. + * @param buffer Pointer to the received data. + */ +void link_loss_pipes_updated_evt_rcvd(uint8_t pipe_num, uint8_t *buffer); + + +/** @} */ + +#endif //LINK_LOSS_H diff --git a/libraries/BLE/examples/ble_ANCS_template/run_me_compile_xml_to_nRF8001_setup.bat b/libraries/BLE/examples/ble_ANCS_template/run_me_compile_xml_to_nRF8001_setup.bat new file mode 100644 index 0000000..f55889c --- /dev/null +++ b/libraries/BLE/examples/ble_ANCS_template/run_me_compile_xml_to_nRF8001_setup.bat @@ -0,0 +1,6 @@ + +del services.h +del services_lock.h +del ublue_setup.gen.out.txt + +"%NRFGOSTUDIOPATH%\nrfgostudio.exe" -nrf8001 -g ANCS_setup.xml -codeGenVersion 1 -o . \ No newline at end of file diff --git a/libraries/BLE/examples/ble_ANCS_template/services.h b/libraries/BLE/examples/ble_ANCS_template/services.h new file mode 100644 index 0000000..b3af833 --- /dev/null +++ b/libraries/BLE/examples/ble_ANCS_template/services.h @@ -0,0 +1,289 @@ +/* +* 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 name of Nordic Semiconductor ASA may not be used to endorse or promote +* products derived from this software without specific prior written permission. +* +* 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. +*/ + +/** +* This file is autogenerated by nRFgo Studio 1.16.1.3119 +*/ + +#ifndef SETUP_MESSAGES_H__ +#define SETUP_MESSAGES_H__ + +#include "hal_platform.h" +#include "aci.h" + + +#define SETUP_ID 1 +#define SETUP_FORMAT 3 /** nRF8001 D */ +#define ACI_DYNAMIC_DATA_SIZE 183 + +/* Service: GATT - Characteristic: Service Changed - Pipe: TX_ACK */ +#define PIPE_GATT_SERVICE_CHANGED_TX_ACK 1 +#define PIPE_GATT_SERVICE_CHANGED_TX_ACK_MAX_SIZE 4 + +/* Service: TX Power - Characteristic: TX Power Level - Pipe: SET */ +#define PIPE_TX_POWER_TX_POWER_LEVEL_SET 2 +#define PIPE_TX_POWER_TX_POWER_LEVEL_SET_MAX_SIZE 1 + +/* Service: Immediate Alert - Characteristic: Alert Level - Pipe: RX */ +#define PIPE_IMMEDIATE_ALERT_ALERT_LEVEL_RX 3 +#define PIPE_IMMEDIATE_ALERT_ALERT_LEVEL_RX_MAX_SIZE 1 + +/* Service: Link Loss Alert - Characteristic: Alert Level - Pipe: RX_ACK_AUTO */ +#define PIPE_LINK_LOSS_ALERT_ALERT_LEVEL_RX_ACK_AUTO 4 +#define PIPE_LINK_LOSS_ALERT_ALERT_LEVEL_RX_ACK_AUTO_MAX_SIZE 1 + +/* Service: Battery - Characteristic: Battery Level - Pipe: TX */ +#define PIPE_BATTERY_BATTERY_LEVEL_TX 5 +#define PIPE_BATTERY_BATTERY_LEVEL_TX_MAX_SIZE 1 + +/* Service: Battery - Characteristic: Battery Level - Pipe: SET */ +#define PIPE_BATTERY_BATTERY_LEVEL_SET 6 +#define PIPE_BATTERY_BATTERY_LEVEL_SET_MAX_SIZE 1 + +/* Service: Device Information - Characteristic: Hardware Revision String - Pipe: SET */ +#define PIPE_DEVICE_INFORMATION_HARDWARE_REVISION_STRING_SET 7 +#define PIPE_DEVICE_INFORMATION_HARDWARE_REVISION_STRING_SET_MAX_SIZE 9 + +/* Service: Immediate Alert - Characteristic: Alert Level - Pipe: TX */ +#define PIPE_IMMEDIATE_ALERT_ALERT_LEVEL_TX_1 8 +#define PIPE_IMMEDIATE_ALERT_ALERT_LEVEL_TX_1_MAX_SIZE 1 + +/* Service: ANCS - Characteristic: Notification Source - Pipe: RX */ +#define PIPE_ANCS_NOTIFICATION_SOURCE_RX 9 +#define PIPE_ANCS_NOTIFICATION_SOURCE_RX_MAX_SIZE 20 + +/* Service: ANCS - Characteristic: Control Point - Pipe: TX_ACK */ +#define PIPE_ANCS_CONTROL_POINT_TX_ACK 10 +#define PIPE_ANCS_CONTROL_POINT_TX_ACK_MAX_SIZE 20 + +/* Service: ANCS - Characteristic: Data Source - Pipe: RX */ +#define PIPE_ANCS_DATA_SOURCE_RX 11 +#define PIPE_ANCS_DATA_SOURCE_RX_MAX_SIZE 20 + + +#define NUMBER_OF_PIPES 11 + +#define SERVICES_PIPE_TYPE_MAPPING_CONTENT {\ + {ACI_STORE_LOCAL, ACI_TX_ACK}, \ + {ACI_STORE_LOCAL, ACI_SET}, \ + {ACI_STORE_LOCAL, ACI_RX}, \ + {ACI_STORE_LOCAL, ACI_RX_ACK_AUTO}, \ + {ACI_STORE_LOCAL, ACI_TX}, \ + {ACI_STORE_LOCAL, ACI_SET}, \ + {ACI_STORE_LOCAL, ACI_SET}, \ + {ACI_STORE_REMOTE, ACI_TX}, \ + {ACI_STORE_REMOTE, ACI_RX}, \ + {ACI_STORE_REMOTE, ACI_TX_ACK}, \ + {ACI_STORE_REMOTE, ACI_RX}, \ +} + +#define GAP_PPCP_MAX_CONN_INT 0x320 /**< Maximum connection interval as a multiple of 1.25 msec , 0xFFFF means no specific value requested */ +#define GAP_PPCP_MIN_CONN_INT 0x190 /**< Minimum connection interval as a multiple of 1.25 msec , 0xFFFF means no specific value requested */ +#define GAP_PPCP_SLAVE_LATENCY 0 +#define GAP_PPCP_CONN_TIMEOUT 0x258 /** Connection Supervision timeout multiplier as a multiple of 10msec, 0xFFFF means no specific value requested */ + +#define NB_SETUP_MESSAGES 30 +#define SETUP_MESSAGES_CONTENT {\ + {0x00,\ + {\ + 0x07,0x06,0x00,0x00,0x03,0x02,0x41,0xfe,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x10,0x00,0x01,0x00,0x00,0x00,0x02,0x03,0x06,0x05,0x0c,0x01,0x01,0x00,0x00,0x06,0x00,0x03,\ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x10,0x1c,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf4,0x31,0x02,\ + 0x00,0x00,0x40,0x10,0x00,0x00,0x40,0x10,0x03,0x90,0x04,0x64,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x10,0x38,0x02,0xff,0x02,0x58,0x63,0x05,0x00,0x00,0x08,0x40,0x00,0x00,0x08,0x40,0x00,0x00,\ + 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x00,\ + },\ + },\ + {0x00,\ + {\ + 0x05,0x06,0x10,0x54,0x01,0x01,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x20,0x00,0x04,0x04,0x02,0x02,0x00,0x01,0x28,0x00,0x01,0x00,0x18,0x04,0x04,0x05,0x05,0x00,\ + 0x02,0x28,0x03,0x01,0x02,0x03,0x00,0x00,0x2a,0x04,0x04,0x14,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x20,0x1c,0x09,0x00,0x03,0x2a,0x00,0x01,0x41,0x4e,0x43,0x53,0x20,0x52,0x75,0x73,0x6b,0x69,\ + 0x2e,0x63,0x6f,0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x20,0x38,0x05,0x05,0x00,0x04,0x28,0x03,0x01,0x02,0x05,0x00,0x01,0x2a,0x06,0x04,0x03,0x02,\ + 0x00,0x05,0x2a,0x01,0x01,0x40,0x02,0x04,0x04,0x05,0x05,0x00,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x20,0x54,0x06,0x28,0x03,0x01,0x02,0x07,0x00,0x04,0x2a,0x06,0x04,0x09,0x08,0x00,0x07,0x2a,\ + 0x04,0x01,0x90,0x01,0x20,0x03,0x00,0x00,0x58,0x02,0x04,0x04,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x20,0x70,0x02,0x02,0x00,0x08,0x28,0x00,0x01,0x01,0x18,0x04,0x04,0x05,0x05,0x00,0x09,0x28,\ + 0x03,0x01,0x22,0x0a,0x00,0x05,0x2a,0x26,0x0c,0x05,0x04,0x00,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x20,0x8c,0x0a,0x2a,0x05,0x01,0x00,0x00,0x00,0x00,0x46,0x34,0x03,0x02,0x00,0x0b,0x29,0x02,\ + 0x01,0x00,0x00,0x04,0x04,0x02,0x02,0x00,0x0c,0x28,0x00,0x01,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x20,0xa8,0x04,0x18,0x04,0x04,0x05,0x05,0x00,0x0d,0x28,0x03,0x01,0x02,0x0e,0x00,0x07,0x2a,\ + 0x06,0x0c,0x02,0x01,0x00,0x0e,0x2a,0x07,0x01,0x00,0x04,0x04,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x20,0xc4,0x02,0x02,0x00,0x0f,0x28,0x00,0x01,0x02,0x18,0x04,0x04,0x05,0x05,0x00,0x10,0x28,\ + 0x03,0x01,0x04,0x11,0x00,0x06,0x2a,0x46,0x30,0x02,0x01,0x00,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x20,0xe0,0x11,0x2a,0x06,0x01,0x00,0x04,0x04,0x02,0x02,0x00,0x12,0x28,0x00,0x01,0x03,0x18,\ + 0x04,0x04,0x05,0x05,0x00,0x13,0x28,0x03,0x01,0x0a,0x14,0x00,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x20,0xfc,0x06,0x2a,0x46,0x3c,0x02,0x01,0x00,0x14,0x2a,0x06,0x01,0x00,0x04,0x04,0x02,0x02,\ + 0x00,0x15,0x28,0x00,0x01,0x0f,0x18,0x04,0x04,0x05,0x05,0x00,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x21,0x18,0x16,0x28,0x03,0x01,0x12,0x17,0x00,0x19,0x2a,0x16,0x0c,0x02,0x01,0x00,0x17,0x2a,\ + 0x19,0x01,0x64,0x46,0x34,0x03,0x02,0x00,0x18,0x29,0x02,0x01,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x21,0x34,0x00,0x00,0x04,0x04,0x02,0x02,0x00,0x19,0x28,0x00,0x01,0x0a,0x18,0x04,0x04,0x05,\ + 0x05,0x00,0x1a,0x28,0x03,0x01,0x02,0x1b,0x00,0x27,0x2a,0x04,\ + },\ + },\ + {0x00,\ + {\ + 0x15,0x06,0x21,0x50,0x0c,0x09,0x00,0x00,0x1b,0x2a,0x27,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ + 0x00,0x00,\ + },\ + },\ + {0x00,\ + {\ + 0x12,0x06,0x30,0x00,0x18,0x02,0x01,0x06,0x01,0xf4,0x31,0x02,0x07,0x03,0x18,0x01,0x01,0x0a,0x01,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x40,0x00,0x2a,0x05,0x01,0x00,0x04,0x04,0x00,0x0a,0x00,0x0b,0x2a,0x07,0x01,0x00,0x80,0x04,\ + 0x00,0x0e,0x00,0x00,0x2a,0x06,0x01,0x00,0x08,0x04,0x00,0x11,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x40,0x1c,0x00,0x00,0x2a,0x06,0x01,0x04,0x00,0x04,0x00,0x14,0x00,0x00,0x2a,0x19,0x01,0x00,\ + 0x82,0x04,0x00,0x17,0x00,0x18,0x2a,0x27,0x01,0x00,0x80,0x04,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x40,0x38,0x00,0x1b,0x00,0x00,0x2a,0x06,0x01,0x00,0x02,0x04,0x00,0x00,0x00,0x00,0x12,0x0d,\ + 0x03,0x00,0x08,0x04,0x00,0x00,0x00,0x00,0xd8,0xf3,0x05,0x00,\ + },\ + },\ + {0x00,\ + {\ + 0x1d,0x06,0x40,0x54,0x04,0x04,0x00,0x00,0x00,0x00,0xc6,0xe9,0x04,0x00,0x08,0x04,0x00,0x00,0x00,0x00,\ + 0x2a,0x05,0x01,0x00,0x10,0x04,0x00,0x00,0x00,0x00,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x50,0x00,0xd0,0x00,0x2d,0x12,0x1e,0x4b,0x0f,0xa4,0x99,0x4e,0xce,0xb5,0x00,0x00,0x05,0x79,\ + 0xbd,0x1d,0xa2,0x99,0xe6,0x25,0x58,0x8c,0xd9,0x42,0x01,0x63,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x50,0x1c,0x00,0x00,0xbf,0x9f,0xfb,0x7b,0x7c,0xce,0x6a,0xb3,0x44,0xbe,0xb5,0x4b,0xd6,0x24,\ + 0x00,0x00,0xea,0x22,0xd9,0xd9,0xaa,0xfd,0xbd,0x9b,0x21,0x98,\ + },\ + },\ + {0x00,\ + {\ + 0x0b,0x06,0x50,0x38,0xa8,0x49,0xe1,0x45,0x00,0x00,0xd1,0x69,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ + },\ + },\ + {0x00,\ + {\ + 0x08,0x06,0x60,0x1c,0x00,0x00,0x00,0x00,0x00,\ + },\ + },\ + {0x00,\ + {\ + 0x19,0x06,0x70,0x00,0x19,0x02,0x40,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ + 0x00,0x00,0x00,0x00,0x00,0x00,\ + },\ + },\ + {0x00,\ + {\ + 0x06,0x06,0xf0,0x00,0x03,0x77,0x18,\ + },\ + },\ +} + +#endif diff --git a/libraries/BLE/examples/ble_ANCS_template/services_lock.h b/libraries/BLE/examples/ble_ANCS_template/services_lock.h new file mode 100644 index 0000000..d8f519e --- /dev/null +++ b/libraries/BLE/examples/ble_ANCS_template/services_lock.h @@ -0,0 +1,293 @@ +/* +* 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 name of Nordic Semiconductor ASA may not be used to endorse or promote +* products derived from this software without specific prior written permission. +* +* 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. +*/ + +/** +* This file is autogenerated by nRFgo Studio 1.16.1.3119 +*/ + +#ifndef SETUP_MESSAGES_H__ +#define SETUP_MESSAGES_H__ + +#include "hal_platform.h" +#include "aci.h" + +// You have now chosen to upload the configuration to OTP on the device. +// This will result in a device that you can not modify afterwards. If this is your intention, +// remove this comment and the #error below +#error Generating configuration for OTP. Please verify usage by removing this error message from include file. + +#define SETUP_ID 1 +#define SETUP_FORMAT 3 /** nRF8001 D */ +#define ACI_DYNAMIC_DATA_SIZE 183 + +/* Service: GATT - Characteristic: Service Changed - Pipe: TX_ACK */ +#define PIPE_GATT_SERVICE_CHANGED_TX_ACK 1 +#define PIPE_GATT_SERVICE_CHANGED_TX_ACK_MAX_SIZE 4 + +/* Service: TX Power - Characteristic: TX Power Level - Pipe: SET */ +#define PIPE_TX_POWER_TX_POWER_LEVEL_SET 2 +#define PIPE_TX_POWER_TX_POWER_LEVEL_SET_MAX_SIZE 1 + +/* Service: Immediate Alert - Characteristic: Alert Level - Pipe: RX */ +#define PIPE_IMMEDIATE_ALERT_ALERT_LEVEL_RX 3 +#define PIPE_IMMEDIATE_ALERT_ALERT_LEVEL_RX_MAX_SIZE 1 + +/* Service: Link Loss Alert - Characteristic: Alert Level - Pipe: RX_ACK_AUTO */ +#define PIPE_LINK_LOSS_ALERT_ALERT_LEVEL_RX_ACK_AUTO 4 +#define PIPE_LINK_LOSS_ALERT_ALERT_LEVEL_RX_ACK_AUTO_MAX_SIZE 1 + +/* Service: Battery - Characteristic: Battery Level - Pipe: TX */ +#define PIPE_BATTERY_BATTERY_LEVEL_TX 5 +#define PIPE_BATTERY_BATTERY_LEVEL_TX_MAX_SIZE 1 + +/* Service: Battery - Characteristic: Battery Level - Pipe: SET */ +#define PIPE_BATTERY_BATTERY_LEVEL_SET 6 +#define PIPE_BATTERY_BATTERY_LEVEL_SET_MAX_SIZE 1 + +/* Service: Device Information - Characteristic: Hardware Revision String - Pipe: SET */ +#define PIPE_DEVICE_INFORMATION_HARDWARE_REVISION_STRING_SET 7 +#define PIPE_DEVICE_INFORMATION_HARDWARE_REVISION_STRING_SET_MAX_SIZE 9 + +/* Service: Immediate Alert - Characteristic: Alert Level - Pipe: TX */ +#define PIPE_IMMEDIATE_ALERT_ALERT_LEVEL_TX_1 8 +#define PIPE_IMMEDIATE_ALERT_ALERT_LEVEL_TX_1_MAX_SIZE 1 + +/* Service: ANCS - Characteristic: Notification Source - Pipe: RX */ +#define PIPE_ANCS_NOTIFICATION_SOURCE_RX 9 +#define PIPE_ANCS_NOTIFICATION_SOURCE_RX_MAX_SIZE 20 + +/* Service: ANCS - Characteristic: Control Point - Pipe: TX_ACK */ +#define PIPE_ANCS_CONTROL_POINT_TX_ACK 10 +#define PIPE_ANCS_CONTROL_POINT_TX_ACK_MAX_SIZE 20 + +/* Service: ANCS - Characteristic: Data Source - Pipe: RX */ +#define PIPE_ANCS_DATA_SOURCE_RX 11 +#define PIPE_ANCS_DATA_SOURCE_RX_MAX_SIZE 20 + + +#define NUMBER_OF_PIPES 11 + +#define SERVICES_PIPE_TYPE_MAPPING_CONTENT {\ + {ACI_STORE_LOCAL, ACI_TX_ACK}, \ + {ACI_STORE_LOCAL, ACI_SET}, \ + {ACI_STORE_LOCAL, ACI_RX}, \ + {ACI_STORE_LOCAL, ACI_RX_ACK_AUTO}, \ + {ACI_STORE_LOCAL, ACI_TX}, \ + {ACI_STORE_LOCAL, ACI_SET}, \ + {ACI_STORE_LOCAL, ACI_SET}, \ + {ACI_STORE_REMOTE, ACI_TX}, \ + {ACI_STORE_REMOTE, ACI_RX}, \ + {ACI_STORE_REMOTE, ACI_TX_ACK}, \ + {ACI_STORE_REMOTE, ACI_RX}, \ +} + +#define GAP_PPCP_MAX_CONN_INT 0x320 /**< Maximum connection interval as a multiple of 1.25 msec , 0xFFFF means no specific value requested */ +#define GAP_PPCP_MIN_CONN_INT 0x190 /**< Minimum connection interval as a multiple of 1.25 msec , 0xFFFF means no specific value requested */ +#define GAP_PPCP_SLAVE_LATENCY 0 +#define GAP_PPCP_CONN_TIMEOUT 0x258 /** Connection Supervision timeout multiplier as a multiple of 10msec, 0xFFFF means no specific value requested */ + +#define NB_SETUP_MESSAGES 30 +#define SETUP_MESSAGES_CONTENT {\ + {0x00,\ + {\ + 0x07,0x06,0x00,0x00,0x03,0x02,0x41,0xfe,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x10,0x00,0x01,0x00,0x00,0x00,0x02,0x03,0x06,0x05,0x0c,0x01,0x01,0x00,0x00,0x06,0x00,0x03,\ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x10,0x1c,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf4,0x31,0x02,\ + 0x00,0x00,0x40,0x10,0x00,0x00,0x40,0x10,0x03,0x90,0x04,0x64,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x10,0x38,0x02,0xff,0x02,0x58,0x63,0x05,0x00,0x00,0x08,0x40,0x00,0x00,0x08,0x40,0x00,0x00,\ + 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x00,\ + },\ + },\ + {0x00,\ + {\ + 0x05,0x06,0x10,0x54,0x01,0x01,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x20,0x00,0x04,0x04,0x02,0x02,0x00,0x01,0x28,0x00,0x01,0x00,0x18,0x04,0x04,0x05,0x05,0x00,\ + 0x02,0x28,0x03,0x01,0x02,0x03,0x00,0x00,0x2a,0x04,0x04,0x14,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x20,0x1c,0x09,0x00,0x03,0x2a,0x00,0x01,0x41,0x4e,0x43,0x53,0x20,0x52,0x75,0x73,0x6b,0x69,\ + 0x2e,0x63,0x6f,0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x20,0x38,0x05,0x05,0x00,0x04,0x28,0x03,0x01,0x02,0x05,0x00,0x01,0x2a,0x06,0x04,0x03,0x02,\ + 0x00,0x05,0x2a,0x01,0x01,0x40,0x02,0x04,0x04,0x05,0x05,0x00,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x20,0x54,0x06,0x28,0x03,0x01,0x02,0x07,0x00,0x04,0x2a,0x06,0x04,0x09,0x08,0x00,0x07,0x2a,\ + 0x04,0x01,0x90,0x01,0x20,0x03,0x00,0x00,0x58,0x02,0x04,0x04,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x20,0x70,0x02,0x02,0x00,0x08,0x28,0x00,0x01,0x01,0x18,0x04,0x04,0x05,0x05,0x00,0x09,0x28,\ + 0x03,0x01,0x22,0x0a,0x00,0x05,0x2a,0x26,0x0c,0x05,0x04,0x00,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x20,0x8c,0x0a,0x2a,0x05,0x01,0x00,0x00,0x00,0x00,0x46,0x34,0x03,0x02,0x00,0x0b,0x29,0x02,\ + 0x01,0x00,0x00,0x04,0x04,0x02,0x02,0x00,0x0c,0x28,0x00,0x01,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x20,0xa8,0x04,0x18,0x04,0x04,0x05,0x05,0x00,0x0d,0x28,0x03,0x01,0x02,0x0e,0x00,0x07,0x2a,\ + 0x06,0x0c,0x02,0x01,0x00,0x0e,0x2a,0x07,0x01,0x00,0x04,0x04,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x20,0xc4,0x02,0x02,0x00,0x0f,0x28,0x00,0x01,0x02,0x18,0x04,0x04,0x05,0x05,0x00,0x10,0x28,\ + 0x03,0x01,0x04,0x11,0x00,0x06,0x2a,0x46,0x30,0x02,0x01,0x00,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x20,0xe0,0x11,0x2a,0x06,0x01,0x00,0x04,0x04,0x02,0x02,0x00,0x12,0x28,0x00,0x01,0x03,0x18,\ + 0x04,0x04,0x05,0x05,0x00,0x13,0x28,0x03,0x01,0x0a,0x14,0x00,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x20,0xfc,0x06,0x2a,0x46,0x3c,0x02,0x01,0x00,0x14,0x2a,0x06,0x01,0x00,0x04,0x04,0x02,0x02,\ + 0x00,0x15,0x28,0x00,0x01,0x0f,0x18,0x04,0x04,0x05,0x05,0x00,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x21,0x18,0x16,0x28,0x03,0x01,0x12,0x17,0x00,0x19,0x2a,0x16,0x0c,0x02,0x01,0x00,0x17,0x2a,\ + 0x19,0x01,0x64,0x46,0x34,0x03,0x02,0x00,0x18,0x29,0x02,0x01,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x21,0x34,0x00,0x00,0x04,0x04,0x02,0x02,0x00,0x19,0x28,0x00,0x01,0x0a,0x18,0x04,0x04,0x05,\ + 0x05,0x00,0x1a,0x28,0x03,0x01,0x02,0x1b,0x00,0x27,0x2a,0x04,\ + },\ + },\ + {0x00,\ + {\ + 0x15,0x06,0x21,0x50,0x0c,0x09,0x00,0x00,0x1b,0x2a,0x27,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ + 0x00,0x00,\ + },\ + },\ + {0x00,\ + {\ + 0x12,0x06,0x30,0x00,0x18,0x02,0x01,0x06,0x01,0xf4,0x31,0x02,0x07,0x03,0x18,0x01,0x01,0x0a,0x01,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x40,0x00,0x2a,0x05,0x01,0x00,0x04,0x04,0x00,0x0a,0x00,0x0b,0x2a,0x07,0x01,0x00,0x80,0x04,\ + 0x00,0x0e,0x00,0x00,0x2a,0x06,0x01,0x00,0x08,0x04,0x00,0x11,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x40,0x1c,0x00,0x00,0x2a,0x06,0x01,0x04,0x00,0x04,0x00,0x14,0x00,0x00,0x2a,0x19,0x01,0x00,\ + 0x82,0x04,0x00,0x17,0x00,0x18,0x2a,0x27,0x01,0x00,0x80,0x04,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x40,0x38,0x00,0x1b,0x00,0x00,0x2a,0x06,0x01,0x00,0x02,0x04,0x00,0x00,0x00,0x00,0x12,0x0d,\ + 0x03,0x00,0x08,0x04,0x00,0x00,0x00,0x00,0xd8,0xf3,0x05,0x00,\ + },\ + },\ + {0x00,\ + {\ + 0x1d,0x06,0x40,0x54,0x04,0x04,0x00,0x00,0x00,0x00,0xc6,0xe9,0x04,0x00,0x08,0x04,0x00,0x00,0x00,0x00,\ + 0x2a,0x05,0x01,0x00,0x10,0x04,0x00,0x00,0x00,0x00,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x50,0x00,0xd0,0x00,0x2d,0x12,0x1e,0x4b,0x0f,0xa4,0x99,0x4e,0xce,0xb5,0x00,0x00,0x05,0x79,\ + 0xbd,0x1d,0xa2,0x99,0xe6,0x25,0x58,0x8c,0xd9,0x42,0x01,0x63,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x50,0x1c,0x00,0x00,0xbf,0x9f,0xfb,0x7b,0x7c,0xce,0x6a,0xb3,0x44,0xbe,0xb5,0x4b,0xd6,0x24,\ + 0x00,0x00,0xea,0x22,0xd9,0xd9,0xaa,0xfd,0xbd,0x9b,0x21,0x98,\ + },\ + },\ + {0x00,\ + {\ + 0x0b,0x06,0x50,0x38,0xa8,0x49,0xe1,0x45,0x00,0x00,0xd1,0x69,\ + },\ + },\ + {0x00,\ + {\ + 0x1f,0x06,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ + },\ + },\ + {0x00,\ + {\ + 0x08,0x06,0x60,0x1c,0x00,0x00,0x00,0x00,0x00,\ + },\ + },\ + {0x00,\ + {\ + 0x19,0x06,0x70,0x00,0x19,0x02,0x40,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ + 0x00,0x00,0x00,0x00,0x00,0x00,\ + },\ + },\ + {0x00,\ + {\ + 0x06,0x06,0xf0,0x00,0x83,0xe6,0x90,\ + },\ + },\ +} + +#endif diff --git a/libraries/BLE/examples/ble_ANCS_template/ublue_setup.gen.out.txt b/libraries/BLE/examples/ble_ANCS_template/ublue_setup.gen.out.txt new file mode 100644 index 0000000..82f9cb5 --- /dev/null +++ b/libraries/BLE/examples/ble_ANCS_template/ublue_setup.gen.out.txt @@ -0,0 +1,155 @@ +------------------------------------------------------------------------------ + uBlue Setup generation report + Generated with uBlue setup DLL version: 1.0.0.16894 + Generated: Mon May 05 13:42:52 2014 (UTC) + This file is automatically generated, do not modify +------------------------------------------------------------------------------ + +[Counts] + +Setup data size = 811 bytes +Local database size = 354 bytes +Local attribute count = 6 +Remote attribute count = 5 +Total pipe count = 12 +Dynamic data size = 183 bytes (worst case) + +[Setup Area Layout] + +Setup area, total = 1595 bytes +Setup area, used = 576 bytes ( 36% of total ) +Local services = 354 bytes ( 61% of used ) +Remote services = 15 bytes ( 2% of used ) +Pipes = 110 bytes ( 19% of used ) +VS UUID area = 64 bytes ( 11% of used ) +Extended Attr area = 33 bytes ( 5% of used ) + +[Device Settings] + +Setup ID = 0x00000001 +Setup Format = 0x03 +Security = ENCRYPTED (2) +Bond Timeout = 600 +Security Request Delay = 99 +Change Timing Delay = 5 +Whitelist = Disabled + +[Advertisement Data] + +Bond Advertise = 0x00004010 [LOCAL_NAME_COMPLETE | CUSTOM] +Bond Scan Resp = 0x00000840 [TX_POWER_LEVEL | SERVICE_SOL_128] +General Advertise = 0x00004010 [LOCAL_NAME_COMPLETE | CUSTOM] +General Scan Resp = 0x00000840 [TX_POWER_LEVEL | SERVICE_SOL_128] +Broadcast Advertise = 0x00000000 [] +Broadcast Scan Resp = 0x00000000 [] + +Custom Bond Advertise = 0x01 ["0x19"] +Custom Bond Scan Resp = 0x00 [] +Custom General Advertise = 0x01 ["0x19"] +Custom General Scan Resp = 0x00 [] +Custom Broadcast Advertise = 0x00 [] +Custom Broadcast Scan Resp = 0x00 [] + +Custom AD type #0 (type=0x19): 0x40 0x02 + +[Vendor Specific UUIDs] + +VS UUID #0 (type=0x02): 0xD0 0x00 0x2D 0x12 0x1E 0x4B 0x0F 0xA4 0x99 0x4E 0xCE 0xB5 0x00 0x00 0x05 0x79 +VS UUID #1 (type=0x03): 0xBD 0x1D 0xA2 0x99 0xE6 0x25 0x58 0x8C 0xD9 0x42 0x01 0x63 0x00 0x00 0xBF 0x9F +VS UUID #2 (type=0x04): 0xFB 0x7B 0x7C 0xCE 0x6A 0xB3 0x44 0xBE 0xB5 0x4B 0xD6 0x24 0x00 0x00 0xEA 0x22 +VS UUID #3 (type=0x05): 0xD9 0xD9 0xAA 0xFD 0xBD 0x9B 0x21 0x98 0xA8 0x49 0xE1 0x45 0x00 0x00 0xD1 0x69 + +[Local Database] + +Handle Pipes Structure +------ ----- --------- +0x0001 +----- Service (Primary): "GAP" (01:0x1800) +0x0002 |----- |Characteristic: "Device Name" (01:0x2A00) [rd] [rd:allow|wr:none] +0x0003 |Value: {0x41 0x4E 0x43 0x53 0x20 0x52 0x75 0x73 0x6B} [rd:allow|wr:none] +0x0004 |----- |Characteristic: "Appearance" (01:0x2A01) [rd] [rd:allow|wr:none] +0x0005 |Value: {0x40 0x02} [rd:allow|wr:none] +0x0006 |----- |Characteristic: "PPCP" (01:0x2A04) [rd] [rd:allow|wr:none] +0x0007 |Value: {0x90 0x01 0x20 0x03 0x00 0x00 0x58 0x02} [rd:allow|wr:none] +0x0008 +----- Service (Primary): "GATT" (01:0x1801) +0x0009 |----- |Characteristic: "Service Changed" (01:0x2A05) [rd|ind] [rd:allow|wr:none] +0x000A > |Value: {0x00 0x00 0x00 0x00} [rd:enc|wr:none] +0x000B |----- |Descriptor: "Client Characteristic Configuration" (01:0x2902) Value: {0x00 0x00} [rd:allow|wr:enc] +0x000C +----- Service (Primary): "TX Power" (01:0x1804) +0x000D |----- |Characteristic: "TX Pow Lev" (01:0x2A07) [rd] [rd:allow|wr:none] +0x000E x |Value: {0x00} [rd:enc|wr:none] +0x000F +----- Service (Primary): "Immediate Alert" (01:0x1802) +0x0010 |----- |Characteristic: "Alert Level" (01:0x2A06) [wwr] [rd:allow|wr:none] +0x0011 < |Value: {0x00} [rd:none|wr:enc] +0x0012 +----- Service (Primary): "Link Loss" (01:0x1803) +0x0013 |----- |Characteristic: "Alert Level" (01:0x2A06) [rd|wr] [rd:allow|wr:none] +0x0014 < |Value: {0x00} [rd:enc|wr:enc] +0x0015 +----- Service (Primary): "Battery" (01:0x180F) +0x0016 |----- |Characteristic: "Batt Lev" (01:0x2A19) [rd|not] [rd:allow|wr:none] +0x0017 x> |Value: {0x64} [rd:enc|wr:none] +0x0018 |----- |Descriptor: "Client Characteristic Configuration" (01:0x2902) Value: {0x00 0x00} [rd:allow|wr:enc] +0x0019 +----- Service (Primary): "Device Info" (01:0x180A) +0x001A |----- |Characteristic: "HW Rev" (01:0x2A27) [rd] [rd:allow|wr:none] +0x001B x |Value: {} [rd:enc|wr:none] + +[Remote Database] + +Handle Pipes Structure +------ ----- --------- + -- +----- Service: "Immediate Alert" (01:0x1802) + -- > |----- |Characteristic: "Alert Level" (01:0x2A06) + -- +----- Service: "?" (02:0xF431) + -- < |----- |Characteristic: "?" (03:0x120D) + -- > |----- |Characteristic: "?" (05:0xD8F3) + -- < |----- |Characteristic: "?" (04:0xC6E9) + -- +----- Service: "GATT" (01:0x1801) + -- < |----- |Characteristic: "Service Changed" (01:0x2A05) + +[Pipe Map] + +Pipe Store Type Service Char. CPF Desc. +---- ------ ------ ---------- --------- ----------- --------- +01 Local TX_ACK 01:0x1801 01:0x2A05 -- -- +02 Local SET 01:0x1804 01:0x2A07 -- -- +03 Local RX 01:0x1802 01:0x2A06 -- -- +04 Local RX_AA 01:0x1803 01:0x2A06 -- -- +05 Local TX 01:0x180F 01:0x2A19 -- -- +06 Local SET 01:0x180F 01:0x2A19 -- -- +07 Local SET 01:0x180A 01:0x2A27 -- -- +08 Remote TX 01:0x1802 01:0x2A06 -- -- +09 Remote RX 02:0xF431 03:0x120D -- -- +10 Remote TX_ACK 02:0xF431 05:0xD8F3 -- -- +11 Remote RX 02:0xF431 04:0xC6E9 -- -- +12 Remote RX_ACK 01:0x1801 01:0x2A05 -- -- + +[Setup Data] + +07-06-00-00-03-02-41-FE +1F-06-10-00-01-00-00-00-02-03-06-05-0C-01-01-00-00-06-00-03-00-00-00-00-00-00-00-00-00-00-00-00 +1F-06-10-1C-00-00-10-00-00-00-00-00-00-00-00-00-00-F4-31-02-00-00-40-10-00-00-40-10-03-90-04-64 +1F-06-10-38-02-FF-02-58-63-05-00-00-08-40-00-00-08-40-00-00-00-00-00-00-00-00-01-00-01-00-00-00 +05-06-10-54-01-01 +1F-06-20-00-04-04-02-02-00-01-28-00-01-00-18-04-04-05-05-00-02-28-03-01-02-03-00-00-2A-04-04-14 +1F-06-20-1C-09-00-03-2A-00-01-41-4E-43-53-20-52-75-73-6B-69-2E-63-6F-6D-00-00-00-00-00-00-04-04 +1F-06-20-38-05-05-00-04-28-03-01-02-05-00-01-2A-06-04-03-02-00-05-2A-01-01-40-02-04-04-05-05-00 +1F-06-20-54-06-28-03-01-02-07-00-04-2A-06-04-09-08-00-07-2A-04-01-90-01-20-03-00-00-58-02-04-04 +1F-06-20-70-02-02-00-08-28-00-01-01-18-04-04-05-05-00-09-28-03-01-22-0A-00-05-2A-26-0C-05-04-00 +1F-06-20-8C-0A-2A-05-01-00-00-00-00-46-34-03-02-00-0B-29-02-01-00-00-04-04-02-02-00-0C-28-00-01 +1F-06-20-A8-04-18-04-04-05-05-00-0D-28-03-01-02-0E-00-07-2A-06-0C-02-01-00-0E-2A-07-01-00-04-04 +1F-06-20-C4-02-02-00-0F-28-00-01-02-18-04-04-05-05-00-10-28-03-01-04-11-00-06-2A-46-30-02-01-00 +1F-06-20-E0-11-2A-06-01-00-04-04-02-02-00-12-28-00-01-03-18-04-04-05-05-00-13-28-03-01-0A-14-00 +1F-06-20-FC-06-2A-46-3C-02-01-00-14-2A-06-01-00-04-04-02-02-00-15-28-00-01-0F-18-04-04-05-05-00 +1F-06-21-18-16-28-03-01-12-17-00-19-2A-16-0C-02-01-00-17-2A-19-01-64-46-34-03-02-00-18-29-02-01 +1F-06-21-34-00-00-04-04-02-02-00-19-28-00-01-0A-18-04-04-05-05-00-1A-28-03-01-02-1B-00-27-2A-04 +15-06-21-50-0C-09-00-00-1B-2A-27-01-00-00-00-00-00-00-00-00-00-00 +12-06-30-00-18-02-01-06-01-F4-31-02-07-03-18-01-01-0A-01 +1F-06-40-00-2A-05-01-00-04-04-00-0A-00-0B-2A-07-01-00-80-04-00-0E-00-00-2A-06-01-00-08-04-00-11 +1F-06-40-1C-00-00-2A-06-01-04-00-04-00-14-00-00-2A-19-01-00-82-04-00-17-00-18-2A-27-01-00-80-04 +1F-06-40-38-00-1B-00-00-2A-06-01-00-02-04-00-00-00-00-12-0D-03-00-08-04-00-00-00-00-D8-F3-05-00 +1D-06-40-54-04-04-00-00-00-00-C6-E9-04-00-08-04-00-00-00-00-2A-05-01-00-10-04-00-00-00-00 +1F-06-50-00-D0-00-2D-12-1E-4B-0F-A4-99-4E-CE-B5-00-00-05-79-BD-1D-A2-99-E6-25-58-8C-D9-42-01-63 +1F-06-50-1C-00-00-BF-9F-FB-7B-7C-CE-6A-B3-44-BE-B5-4B-D6-24-00-00-EA-22-D9-D9-AA-FD-BD-9B-21-98 +0B-06-50-38-A8-49-E1-45-00-00-D1-69 +1F-06-60-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 +08-06-60-1C-00-00-00-00-00 +19-06-70-00-19-02-40-02-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 +06-06-F0-00-83-E6-90 From a931365c1dd1bf061b25296bcc6312ccfbd4ddff Mon Sep 17 00:00:00 2001 From: Skjerve Date: Tue, 26 Aug 2014 13:00:30 +0200 Subject: [PATCH 2/4] Added some structs for ANCS events --- .../BLE/examples/ble_ANCS_template/ancs.h | 72 ++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/libraries/BLE/examples/ble_ANCS_template/ancs.h b/libraries/BLE/examples/ble_ANCS_template/ancs.h index ac46979..17d5ba8 100644 --- a/libraries/BLE/examples/ble_ANCS_template/ancs.h +++ b/libraries/BLE/examples/ble_ANCS_template/ancs.h @@ -20,7 +20,77 @@ */ #include - + +#define ANCS_ATTRIBUTE_DATA_MAX 32 /*<< Maximium notification attribute data length. */ + +/**@brief Category IDs for iOS notifications. */ +typedef enum +{ + BLE_ANCS_CATEGORY_ID_OTHER, + BLE_ANCS_CATEGORY_ID_INCOMING_CALL, + BLE_ANCS_CATEGORY_ID_MISSED_CALL, + BLE_ANCS_CATEGORY_ID_VOICE_MAIL, + BLE_ANCS_CATEGORY_ID_SOCIAL, + BLE_ANCS_CATEGORY_ID_SCHEDULE, + BLE_ANCS_CATEGORY_ID_EMAIL, + BLE_ANCS_CATEGORY_ID_NEWS, + BLE_ANCS_CATEGORY_ID_HEALTH_AND_FITNESS, + BLE_ANCS_CATEGORY_ID_BUSINESS_AND_FINANCE, + BLE_ANCS_CATEGORY_ID_LOCATION, + BLE_ANCS_CATEGORY_ID_ENTERTAINMENT +} ble_ancs_category_id_values_t; + +/**@brief Event IDs for iOS notifications. */ +typedef enum +{ + BLE_ANCS_EVENT_ID_NOTIFICATION_ADDED, + BLE_ANCS_EVENT_ID_NOTIFICATION_MODIFIED, + BLE_ANCS_EVENT_ID_NOTIFICATION_REMOVED +} ble_ancs_event_id_values_t; + +/**@brief Control point command IDs. */ +typedef enum +{ + BLE_ANCS_COMMAND_ID_GET_NOTIFICATION_ATTRIBUTES, + BLE_ANCS_COMMAND_ID_GET_APP_ATTRIBUTES +} ble_ancs_command_id_values_t; + +/**@brief Event flags for iOS notifications. */ +#define BLE_ANCS_EVENT_FLAG_SILENT (1 << 0) +#define BLE_ANCS_EVENT_FLAG_IMPORTANT (1 << 1) + +/**@brief Notification attribute IDs. */ +typedef enum +{ + BLE_ANCS_NOTIFICATION_ATTRIBUTE_ID_APP_IDENTIFIER, + BLE_ANCS_NOTIFICATION_ATTRIBUTE_ID_TITLE, + BLE_ANCS_NOTIFICATION_ATTRIBUTE_ID_SUBTITLE, + BLE_ANCS_NOTIFICATION_ATTRIBUTE_ID_MESSAGE, + BLE_ANCS_NOTIFICATION_ATTRIBUTE_ID_MESSAGE_SIZE, + BLE_ANCS_NOTIFICATION_ATTRIBUTE_ID_DATE, +} ble_ancs_notification_attribute_id_values_t; + +typedef struct { + uint8_t event_id; + uint8_t event_flags; + uint8_t category_id; + uint8_t category_count; + uint8_t notification_uid[4]; +} ble_ancs_c_evt_ios_notification_t; + +typedef struct { + uint8_t command_id; + uint8_t notification_uid[4]; + uint8_t attribute_id; + uint16_t attribute_len; + uint8_t data[ANCS_ATTRIBUTE_DATA_MAX]; +} ble_ancs_c_evt_notif_attribute_t; + +typedef struct { + uint8_t attribute_id; + uint16_t attribute_len; +} ble_ancs_attr_list_t; + /** @brief Function to handle reception of data for ANCS. * @details Call this function on the ACI_EVT_DATA_RECEIVED event. This function checks if the data received is for ANCS. * If so it prints the received data to the Serial interface. From 7090bb840be961f299f68af8bfa33d8d654a57e6 Mon Sep 17 00:00:00 2001 From: Skjerve Date: Wed, 27 Aug 2014 12:11:58 +0200 Subject: [PATCH 3/4] Added separate functions for notify and data events --- .../BLE/examples/ble_ANCS_template/ancs.cpp | 14 ++++++------- .../BLE/examples/ble_ANCS_template/ancs.h | 4 +++- .../ble_ANCS_template/ble_ANCS_template.ino | 21 ++++++++++++++----- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/libraries/BLE/examples/ble_ANCS_template/ancs.cpp b/libraries/BLE/examples/ble_ANCS_template/ancs.cpp index d08be66..cc8db2d 100644 --- a/libraries/BLE/examples/ble_ANCS_template/ancs.cpp +++ b/libraries/BLE/examples/ble_ANCS_template/ancs.cpp @@ -25,26 +25,24 @@ #include "ancs.h" -void ancs_evt_rcvd(uint8_t pipe_num, uint8_t *buffer) +void ancs_notification_evt_rcvd(uint8_t pipe_num, uint8_t *buffer) { - switch (pipe_num) - { - case PIPE_ANCS_NOTIFICATION_SOURCE_RX : Serial.print(F("PIPE_ANCS_NOTIFICATION_SOURCE_RX: ")); for(uint8_t counter = 0; counter <= 20; counter++) { Serial.write(buffer[counter]); //uint8_t file_name[20]; } Serial.println(); - break; +} - case PIPE_ANCS_DATA_SOURCE_RX : +void ancs_data_evt_rcvd(uint8_t pipe_num, uint8_t *buffer) +{ Serial.print(F("PIPE_ANCS_DATA_SOURCE_RX: ")); for(uint8_t counter = 0; counter <= ACI_PIPE_RX_DATA_MAX_LEN; counter++) { Serial.write(buffer[counter]); //uint8_t file_name[20]; } Serial.println(); - break; - } + } + diff --git a/libraries/BLE/examples/ble_ANCS_template/ancs.h b/libraries/BLE/examples/ble_ANCS_template/ancs.h index 17d5ba8..787df44 100644 --- a/libraries/BLE/examples/ble_ANCS_template/ancs.h +++ b/libraries/BLE/examples/ble_ANCS_template/ancs.h @@ -97,4 +97,6 @@ typedef struct { * @param pipe_num Pipe which has received data. * @param buffer Pointer to the received data. */ - void ancs_evt_rcvd(uint8_t pipe_num, uint8_t *buffer); + void ancs_notification_evt_rcvd(uint8_t pipe_num, uint8_t *buffer); + +void ancs_data_evt_rcvd(uint8_t pipe_num, uint8_t *buffer); diff --git a/libraries/BLE/examples/ble_ANCS_template/ble_ANCS_template.ino b/libraries/BLE/examples/ble_ANCS_template/ble_ANCS_template.ino index 3a7569a..e64eb25 100644 --- a/libraries/BLE/examples/ble_ANCS_template/ble_ANCS_template.ino +++ b/libraries/BLE/examples/ble_ANCS_template/ble_ANCS_template.ino @@ -526,9 +526,20 @@ void aci_loop() Serial.println(aci_evt->params.data_received.rx_data.aci_data[0], DEC); link_loss_pipes_updated_evt_rcvd(aci_evt->params.data_received.rx_data.pipe_number, &aci_evt->params.data_received.rx_data.aci_data[0]); - //ancs_evt_rcvd(aci_evt->params.data_received.rx_data.pipe_number, - // &aci_evt->params.data_received.rx_data.aci_data[0]); - if (PIPE_ANCS_NOTIFICATION_SOURCE_RX==aci_evt->params.data_received.rx_data.pipe_number) + + switch (aci_evt->params.data_received.rx_data.pipe_number) + { + case PIPE_ANCS_NOTIFICATION_SOURCE_RX : + ancs_notification_evt_rcvd(aci_evt->params.data_received.rx_data.pipe_number, + &aci_evt->params.data_received.rx_data.aci_data[0]); + break; + + case PIPE_ANCS_DATA_SOURCE_RX : + ancs_data_evt_rcvd(aci_evt->params.data_received.rx_data.pipe_number, + &aci_evt->params.data_received.rx_data.aci_data[0]); + break; + } + /* if (PIPE_ANCS_NOTIFICATION_SOURCE_RX==aci_evt->params.data_received.rx_data.pipe_number) { Serial.print(F("PIPE_ANCS_NOTIFICATION_SOURCE_RX: ")); for(uint8_t counter = 0; counter <= 20; counter++) @@ -545,8 +556,8 @@ void aci_loop() Serial.write(aci_evt->params.data_received.rx_data.aci_data[counter]); //uint8_t file_name[20]; } Serial.println(); - } - break; + }*/ + //break; case ACI_EVT_DATA_CREDIT: aci_state.data_credit_available = aci_state.data_credit_available + aci_evt->params.data_credit.credit; From 96753dbd4bc9a10ecca144f44bdef30e84eaf4c9 Mon Sep 17 00:00:00 2001 From: Skjerve Date: Fri, 29 Aug 2014 15:29:58 +0200 Subject: [PATCH 4/4] Updated release notes --- Release notes.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Release notes.md b/Release notes.md index 7985dfd..bbab5b6 100644 --- a/Release notes.md +++ b/Release notes.md @@ -1,3 +1,11 @@ +#Release notes 0.9.4: + +##Changes: +* Added limited ANCS template +* Removed sleep.h for !defined(__SAM3X8E__) && !defined(__PIC32MX__) +* Attempted to reduce RAM usage + + #Release notes 0.9.3: ##Changes: