encodings: Added check for non-8bit encodings in src tree.

This commit sanitizes source files for unicode encodings which
cause failures in downstream flows (docgen, python2 module loading,
etc...).

    * Removed explicit encodings from src files
    * Replaced 2 byte character encodings with ascii encodies:
        ± -> +/-
        ° -> deg
        “ -> "
        etc...
    * Added ctest to check src tree files for non-8bit encodings

Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:
Noel Eck 2016-10-05 13:36:56 -07:00
parent 131947dc74
commit edd8df4c50
46 changed files with 5721 additions and 5660 deletions

View File

@ -1,4 +1,4 @@
/*
/*
* Author: Marc Graham <marc@m2ag.net>
* Copyright (c) 2015 Intel Corporation.
*
@ -71,12 +71,12 @@ namespace upm {
* Data is transferred via an I2C-compatible serial interface; four I2C slave addresses can be selected. The ADS1013/4/5
* operate from a single power supply ranging from 2.0V to 5.5V.
* The ADS1013/4/5 can perform conversions at rates up to 3300 samples per second (SPS). An onboard PGA is available
* on the ADS1014 and ADS1015 that offers input ranges from the supply to as low as ±256mV, allowing both large and small
* on the ADS1014 and ADS1015 that offers input ranges from the supply to as low as +/- 256mV, allowing both large and small
* signals to be measured with high resolution. The ADS1015 also features an input multiplexer (MUX) that provides two
* differential or four single-ended inputs.
* The ADS1013/4/5 operate either in continuous conversion mode or a single-shot mode that automatically powers down
* after a conversion and greatly reduces current consumption during idle periods. The ADS1013/4/5 are specified from
* 40°C to +125°C.
* -40 deg C to +125 deg C.
*
* Tested with Adafriut ADS1015 board: https://www.adafruit.com/products/1083
*

View File

@ -1,4 +1,4 @@
/*
/*
* Author: Marc Graham <marc@m2ag.net>
* Copyright (c) 2015 Intel Corporation.
*
@ -71,11 +71,11 @@ namespace upm {
* an I2C-compatible serial interface; four I2C slave addresses can be selected. The ADS1113/4/5 operate from a single power
* supply ranging from 2.0V to 5.5V.
* The ADS1113/4/5 can perform conversions at rates up to 860 samples per second (SPS). An onboard PGA is available on
* the ADS1114 and ADS1115 that offers input ranges from the supply to as low as ±256mV, allowing both large and small
* the ADS1114 and ADS1115 that offers input ranges from the supply to as low as +/- 256mV, allowing both large and small
* signals to be measured with high resolution. The ADS1115 also features an input multiplexer (MUX) that provides two
* differential or four single-ended inputs.
* The ADS1113/4/5 operate either in continuous conversion mode or a single-shot mode that automatically powers down after
* a conversion and greatly reduces current consumption during idle periods. The ADS1113/4/5 are specified from 40°C to +125°C.
* a conversion and greatly reduces current consumption during idle periods. The ADS1113/4/5 are specified from -40 deg C to +125 deg C.
*
* Tested with DIYMall ADS1115 board. Also available from Adafruit: https://www.adafruit.com/products/1085
*

View File

@ -48,7 +48,7 @@ namespace upm {
*
* ADXL345 is a 3-axis digital accelerometer.
* (http://www.seeedstudio.com/wiki/images/2/2c/ADXL345_datasheet.pdf)
* The sensor has configurable resolutions to measure ±2g, ±4g, ±8g, or ±16g.
* The sensor has configurable resolutions to measure +/- 2g, +/- 4g, +/- 8g, or +/- 16g.
* Note: The Grove* version of the sensor is incompatible with and not detected
* on the I2C bus by the Intel(R) Edison using an Arduino* breakout board at 5V
* (3V works fine).

View File

@ -54,7 +54,7 @@ namespace upm {
* The BME280 is as combined digital humidity, pressure and
* temperature sensor based on proven sensing principles. The sensor
* module is housed in an extremely compact metal-lid LGA package
* with a footprint of only 2.5 × 2.5 mm2 with a height of 0.93
* with a footprint of only 2.5 * 2.5 mm2 with a height of 0.93
* mm. Its small dimensions and its low power consumption allow the
* implementation in battery driven devices such as handsets, GPS
* modules or watches. The BME280 is register and performance

View File

@ -538,7 +538,7 @@ void BMP280::csOff()
// These functions come from the BMP280 datasheet, section 3.11.3
// Returns temperature in DegC, resolution is 0.01 DegC. Output value
// of “5123” equals 51.23 DegC. t_fine carries fine temperature as
// of "5123" equals 51.23 DegC. t_fine carries fine temperature as
// global value
int32_t BMP280::bmp280_compensate_T_int32(int32_t adc_T)
{

View File

@ -58,8 +58,8 @@ namespace upm {
* The BMP280 is an absolute barometric pressure sensor especially
* designed for mobile applications. The sensor module is housed in
* an extremely compact 8-pin metal-lid LGA package with a footprint
* of only 2.0 × 2.5 mm2 and 0.95 mm package height. Its small
* dimensions and its low power consumption of 2.7 μA @1Hz allow the
* of only 2.0 * 2.5 mm2 and 0.95 mm package height. Its small
* dimensions and its low power consumption of 2.7 uA @1Hz allow the
* implementation in battery driven devices such as mobile phones,
* GPS modules or watches.
*

View File

@ -45,7 +45,7 @@ namespace upm {
* detection of movements and rotations in 6 degrees of freedom
* (6DoF). It reflects the full functionality of a triaxial, low-g
* acceleration sensor and at the same time it is capable to measure
* angular rates. Both acceleration and angular rate in three
* angular rates. Both - acceleration and angular rate - in three
* perpendicular room dimensions, the x-, y- and z-axis.
*
* The BMI055 is essentially 2 separate devices in one: the BMA250E

View File

@ -48,7 +48,7 @@ namespace upm {
*
* The BMM150 is a standalone geomagnetic sensor for consumer market
* applications. It allows measurements of the magnetic field in
* three perpendicular axes. Based on Boschs proprietary FlipCore
* three perpendicular axes. Based on Bosch's proprietary FlipCore
* technology, performance and features of BMM150 are carefully
* tuned and perfectly match the demanding requirements of all
* 3-axis mobile applications such as electronic compass, navigation

View File

@ -51,7 +51,7 @@ namespace upm {
*
* The BNO055 is a System in Package (SiP), integrating a triaxial
* 14-bit accelerometer, a triaxial 16-bit gyroscope with a range of
* ±2000 degrees per second, a triaxial geomagnetic sensor and a
* +/- 2000 degrees per second, a triaxial geomagnetic sensor and a
* 32-bit cortex M0+ microcontroller running Bosch Sensortec sensor
* fusion software, in a single package.
*

View File

@ -1,6 +1,6 @@
include_directories(..)
set (libname "ds1808lc")
set (libdescription “DS1808 lighting controller”)
set (libdescription "DS1808 lighting controller")
set (module_src ${libname}.cxx mraa-utils.cxx)
set (module_hpp ${libname}.hpp)
upm_module_init()

View File

@ -54,7 +54,7 @@ namespace upm {
*
* @brief API for the DS2413 1-Wire Dual Channel Addressable Switch
*
* The DS2413 is a dual-channel programmable I/O 1-Wire® chip. The
* The DS2413 is a dual-channel programmable I/O 1-Wire(r) chip. The
* PIO outputs are configured as open-drain and provide up to 20mA
* continuous sink capability and off-state operating voltage up
* to 28V. Control and sensing of the PIO pins is performed with

View File

@ -82,7 +82,7 @@ namespace upm {
typedef enum {
FORMAT_VGA = 7, // 640x480
FORMAT_CIF = 5, // 352×288
FORMAT_CIF = 5, // 352*288
FORMAT_OCIF = 3 // ??? (maybe they meant QCIF?)
} PIC_FORMATS_T;

View File

@ -1,6 +1,6 @@
include_directories(..)
set (libname "hlg150h")
set (libdescription “Lighting power supply”)
set (libdescription "Lighting power supply")
set (module_src ${libname}.cxx mraa-utils.cxx)
set (module_hpp ${libname}.hpp)
upm_module_init()

View File

@ -47,7 +47,7 @@ const uint8_t DISPLAY_CMD_SET_NORMAL_1308 = 0xA6;
* @brief API for SSD1308 I2C-controlled OLED displays
*
* SSD1308 is a 128x64 dot-matrix OLED/PLED segment driver with a
* controller. This implementation was tested using the Grove LED 128×64
* controller. This implementation was tested using the Grove LED 128*64
* Display module, which is an OLED monochrome display.
*
* @image html ssd1308.jpeg

View File

@ -47,7 +47,7 @@ const uint8_t DISPLAY_CMD_SET_NORMAL = 0xA4;
* @brief API for SSD1327 I2C-controlled OLED displays
*
* SSD1327 is a 96x96 dot-matrix OLED/PLED segment driver with a controller.
* This implementation was tested using the Grove LED 96×96 Display module,
* This implementation was tested using the Grove LED 96*96 Display module,
* which is an OLED monochrome display.
*
* @image html ssd1327.jpeg

View File

@ -1,6 +1,6 @@
include_directories(..)
set (libname "lp8860")
set (libdescription “LED lighting controller”)
set (libdescription "LED lighting controller")
set (module_src ${libname}.cxx mraa-utils.cxx)
set (module_hpp ${libname}.hpp)
upm_module_init()

View File

@ -1,5 +1,5 @@
set (libname "lpd8806")
set (libdescription “Digital RGB LED strip”)
set (libdescription "Digital RGB LED strip")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
upm_module_init()

View File

@ -91,7 +91,7 @@ namespace upm {
*
* The Maxim Integrated
* [MAX44009](http://datasheets.maximintegrated.com/en/ds/MAX44009.pdf)
* is Industrys Lowest-Power Ambient Light Sensor with ADC.
* is Industry's Lowest-Power Ambient Light Sensor with ADC.
*
* @library max44009
* @sensor max44009

View File

@ -59,8 +59,8 @@ namespace upm {
*
* @brief API for MCP9808 precision temprature sensor
*
* The MCP9808 digital temperature sensor converts temperatures between -20°C and +100°C
* to a digital word with ±0.5°C (max.) accuracy. The MCP9808 comes with user-programmable
* The MCP9808 digital temperature sensor converts temperatures between -20 deg C and +100 deg C
* to a digital word with +/- 0.5 deg C (max.) accuracy. The MCP9808 comes with user-programmable
* registers that provide flexibility for temperature sensing applications. The registers
* allow user-selectable settings such as Shutdown or low-power modes and the specification
* of temperature Event and Critical output boundaries. When the temperature changes beyond
@ -133,10 +133,10 @@ namespace upm {
* @var MCP9808_CONFIG::ALERTMODE - Alert Output Mode bit
* 0 = Comparator output (power-up default)
* 1 = Interrupt output
* @var MCP9808_CONFIG::HYST_0 : 0°C
* @var MCP9808_CONFIG::HYST_1_5 : +1.5°C
* @var MCP9808_CONFIG::HYST_3_0 : +3.0°C
* @var MCP9808_CONFIG::HYST_6_0 : +6.0°C
* @var MCP9808_CONFIG::HYST_0 : 0 deg C
* @var MCP9808_CONFIG::HYST_1_5 : +1.5 deg C
* @var MCP9808_CONFIG::HYST_3_0 : +3.0 deg C
* @var MCP9808_CONFIG::HYST_6_0 : +6.0 deg C
*/
typedef enum
{

View File

@ -44,7 +44,7 @@ namespace upm {
*
* @brief API for the MPU60X0 3-axis Gyroscope and 3-axis Accelerometer
*
* The MPU60X0 devices provide the worlds first integrated 6-axis
* The MPU60X0 devices provide the world's first integrated 6-axis
* motion processor solution that eliminates the package-level
* gyroscope and accelerometer cross-axis misalignment associated
* with discrete solutions. The devices combine a 3-axis gyroscope
@ -401,7 +401,7 @@ namespace upm {
*
* MST_DLY is not enumerated in the register map. It configures
* the reduced access rate of i2c slaves relative to the sample
* rate. When a slaves access rate is decreased relative to the
* rate. When a slave's access rate is decreased relative to the
* Sample Rate, the slave is accessed every
* 1 / (1 + I2C_MST_DLY) samples
*/

View File

@ -1,6 +1,6 @@
include_directories(..)
set (libname "ms5611")
set (libdescription “Pressure and temperature sensor”)
set (libdescription "Pressure and temperature sensor")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
upm_module_init()

File diff suppressed because it is too large Load Diff

View File

@ -1,433 +1,433 @@
/* 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.
*/
/**
* @file
* @ingroup aci
* @brief Definitions for the ACI (Application Control Interface) commands
* @remarks
*
*/
#ifndef ACI_CMDS_H__
#define ACI_CMDS_H__
#include "aci.h"
/**
* @enum aci_cmd_opcode_t
* @brief ACI command opcodes
*/
typedef enum
{
/**
* Enter test mode
*/
ACI_CMD_TEST = 0x01,
/**
* Echo (loopback) test command
*/
ACI_CMD_ECHO = 0x02,
/**
* Send a BTLE DTM command to the radio
*/
ACI_CMD_DTM_CMD = 0x03,
/**
* Put the device to sleep
*/
ACI_CMD_SLEEP = 0x04,
/**
* Wakeup the device from deep sleep
*/
ACI_CMD_WAKEUP = 0x05,
/**
* Replace the contents of the internal database with
* user provided data
*/
ACI_CMD_SETUP = 0x06,
/**
* Read the portions of memory required to be restored after a power cycle
*/
ACI_CMD_READ_DYNAMIC_DATA = 0x07,
/**
* Write back the data retrieved using ACI_CMD_READ_DYNAMIC_DATA
*/
ACI_CMD_WRITE_DYNAMIC_DATA = 0x08,
/**
* Retrieve the device's version information
*/
ACI_CMD_GET_DEVICE_VERSION = 0x09,
/**
* Request the Bluetooth address and its type
*/
ACI_CMD_GET_DEVICE_ADDRESS = 0x0A,
/**
* Request the battery level measured by nRF8001
*/
ACI_CMD_GET_BATTERY_LEVEL = 0x0B,
/**
* Request the temperature value measured by nRF8001
*/
ACI_CMD_GET_TEMPERATURE = 0x0C,
/**
* Write to the local Attribute Database
*/
ACI_CMD_SET_LOCAL_DATA = 0x0D,
/**
* Reset the baseband and radio and go back to idle
*/
ACI_CMD_RADIO_RESET = 0x0E,
/**
* Start advertising and wait for a master connection
*/
ACI_CMD_CONNECT = 0x0F,
/**
* Start advertising and wait for a master connection
*/
ACI_CMD_BOND = 0x10,
/**
* Start advertising and wait for a master connection
*/
ACI_CMD_DISCONNECT = 0x11,
/**
* Throttles the Radio transmit power
*/
ACI_CMD_SET_TX_POWER = 0x12,
/**
* Trigger a connection parameter update
*/
ACI_CMD_CHANGE_TIMING = 0x13,
/**
* Open a remote pipe for data reception
*/
ACI_CMD_OPEN_REMOTE_PIPE = 0x14,
/**
* Transmit data over an open pipe
*/
ACI_CMD_SEND_DATA = 0x15,
/**
* Send an acknowledgment of received data
*/
ACI_CMD_SEND_DATA_ACK = 0x16,
/**
* Request data over an open pipe
*/
ACI_CMD_REQUEST_DATA = 0x17,
/**
* NACK a data reception
*/
ACI_CMD_SEND_DATA_NACK = 0x18,
/**
* Set application latency
*/
ACI_CMD_SET_APP_LATENCY = 0x19,
/**
* Set a security key
*/
ACI_CMD_SET_KEY = 0x1A,
/**
* Open Advertising Pipes
*/
ACI_CMD_OPEN_ADV_PIPE = 0x1B,
/**
* Start non-connectable advertising
*/
ACI_CMD_BROADCAST = 0x1C,
/**
* Start a security request in bonding mode
*/
ACI_CMD_BOND_SECURITY_REQUEST = 0x1D,
/**
* Start Directed advertising towards a Bonded Peer
*/
ACI_CMD_CONNECT_DIRECT = 0x1E,
/**
* Close a previously opened remote pipe
*/
ACI_CMD_CLOSE_REMOTE_PIPE = 0x1F,
/**
* Invalid ACI command opcode
*/
ACI_CMD_INVALID = 0xFF
} _aci_packed_ aci_cmd_opcode_t;
ACI_ASSERT_SIZE(aci_cmd_opcode_t, 1);
/**
* @struct aci_cmd_params_test_t
* @brief Structure for the ACI_CMD_TEST ACI command parameters
*/
typedef struct
{
aci_test_mode_change_t test_mode_change; /**< enum aci_test_mode_change_t */
} _aci_packed_ aci_cmd_params_test_t;
ACI_ASSERT_SIZE(aci_cmd_params_test_t, 1);
/**
* @struct aci_cmd_params_echo_t
* @brief Structure for the ACI_CMD_ECHO ACI command parameters
*/
typedef struct
{
uint8_t echo_data[ACI_ECHO_DATA_MAX_LEN];
} _aci_packed_ aci_cmd_params_echo_t;
ACI_ASSERT_SIZE(aci_cmd_params_echo_t, ACI_ECHO_DATA_MAX_LEN);
/**
* @struct aci_cmd_params_dtm_cmd_t
* @brief Structure for the ACI_CMD_DTM_CMD ACI command parameters
*/
typedef struct
{
uint8_t cmd_msb;
uint8_t cmd_lsb;
} _aci_packed_ aci_cmd_params_dtm_cmd_t;
/**
* @struct aci_cmd_params_setup_t
* @brief Structure for the ACI_CMD_SETUP ACI command parameters
*/
typedef struct
{
uint8_t setup_data[1];
} _aci_packed_ aci_cmd_params_setup_t;
ACI_ASSERT_SIZE(aci_cmd_params_setup_t, 1);
/**
* @struct aci_cmd_params_write_dynamic_data_t
* @brief Structure for the ACI_CMD_WRITE_DYNAMIC_DATA ACI command parameters
* @note Dynamic data chunk size in this command is defined to go up to ACI_PACKET_MAX_LEN - 3
*/
typedef struct
{
uint8_t seq_no;
uint8_t dynamic_data[1];
} _aci_packed_ aci_cmd_params_write_dynamic_data_t;
/**
* @define aci_cmd_params_set_local_data_t
* @brief Structure for the ACI_CMD_SET_LOCAL_DATA ACI command parameters
*/
typedef struct
{
aci_tx_data_t tx_data;
} _aci_packed_ aci_cmd_params_set_local_data_t;
/**
* @struct aci_cmd_params_connect_t
* @brief Structure for the ACI_CMD_CONNECT ACI command parameters
*/
typedef struct
{
uint16_t timeout; /**< 0x0000 (no timeout) to 0x3FFF */
uint16_t adv_interval; /**< 16 bits of advertising interval for general discovery */
} _aci_packed_ aci_cmd_params_connect_t;
ACI_ASSERT_SIZE(aci_cmd_params_connect_t, 4);
/**
* @define aci_cmd_params_bond_t
* @brief Structure for the ACI_CMD_BOND ACI command parameters
*/
typedef struct
{
uint16_t timeout; /**< 0x0000 (no timeout) to 0x3FFF */
uint16_t adv_interval; /**< 16 bits of advertising interval for general discovery */
} _aci_packed_ aci_cmd_params_bond_t;
ACI_ASSERT_SIZE(aci_cmd_params_bond_t, 4);
/**
* @struct aci_cmd_params_disconnect_t
* @brief Structure for the ACI_CMD_DISCONNECT ACI command parameters
*/
typedef struct
{
aci_disconnect_reason_t reason; /**< enum aci_disconnect_reason_t */
} _aci_packed_ aci_cmd_params_disconnect_t;
ACI_ASSERT_SIZE(aci_cmd_params_disconnect_t, 1);
/**
* @struct aci_cmd_params_set_tx_power_t
* @brief Structure for the ACI_CMD_SET_TX_POWER ACI command parameters
*/
typedef struct
{
aci_device_output_power_t device_power; /**< enum aci_device_output_power_t */
} _aci_packed_ aci_cmd_params_set_tx_power_t;
ACI_ASSERT_SIZE(aci_cmd_params_set_tx_power_t, 1);
/**
* @struct aci_cmd_params_change_timing_t
* @brief Structure for the ACI_CMD_CHANGE_TIMING ACI command parameters
*/
typedef struct
{
aci_ll_conn_params_t conn_params;
} _aci_packed_ aci_cmd_params_change_timing_t;
ACI_ASSERT_SIZE(aci_cmd_params_change_timing_t, 8);
/**
* @struct aci_cmd_params_open_remote_pipe_t
* @brief Structure for the ACI_CMD_OPEN_REMOTE_PIPE ACI command parameters
*/
typedef struct
{
uint8_t pipe_number;
} _aci_packed_ aci_cmd_params_open_remote_pipe_t;
/**
* @struct aci_cmd_params_send_data_t
* @brief Structure for the ACI_CMD_SEND_DATA ACI command parameters
*/
typedef struct
{
aci_tx_data_t tx_data;
} _aci_packed_ aci_cmd_params_send_data_t;
/**
* @define aci_cmd_params_send_data_ack_t
* @brief Structure for the ACI_CMD_SEND_DATA_ACK ACI command parameters
*/
typedef struct
{
uint8_t pipe_number;
} _aci_packed_ aci_cmd_params_send_data_ack_t;
/**
* @struct aci_cmd_params_send_data_t
* @brief Structure for the ACI_CMD_SEND_DATA ACI command parameters
*/
typedef struct
{
uint8_t pipe_number;
} _aci_packed_ aci_cmd_params_request_data_t;
/**
* @define aci_cmd_params_send_data_nack_t
* @brief Structure for the ACI_CMD_SEND_DATA_NACK ACI command parameters
*/
typedef struct
{
uint8_t pipe_number;
uint8_t error_code;
} _aci_packed_ aci_cmd_params_send_data_nack_t;
ACI_ASSERT_SIZE(aci_cmd_params_send_data_nack_t, 2);
/**
* @define aci_cmd_params_set_app_latency_t
* @brief Structure for the ACI_CMD_SET_APP_LATENCY ACI command parameters
*/
typedef struct
{
aci_app_latency_mode_t mode;
uint16_t latency;
} _aci_packed_ aci_cmd_params_set_app_latency_t;
ACI_ASSERT_SIZE(aci_cmd_params_set_app_latency_t, 3);
/**
* @define aci_cmd_params_set_key_t
* @brief Structure for the ACI_CMD_SET_KEY ACI command parameters
*/
typedef struct
{
aci_key_type_t key_type;
union
{
uint8_t passkey[6];
uint8_t oob_key[16];
} key;
} _aci_packed_ aci_cmd_params_set_key_t;
ACI_ASSERT_SIZE(aci_cmd_params_set_key_t, 17);
/**
* @define aci_cmd_params_open_adv_pipe_t
* @brief Structure for the ACI_CMD_OPEN_ADV_PIPE ACI command parameters
*/
typedef struct
{
uint8_t pipes[8];
} _aci_packed_ aci_cmd_params_open_adv_pipe_t;
/**
* @define aci_cmd_params_broadcast_t
* @brief Structure for the ACI_CMD_BROADCAST ACI command parameters
*/
typedef struct
{
uint16_t timeout; /**< 0x0000 (no timeout) to 0x3FFF */
uint16_t adv_interval; /**< 16 bits of advertising interval for general discovery */
} _aci_packed_ aci_cmd_params_broadcast_t;
/**
* @struct aci_cmd_params_close_remote_pipe_t
* @brief Structure for the ACI_CMD_CLOSE_REMOTE_PIPE ACI command parameters
*/
typedef struct
{
uint8_t pipe_number;
} _aci_packed_ aci_cmd_params_close_remote_pipe_t;
/**
* @struct aci_cmd_t
* @brief Encapsulates a generic ACI command
*/
typedef struct
{
uint8_t len; /**< Length of the ACI command */
aci_cmd_opcode_t cmd_opcode; /**< enum aci_cmd_opcode_t -> Opcode of the ACI command */
union
{
aci_cmd_params_test_t test;
aci_cmd_params_echo_t echo;
aci_cmd_params_dtm_cmd_t dtm_cmd;
aci_cmd_params_setup_t setup;
aci_cmd_params_write_dynamic_data_t write_dynamic_data;
aci_cmd_params_set_local_data_t set_local_data;
aci_cmd_params_connect_t connect;
aci_cmd_params_bond_t bond;
aci_cmd_params_disconnect_t disconnect;
aci_cmd_params_set_tx_power_t set_tx_power;
aci_cmd_params_change_timing_t change_timing;
aci_cmd_params_open_remote_pipe_t open_remote_pipe;
aci_cmd_params_send_data_t send_data;
aci_cmd_params_send_data_ack_t send_data_ack;
aci_cmd_params_request_data_t request_data;
aci_cmd_params_send_data_nack_t send_data_nack;
aci_cmd_params_set_app_latency_t set_app_latency;
aci_cmd_params_set_key_t set_key;
aci_cmd_params_open_adv_pipe_t open_adv_pipe;
aci_cmd_params_broadcast_t broadcast;
aci_cmd_params_close_remote_pipe_t close_remote_pipe;
} params;
} _aci_packed_ aci_cmd_t;
#endif // ACI_CMDS_H__
/* 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.
*/
/**
* @file
* @ingroup aci
* @brief Definitions for the ACI (Application Control Interface) commands
* @remarks
*
*/
#ifndef ACI_CMDS_H__
#define ACI_CMDS_H__
#include "aci.h"
/**
* @enum aci_cmd_opcode_t
* @brief ACI command opcodes
*/
typedef enum
{
/**
* Enter test mode
*/
ACI_CMD_TEST = 0x01,
/**
* Echo (loopback) test command
*/
ACI_CMD_ECHO = 0x02,
/**
* Send a BTLE DTM command to the radio
*/
ACI_CMD_DTM_CMD = 0x03,
/**
* Put the device to sleep
*/
ACI_CMD_SLEEP = 0x04,
/**
* Wakeup the device from deep sleep
*/
ACI_CMD_WAKEUP = 0x05,
/**
* Replace the contents of the internal database with
* user provided data
*/
ACI_CMD_SETUP = 0x06,
/**
* Read the portions of memory required to be restored after a power cycle
*/
ACI_CMD_READ_DYNAMIC_DATA = 0x07,
/**
* Write back the data retrieved using ACI_CMD_READ_DYNAMIC_DATA
*/
ACI_CMD_WRITE_DYNAMIC_DATA = 0x08,
/**
* Retrieve the device's version information
*/
ACI_CMD_GET_DEVICE_VERSION = 0x09,
/**
* Request the Bluetooth address and its type
*/
ACI_CMD_GET_DEVICE_ADDRESS = 0x0A,
/**
* Request the battery level measured by nRF8001
*/
ACI_CMD_GET_BATTERY_LEVEL = 0x0B,
/**
* Request the temperature value measured by nRF8001
*/
ACI_CMD_GET_TEMPERATURE = 0x0C,
/**
* Write to the local Attribute Database
*/
ACI_CMD_SET_LOCAL_DATA = 0x0D,
/**
* Reset the baseband and radio and go back to idle
*/
ACI_CMD_RADIO_RESET = 0x0E,
/**
* Start advertising and wait for a master connection
*/
ACI_CMD_CONNECT = 0x0F,
/**
* Start advertising and wait for a master connection
*/
ACI_CMD_BOND = 0x10,
/**
* Start advertising and wait for a master connection
*/
ACI_CMD_DISCONNECT = 0x11,
/**
* Throttles the Radio transmit power
*/
ACI_CMD_SET_TX_POWER = 0x12,
/**
* Trigger a connection parameter update
*/
ACI_CMD_CHANGE_TIMING = 0x13,
/**
* Open a remote pipe for data reception
*/
ACI_CMD_OPEN_REMOTE_PIPE = 0x14,
/**
* Transmit data over an open pipe
*/
ACI_CMD_SEND_DATA = 0x15,
/**
* Send an acknowledgment of received data
*/
ACI_CMD_SEND_DATA_ACK = 0x16,
/**
* Request data over an open pipe
*/
ACI_CMD_REQUEST_DATA = 0x17,
/**
* NACK a data reception
*/
ACI_CMD_SEND_DATA_NACK = 0x18,
/**
* Set application latency
*/
ACI_CMD_SET_APP_LATENCY = 0x19,
/**
* Set a security key
*/
ACI_CMD_SET_KEY = 0x1A,
/**
* Open Advertising Pipes
*/
ACI_CMD_OPEN_ADV_PIPE = 0x1B,
/**
* Start non-connectable advertising
*/
ACI_CMD_BROADCAST = 0x1C,
/**
* Start a security request in bonding mode
*/
ACI_CMD_BOND_SECURITY_REQUEST = 0x1D,
/**
* Start Directed advertising towards a Bonded Peer
*/
ACI_CMD_CONNECT_DIRECT = 0x1E,
/**
* Close a previously opened remote pipe
*/
ACI_CMD_CLOSE_REMOTE_PIPE = 0x1F,
/**
* Invalid ACI command opcode
*/
ACI_CMD_INVALID = 0xFF
} _aci_packed_ aci_cmd_opcode_t;
ACI_ASSERT_SIZE(aci_cmd_opcode_t, 1);
/**
* @struct aci_cmd_params_test_t
* @brief Structure for the ACI_CMD_TEST ACI command parameters
*/
typedef struct
{
aci_test_mode_change_t test_mode_change; /**< enum aci_test_mode_change_t */
} _aci_packed_ aci_cmd_params_test_t;
ACI_ASSERT_SIZE(aci_cmd_params_test_t, 1);
/**
* @struct aci_cmd_params_echo_t
* @brief Structure for the ACI_CMD_ECHO ACI command parameters
*/
typedef struct
{
uint8_t echo_data[ACI_ECHO_DATA_MAX_LEN];
} _aci_packed_ aci_cmd_params_echo_t;
ACI_ASSERT_SIZE(aci_cmd_params_echo_t, ACI_ECHO_DATA_MAX_LEN);
/**
* @struct aci_cmd_params_dtm_cmd_t
* @brief Structure for the ACI_CMD_DTM_CMD ACI command parameters
*/
typedef struct
{
uint8_t cmd_msb;
uint8_t cmd_lsb;
} _aci_packed_ aci_cmd_params_dtm_cmd_t;
/**
* @struct aci_cmd_params_setup_t
* @brief Structure for the ACI_CMD_SETUP ACI command parameters
*/
typedef struct
{
uint8_t setup_data[1];
} _aci_packed_ aci_cmd_params_setup_t;
ACI_ASSERT_SIZE(aci_cmd_params_setup_t, 1);
/**
* @struct aci_cmd_params_write_dynamic_data_t
* @brief Structure for the ACI_CMD_WRITE_DYNAMIC_DATA ACI command parameters
* @note Dynamic data chunk size in this command is defined to go up to ACI_PACKET_MAX_LEN - 3
*/
typedef struct
{
uint8_t seq_no;
uint8_t dynamic_data[1];
} _aci_packed_ aci_cmd_params_write_dynamic_data_t;
/**
* @define aci_cmd_params_set_local_data_t
* @brief Structure for the ACI_CMD_SET_LOCAL_DATA ACI command parameters
*/
typedef struct
{
aci_tx_data_t tx_data;
} _aci_packed_ aci_cmd_params_set_local_data_t;
/**
* @struct aci_cmd_params_connect_t
* @brief Structure for the ACI_CMD_CONNECT ACI command parameters
*/
typedef struct
{
uint16_t timeout; /**< 0x0000 (no timeout) to 0x3FFF */
uint16_t adv_interval; /**< 16 bits of advertising interval for general discovery */
} _aci_packed_ aci_cmd_params_connect_t;
ACI_ASSERT_SIZE(aci_cmd_params_connect_t, 4);
/**
* @define aci_cmd_params_bond_t
* @brief Structure for the ACI_CMD_BOND ACI command parameters
*/
typedef struct
{
uint16_t timeout; /**< 0x0000 (no timeout) to 0x3FFF */
uint16_t adv_interval; /**< 16 bits of advertising interval for general discovery */
} _aci_packed_ aci_cmd_params_bond_t;
ACI_ASSERT_SIZE(aci_cmd_params_bond_t, 4);
/**
* @struct aci_cmd_params_disconnect_t
* @brief Structure for the ACI_CMD_DISCONNECT ACI command parameters
*/
typedef struct
{
aci_disconnect_reason_t reason; /**< enum aci_disconnect_reason_t */
} _aci_packed_ aci_cmd_params_disconnect_t;
ACI_ASSERT_SIZE(aci_cmd_params_disconnect_t, 1);
/**
* @struct aci_cmd_params_set_tx_power_t
* @brief Structure for the ACI_CMD_SET_TX_POWER ACI command parameters
*/
typedef struct
{
aci_device_output_power_t device_power; /**< enum aci_device_output_power_t */
} _aci_packed_ aci_cmd_params_set_tx_power_t;
ACI_ASSERT_SIZE(aci_cmd_params_set_tx_power_t, 1);
/**
* @struct aci_cmd_params_change_timing_t
* @brief Structure for the ACI_CMD_CHANGE_TIMING ACI command parameters
*/
typedef struct
{
aci_ll_conn_params_t conn_params;
} _aci_packed_ aci_cmd_params_change_timing_t;
ACI_ASSERT_SIZE(aci_cmd_params_change_timing_t, 8);
/**
* @struct aci_cmd_params_open_remote_pipe_t
* @brief Structure for the ACI_CMD_OPEN_REMOTE_PIPE ACI command parameters
*/
typedef struct
{
uint8_t pipe_number;
} _aci_packed_ aci_cmd_params_open_remote_pipe_t;
/**
* @struct aci_cmd_params_send_data_t
* @brief Structure for the ACI_CMD_SEND_DATA ACI command parameters
*/
typedef struct
{
aci_tx_data_t tx_data;
} _aci_packed_ aci_cmd_params_send_data_t;
/**
* @define aci_cmd_params_send_data_ack_t
* @brief Structure for the ACI_CMD_SEND_DATA_ACK ACI command parameters
*/
typedef struct
{
uint8_t pipe_number;
} _aci_packed_ aci_cmd_params_send_data_ack_t;
/**
* @struct aci_cmd_params_send_data_t
* @brief Structure for the ACI_CMD_SEND_DATA ACI command parameters
*/
typedef struct
{
uint8_t pipe_number;
} _aci_packed_ aci_cmd_params_request_data_t;
/**
* @define aci_cmd_params_send_data_nack_t
* @brief Structure for the ACI_CMD_SEND_DATA_NACK ACI command parameters
*/
typedef struct
{
uint8_t pipe_number;
uint8_t error_code;
} _aci_packed_ aci_cmd_params_send_data_nack_t;
ACI_ASSERT_SIZE(aci_cmd_params_send_data_nack_t, 2);
/**
* @define aci_cmd_params_set_app_latency_t
* @brief Structure for the ACI_CMD_SET_APP_LATENCY ACI command parameters
*/
typedef struct
{
aci_app_latency_mode_t mode;
uint16_t latency;
} _aci_packed_ aci_cmd_params_set_app_latency_t;
ACI_ASSERT_SIZE(aci_cmd_params_set_app_latency_t, 3);
/**
* @define aci_cmd_params_set_key_t
* @brief Structure for the ACI_CMD_SET_KEY ACI command parameters
*/
typedef struct
{
aci_key_type_t key_type;
union
{
uint8_t passkey[6];
uint8_t oob_key[16];
} key;
} _aci_packed_ aci_cmd_params_set_key_t;
ACI_ASSERT_SIZE(aci_cmd_params_set_key_t, 17);
/**
* @define aci_cmd_params_open_adv_pipe_t
* @brief Structure for the ACI_CMD_OPEN_ADV_PIPE ACI command parameters
*/
typedef struct
{
uint8_t pipes[8];
} _aci_packed_ aci_cmd_params_open_adv_pipe_t;
/**
* @define aci_cmd_params_broadcast_t
* @brief Structure for the ACI_CMD_BROADCAST ACI command parameters
*/
typedef struct
{
uint16_t timeout; /**< 0x0000 (no timeout) to 0x3FFF */
uint16_t adv_interval; /**< 16 bits of advertising interval for general discovery */
} _aci_packed_ aci_cmd_params_broadcast_t;
/**
* @struct aci_cmd_params_close_remote_pipe_t
* @brief Structure for the ACI_CMD_CLOSE_REMOTE_PIPE ACI command parameters
*/
typedef struct
{
uint8_t pipe_number;
} _aci_packed_ aci_cmd_params_close_remote_pipe_t;
/**
* @struct aci_cmd_t
* @brief Encapsulates a generic ACI command
*/
typedef struct
{
uint8_t len; /**< Length of the ACI command */
aci_cmd_opcode_t cmd_opcode; /**< enum aci_cmd_opcode_t -> Opcode of the ACI command */
union
{
aci_cmd_params_test_t test;
aci_cmd_params_echo_t echo;
aci_cmd_params_dtm_cmd_t dtm_cmd;
aci_cmd_params_setup_t setup;
aci_cmd_params_write_dynamic_data_t write_dynamic_data;
aci_cmd_params_set_local_data_t set_local_data;
aci_cmd_params_connect_t connect;
aci_cmd_params_bond_t bond;
aci_cmd_params_disconnect_t disconnect;
aci_cmd_params_set_tx_power_t set_tx_power;
aci_cmd_params_change_timing_t change_timing;
aci_cmd_params_open_remote_pipe_t open_remote_pipe;
aci_cmd_params_send_data_t send_data;
aci_cmd_params_send_data_ack_t send_data_ack;
aci_cmd_params_request_data_t request_data;
aci_cmd_params_send_data_nack_t send_data_nack;
aci_cmd_params_set_app_latency_t set_app_latency;
aci_cmd_params_set_key_t set_key;
aci_cmd_params_open_adv_pipe_t open_adv_pipe;
aci_cmd_params_broadcast_t broadcast;
aci_cmd_params_close_remote_pipe_t close_remote_pipe;
} params;
} _aci_packed_ aci_cmd_t;
#endif // ACI_CMDS_H__

View File

@ -1,397 +1,397 @@
/* 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.
*/
/**
* @file
*
* @ingroup aci
*
* @brief Definitions for the ACI (Application Control Interface) events
*/
#ifndef ACI_EVTS_H__
#define ACI_EVTS_H__
#include "aci.h"
/**
* @enum aci_evt_opcode_t
* @brief ACI event opcodes
*/
typedef enum
{
/**
* Invalid event code
*/
ACI_EVT_INVALID = 0x00,
/**
* Sent every time the device starts
*/
ACI_EVT_DEVICE_STARTED = 0x81,
/**
* Mirrors the ACI_CMD_ECHO
*/
ACI_EVT_ECHO = 0x82,
/**
* Asynchronous hardware error event
*/
ACI_EVT_HW_ERROR = 0x83,
/**
* Event opcode used as a event response for all commands
*/
ACI_EVT_CMD_RSP = 0x84,
/**
* Link connected
*/
ACI_EVT_CONNECTED = 0x85,
/**
* Link disconnected
*/
ACI_EVT_DISCONNECTED = 0x86,
/**
* Bond completion result
*/
ACI_EVT_BOND_STATUS = 0x87,
/**
* Pipe bitmap for available pipes
*/
ACI_EVT_PIPE_STATUS = 0x88,
/**
* Sent to the application when the radio enters a connected state
* or when the timing of the radio connection changes
*/
ACI_EVT_TIMING = 0x89,
/**
* Notification to the application that transmit credits are
* available
*/
ACI_EVT_DATA_CREDIT = 0x8A,
/**
* Data acknowledgement event
*/
ACI_EVT_DATA_ACK = 0x8B,
/**
* Data received notification event
*/
ACI_EVT_DATA_RECEIVED = 0x8C,
/**
* Error notification event
*/
ACI_EVT_PIPE_ERROR = 0x8D,
/**
* Display Passkey Event
*/
ACI_EVT_DISPLAY_PASSKEY = 0x8E,
/**
* Security Key request
*/
ACI_EVT_KEY_REQUEST = 0x8F
} _aci_packed_ aci_evt_opcode_t;
ACI_ASSERT_SIZE(aci_evt_opcode_t, 1);
/**
* @struct aci_evt_params_device_started_t
* @brief Structure for the ACI_EVT_DEVICE_STARTED event return parameters
*/
typedef struct
{
aci_device_operation_mode_t device_mode; /**< Mode in which the device is being started */
aci_hw_error_t hw_error; /**< Hardware Error if available for the start */
uint8_t credit_available; /**< Flow control credit available for this specific FW build */
} _aci_packed_ aci_evt_params_device_started_t;
ACI_ASSERT_SIZE(aci_evt_params_device_started_t, 3);
/**
* @struct aci_evt_params_hw_error_t
* @brief Structure for the ACI_EVT_HW_ERROR event return parameters
*/
typedef struct
{
uint16_t line_num;
uint8_t file_name[20];
} _aci_packed_ aci_evt_params_hw_error_t;
ACI_ASSERT_SIZE(aci_evt_params_hw_error_t, 22);
/**
* @struct aci_evt_cmd_rsp_params_dtm_cmd_t
* @brief Structure for the ACI_EVT_CMD_RSP event with opcode=ACI_CMD_DTM_CMD event return parameters
*/
typedef struct
{
uint8_t evt_msb;
uint8_t evt_lsb;
} _aci_packed_ aci_evt_cmd_rsp_params_dtm_cmd_t;
/**
* @struct aci_evt_cmd_rsp_read_dynamic_data_t
* @brief Structure for the ACI_EVT_CMD_RSP event with opcode=ACI_CMD_READ_DYNAMIC_DATA event return parameters
* @note Dynamic data chunk size in this event is defined to go up to ACI_PACKET_MAX_LEN - 5
*/
typedef struct
{
uint8_t seq_no;
uint8_t dynamic_data[1];
} _aci_packed_ aci_evt_cmd_rsp_read_dynamic_data_t;
/**
* @struct aci_evt_cmd_rsp_params_get_device_version_t
* @brief Structure for the ACI_EVT_CMD_RSP event with opcode=ACI_CMD_GET_DEVICE_VERSION event return parameters
*/
typedef struct
{
uint16_t configuration_id;
uint8_t aci_version;
uint8_t setup_format;
uint32_t setup_id;
uint8_t setup_status;
} _aci_packed_ aci_evt_cmd_rsp_params_get_device_version_t;
ACI_ASSERT_SIZE(aci_evt_cmd_rsp_params_get_device_version_t, 9);
/**
* @struct aci_evt_cmd_rsp_params_get_device_address_t
* @brief Structure for the ACI_EVT_CMD_RSP event with opcode=ACI_CMD_GET_DEVICE_ADDRESS event return parameters
*/
typedef struct
{
uint8_t bd_addr_own[BTLE_DEVICE_ADDRESS_SIZE];
aci_bd_addr_type_t bd_addr_type;
} _aci_packed_ aci_evt_cmd_rsp_params_get_device_address_t;
ACI_ASSERT_SIZE(aci_evt_cmd_rsp_params_get_device_address_t, BTLE_DEVICE_ADDRESS_SIZE + 1);
/**
* @struct aci_evt_cmd_rsp_params_get_battery_level_t
* @brief Structure for the ACI_EVT_CMD_RSP event with opcode=ACI_CMD_GET_BATTERY_LEVEL event return parameters
*/
typedef struct
{
uint16_t battery_level;
} _aci_packed_ aci_evt_cmd_rsp_params_get_battery_level_t;
/**
* @struct aci_evt_cmd_rsp_params_get_temperature_t
* @brief Structure for the ACI_EVT_CMD_RSP event with opcode=ACI_CMD_GET_TEMPERATURE event return parameters
*/
typedef struct
{
int16_t temperature_value;
} _aci_packed_ aci_evt_cmd_rsp_params_get_temperature_t;
/**
* @struct aci_evt_params_cmd_rsp_t
* @brief Structure for the ACI_EVT_CMD_RSP event return parameters
*/
typedef struct
{
aci_cmd_opcode_t cmd_opcode; /**< Command opcode for which the event response is being sent */
aci_status_code_t cmd_status; /**< Status of the command that was sent. Used in the context of the command. */
union
{
aci_evt_cmd_rsp_params_dtm_cmd_t dtm_cmd;
aci_evt_cmd_rsp_read_dynamic_data_t read_dynamic_data;
aci_evt_cmd_rsp_params_get_device_version_t get_device_version;
aci_evt_cmd_rsp_params_get_device_address_t get_device_address;
aci_evt_cmd_rsp_params_get_battery_level_t get_battery_level;
aci_evt_cmd_rsp_params_get_temperature_t get_temperature;
uint8_t padding[29];
} params;
} _aci_packed_ aci_evt_params_cmd_rsp_t;
ACI_ASSERT_SIZE(aci_evt_params_cmd_rsp_t, 31);
/**
* @struct aci_evt_params_connected_t
* @brief Structure for the ACI_EVT_CONNECTED event return parameters
*/
typedef struct
{
aci_bd_addr_type_t dev_addr_type;
uint8_t dev_addr[BTLE_DEVICE_ADDRESS_SIZE];
uint16_t conn_rf_interval; /**< rf_interval = conn_rf_interval * 1.25 ms Range:0x0006 to 0x0C80 */
uint16_t conn_slave_rf_latency; /**< Number of RF events the slave can skip */
uint16_t conn_rf_timeout; /**< Timeout as a multiple of 10ms i.e timeout = conn_rf_timeout * 10ms Range: 0x000A to 0x0C80 */
aci_clock_accuracy_t master_clock_accuracy; /**< Clock accuracy of Bluetooth master: Enumerated list of values from 500 ppm to 20 ppm */
} _aci_packed_ aci_evt_params_connected_t;
ACI_ASSERT_SIZE(aci_evt_params_connected_t, 14);
/**
* @struct aci_evt_params_disconnected_t
* @brief Structure for the ACI_EVT_DISCONNECTED event return parameters
*/
typedef struct
{
aci_status_code_t aci_status;
uint8_t btle_status;
} _aci_packed_ aci_evt_params_disconnected_t;
ACI_ASSERT_SIZE(aci_evt_params_disconnected_t, 2);
/**
* @struct aci_evt_params_bond_status_t
* @brief Structure for the ACI_EVT_BOND_STATUS event return parameters
*/
typedef struct
{
aci_bond_status_code_t status_code;
aci_bond_status_source_t status_source;
uint8_t secmode1_bitmap;
uint8_t secmode2_bitmap;
uint8_t keys_exchanged_slave;
uint8_t keys_exchanged_master;
} _aci_packed_ aci_evt_params_bond_status_t;
ACI_ASSERT_SIZE(aci_evt_params_bond_status_t, 6);
/**
* @struct aci_evt_params_pipe_status_t
* @brief Structure for the ACI_EVT_PIPE_STATUS event return parameters
*/
typedef struct
{
uint8_t pipes_open_bitmap[8];
uint8_t pipes_closed_bitmap[8];
} _aci_packed_ aci_evt_params_pipe_status_t;
ACI_ASSERT_SIZE(aci_evt_params_pipe_status_t, 16);
/**
* @struct aci_evt_params_timing_t
* @brief Structure for the ACI_EVT_TIMING event return parameters
*/
typedef struct
{
uint16_t conn_rf_interval; /**< rf_interval = conn_rf_interval * 1.25 ms Range:0x0006 to 0x0C80 */
uint16_t conn_slave_rf_latency; /**< Number of RF events the slave can skip */
uint16_t conn_rf_timeout; /**< Timeout as a multiple of 10ms i.e timeout = conn_rf_timeout * 10ms Range: 0x000A to 0x0C80 */
} _aci_packed_ aci_evt_params_timing_t;
ACI_ASSERT_SIZE(aci_evt_params_timing_t, 6);
/**
* @struct aci_evt_params_data_credit_t
* @brief Structure for the ACI_EVT_DATA_CREDIT event return parameters
*/
typedef struct
{
uint8_t credit;
} _aci_packed_ aci_evt_params_data_credit_t;
/**
* @struct aci_evt_params_data_ack_t
* @brief Structure for the ACI_EVT_DATA_ACK event return parameters
*/
typedef struct
{
uint8_t pipe_number;
} _aci_packed_ aci_evt_params_data_ack_t;
/**
* @struct aci_evt_params_data_received_t
* @brief Structure for the ACI_EVT_DATA_RECEIVED event return parameters
*/
typedef struct
{
aci_rx_data_t rx_data;
} _aci_packed_ aci_evt_params_data_received_t;
typedef struct
{
uint8_t content[1];
} _aci_packed_ error_data_t;
/**
* @struct aci_evt_params_pipe_error_t
* @brief Structure for the ACI_EVT_PIPE_ERROR event return parameters
*/
typedef struct
{
uint8_t pipe_number;
uint8_t error_code;
union
{
error_data_t error_data;
} params;
} _aci_packed_ aci_evt_params_pipe_error_t;
/**
* @struct aci_evt_params_display_passkey_t
* @brief Structure for the ACI_EVT_DISPLAY_PASSKEY event return parameters
*/
typedef struct
{
uint8_t passkey[6];
} _aci_packed_ aci_evt_params_display_passkey_t;
/**
* @struct aci_evt_params_key_request_t
* @brief Structure for the ACI_EVT_KEY_REQUEST event return parameters
*/
typedef struct
{
aci_key_type_t key_type;
} _aci_packed_ aci_evt_params_key_request_t;
/**
* @struct aci_event_params_echo_t
* @brief Structure for the ACI_EVT_ECHO ACI event parameters
*/
typedef struct
{
uint8_t echo_data[ACI_ECHO_DATA_MAX_LEN];
} _aci_packed_ aci_evt_params_echo_t;
/**
* @struct aci_evt_t
* @brief Encapsulates a generic ACI event
*/
typedef struct
{
uint8_t len;
aci_evt_opcode_t evt_opcode;
union
{
aci_evt_params_device_started_t device_started;
aci_evt_params_echo_t echo;
aci_evt_params_hw_error_t hw_error;
aci_evt_params_cmd_rsp_t cmd_rsp;
aci_evt_params_connected_t connected;
aci_evt_params_disconnected_t disconnected;
aci_evt_params_bond_status_t bond_status;
aci_evt_params_pipe_status_t pipe_status;
aci_evt_params_timing_t timing;
aci_evt_params_data_credit_t data_credit;
aci_evt_params_data_ack_t data_ack;
aci_evt_params_data_received_t data_received;
aci_evt_params_pipe_error_t pipe_error;
aci_evt_params_display_passkey_t display_passkey;
aci_evt_params_key_request_t key_request;
} params;
} _aci_packed_ aci_evt_t;
ACI_ASSERT_SIZE(aci_evt_t, 33);
#endif // ACI_EVTS_H__
/* 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.
*/
/**
* @file
*
* @ingroup aci
*
* @brief Definitions for the ACI (Application Control Interface) events
*/
#ifndef ACI_EVTS_H__
#define ACI_EVTS_H__
#include "aci.h"
/**
* @enum aci_evt_opcode_t
* @brief ACI event opcodes
*/
typedef enum
{
/**
* Invalid event code
*/
ACI_EVT_INVALID = 0x00,
/**
* Sent every time the device starts
*/
ACI_EVT_DEVICE_STARTED = 0x81,
/**
* Mirrors the ACI_CMD_ECHO
*/
ACI_EVT_ECHO = 0x82,
/**
* Asynchronous hardware error event
*/
ACI_EVT_HW_ERROR = 0x83,
/**
* Event opcode used as a event response for all commands
*/
ACI_EVT_CMD_RSP = 0x84,
/**
* Link connected
*/
ACI_EVT_CONNECTED = 0x85,
/**
* Link disconnected
*/
ACI_EVT_DISCONNECTED = 0x86,
/**
* Bond completion result
*/
ACI_EVT_BOND_STATUS = 0x87,
/**
* Pipe bitmap for available pipes
*/
ACI_EVT_PIPE_STATUS = 0x88,
/**
* Sent to the application when the radio enters a connected state
* or when the timing of the radio connection changes
*/
ACI_EVT_TIMING = 0x89,
/**
* Notification to the application that transmit credits are
* available
*/
ACI_EVT_DATA_CREDIT = 0x8A,
/**
* Data acknowledgement event
*/
ACI_EVT_DATA_ACK = 0x8B,
/**
* Data received notification event
*/
ACI_EVT_DATA_RECEIVED = 0x8C,
/**
* Error notification event
*/
ACI_EVT_PIPE_ERROR = 0x8D,
/**
* Display Passkey Event
*/
ACI_EVT_DISPLAY_PASSKEY = 0x8E,
/**
* Security Key request
*/
ACI_EVT_KEY_REQUEST = 0x8F
} _aci_packed_ aci_evt_opcode_t;
ACI_ASSERT_SIZE(aci_evt_opcode_t, 1);
/**
* @struct aci_evt_params_device_started_t
* @brief Structure for the ACI_EVT_DEVICE_STARTED event return parameters
*/
typedef struct
{
aci_device_operation_mode_t device_mode; /**< Mode in which the device is being started */
aci_hw_error_t hw_error; /**< Hardware Error if available for the start */
uint8_t credit_available; /**< Flow control credit available for this specific FW build */
} _aci_packed_ aci_evt_params_device_started_t;
ACI_ASSERT_SIZE(aci_evt_params_device_started_t, 3);
/**
* @struct aci_evt_params_hw_error_t
* @brief Structure for the ACI_EVT_HW_ERROR event return parameters
*/
typedef struct
{
uint16_t line_num;
uint8_t file_name[20];
} _aci_packed_ aci_evt_params_hw_error_t;
ACI_ASSERT_SIZE(aci_evt_params_hw_error_t, 22);
/**
* @struct aci_evt_cmd_rsp_params_dtm_cmd_t
* @brief Structure for the ACI_EVT_CMD_RSP event with opcode=ACI_CMD_DTM_CMD event return parameters
*/
typedef struct
{
uint8_t evt_msb;
uint8_t evt_lsb;
} _aci_packed_ aci_evt_cmd_rsp_params_dtm_cmd_t;
/**
* @struct aci_evt_cmd_rsp_read_dynamic_data_t
* @brief Structure for the ACI_EVT_CMD_RSP event with opcode=ACI_CMD_READ_DYNAMIC_DATA event return parameters
* @note Dynamic data chunk size in this event is defined to go up to ACI_PACKET_MAX_LEN - 5
*/
typedef struct
{
uint8_t seq_no;
uint8_t dynamic_data[1];
} _aci_packed_ aci_evt_cmd_rsp_read_dynamic_data_t;
/**
* @struct aci_evt_cmd_rsp_params_get_device_version_t
* @brief Structure for the ACI_EVT_CMD_RSP event with opcode=ACI_CMD_GET_DEVICE_VERSION event return parameters
*/
typedef struct
{
uint16_t configuration_id;
uint8_t aci_version;
uint8_t setup_format;
uint32_t setup_id;
uint8_t setup_status;
} _aci_packed_ aci_evt_cmd_rsp_params_get_device_version_t;
ACI_ASSERT_SIZE(aci_evt_cmd_rsp_params_get_device_version_t, 9);
/**
* @struct aci_evt_cmd_rsp_params_get_device_address_t
* @brief Structure for the ACI_EVT_CMD_RSP event with opcode=ACI_CMD_GET_DEVICE_ADDRESS event return parameters
*/
typedef struct
{
uint8_t bd_addr_own[BTLE_DEVICE_ADDRESS_SIZE];
aci_bd_addr_type_t bd_addr_type;
} _aci_packed_ aci_evt_cmd_rsp_params_get_device_address_t;
ACI_ASSERT_SIZE(aci_evt_cmd_rsp_params_get_device_address_t, BTLE_DEVICE_ADDRESS_SIZE + 1);
/**
* @struct aci_evt_cmd_rsp_params_get_battery_level_t
* @brief Structure for the ACI_EVT_CMD_RSP event with opcode=ACI_CMD_GET_BATTERY_LEVEL event return parameters
*/
typedef struct
{
uint16_t battery_level;
} _aci_packed_ aci_evt_cmd_rsp_params_get_battery_level_t;
/**
* @struct aci_evt_cmd_rsp_params_get_temperature_t
* @brief Structure for the ACI_EVT_CMD_RSP event with opcode=ACI_CMD_GET_TEMPERATURE event return parameters
*/
typedef struct
{
int16_t temperature_value;
} _aci_packed_ aci_evt_cmd_rsp_params_get_temperature_t;
/**
* @struct aci_evt_params_cmd_rsp_t
* @brief Structure for the ACI_EVT_CMD_RSP event return parameters
*/
typedef struct
{
aci_cmd_opcode_t cmd_opcode; /**< Command opcode for which the event response is being sent */
aci_status_code_t cmd_status; /**< Status of the command that was sent. Used in the context of the command. */
union
{
aci_evt_cmd_rsp_params_dtm_cmd_t dtm_cmd;
aci_evt_cmd_rsp_read_dynamic_data_t read_dynamic_data;
aci_evt_cmd_rsp_params_get_device_version_t get_device_version;
aci_evt_cmd_rsp_params_get_device_address_t get_device_address;
aci_evt_cmd_rsp_params_get_battery_level_t get_battery_level;
aci_evt_cmd_rsp_params_get_temperature_t get_temperature;
uint8_t padding[29];
} params;
} _aci_packed_ aci_evt_params_cmd_rsp_t;
ACI_ASSERT_SIZE(aci_evt_params_cmd_rsp_t, 31);
/**
* @struct aci_evt_params_connected_t
* @brief Structure for the ACI_EVT_CONNECTED event return parameters
*/
typedef struct
{
aci_bd_addr_type_t dev_addr_type;
uint8_t dev_addr[BTLE_DEVICE_ADDRESS_SIZE];
uint16_t conn_rf_interval; /**< rf_interval = conn_rf_interval * 1.25 ms Range:0x0006 to 0x0C80 */
uint16_t conn_slave_rf_latency; /**< Number of RF events the slave can skip */
uint16_t conn_rf_timeout; /**< Timeout as a multiple of 10ms i.e timeout = conn_rf_timeout * 10ms Range: 0x000A to 0x0C80 */
aci_clock_accuracy_t master_clock_accuracy; /**< Clock accuracy of Bluetooth master: Enumerated list of values from 500 ppm to 20 ppm */
} _aci_packed_ aci_evt_params_connected_t;
ACI_ASSERT_SIZE(aci_evt_params_connected_t, 14);
/**
* @struct aci_evt_params_disconnected_t
* @brief Structure for the ACI_EVT_DISCONNECTED event return parameters
*/
typedef struct
{
aci_status_code_t aci_status;
uint8_t btle_status;
} _aci_packed_ aci_evt_params_disconnected_t;
ACI_ASSERT_SIZE(aci_evt_params_disconnected_t, 2);
/**
* @struct aci_evt_params_bond_status_t
* @brief Structure for the ACI_EVT_BOND_STATUS event return parameters
*/
typedef struct
{
aci_bond_status_code_t status_code;
aci_bond_status_source_t status_source;
uint8_t secmode1_bitmap;
uint8_t secmode2_bitmap;
uint8_t keys_exchanged_slave;
uint8_t keys_exchanged_master;
} _aci_packed_ aci_evt_params_bond_status_t;
ACI_ASSERT_SIZE(aci_evt_params_bond_status_t, 6);
/**
* @struct aci_evt_params_pipe_status_t
* @brief Structure for the ACI_EVT_PIPE_STATUS event return parameters
*/
typedef struct
{
uint8_t pipes_open_bitmap[8];
uint8_t pipes_closed_bitmap[8];
} _aci_packed_ aci_evt_params_pipe_status_t;
ACI_ASSERT_SIZE(aci_evt_params_pipe_status_t, 16);
/**
* @struct aci_evt_params_timing_t
* @brief Structure for the ACI_EVT_TIMING event return parameters
*/
typedef struct
{
uint16_t conn_rf_interval; /**< rf_interval = conn_rf_interval * 1.25 ms Range:0x0006 to 0x0C80 */
uint16_t conn_slave_rf_latency; /**< Number of RF events the slave can skip */
uint16_t conn_rf_timeout; /**< Timeout as a multiple of 10ms i.e timeout = conn_rf_timeout * 10ms Range: 0x000A to 0x0C80 */
} _aci_packed_ aci_evt_params_timing_t;
ACI_ASSERT_SIZE(aci_evt_params_timing_t, 6);
/**
* @struct aci_evt_params_data_credit_t
* @brief Structure for the ACI_EVT_DATA_CREDIT event return parameters
*/
typedef struct
{
uint8_t credit;
} _aci_packed_ aci_evt_params_data_credit_t;
/**
* @struct aci_evt_params_data_ack_t
* @brief Structure for the ACI_EVT_DATA_ACK event return parameters
*/
typedef struct
{
uint8_t pipe_number;
} _aci_packed_ aci_evt_params_data_ack_t;
/**
* @struct aci_evt_params_data_received_t
* @brief Structure for the ACI_EVT_DATA_RECEIVED event return parameters
*/
typedef struct
{
aci_rx_data_t rx_data;
} _aci_packed_ aci_evt_params_data_received_t;
typedef struct
{
uint8_t content[1];
} _aci_packed_ error_data_t;
/**
* @struct aci_evt_params_pipe_error_t
* @brief Structure for the ACI_EVT_PIPE_ERROR event return parameters
*/
typedef struct
{
uint8_t pipe_number;
uint8_t error_code;
union
{
error_data_t error_data;
} params;
} _aci_packed_ aci_evt_params_pipe_error_t;
/**
* @struct aci_evt_params_display_passkey_t
* @brief Structure for the ACI_EVT_DISPLAY_PASSKEY event return parameters
*/
typedef struct
{
uint8_t passkey[6];
} _aci_packed_ aci_evt_params_display_passkey_t;
/**
* @struct aci_evt_params_key_request_t
* @brief Structure for the ACI_EVT_KEY_REQUEST event return parameters
*/
typedef struct
{
aci_key_type_t key_type;
} _aci_packed_ aci_evt_params_key_request_t;
/**
* @struct aci_event_params_echo_t
* @brief Structure for the ACI_EVT_ECHO ACI event parameters
*/
typedef struct
{
uint8_t echo_data[ACI_ECHO_DATA_MAX_LEN];
} _aci_packed_ aci_evt_params_echo_t;
/**
* @struct aci_evt_t
* @brief Encapsulates a generic ACI event
*/
typedef struct
{
uint8_t len;
aci_evt_opcode_t evt_opcode;
union
{
aci_evt_params_device_started_t device_started;
aci_evt_params_echo_t echo;
aci_evt_params_hw_error_t hw_error;
aci_evt_params_cmd_rsp_t cmd_rsp;
aci_evt_params_connected_t connected;
aci_evt_params_disconnected_t disconnected;
aci_evt_params_bond_status_t bond_status;
aci_evt_params_pipe_status_t pipe_status;
aci_evt_params_timing_t timing;
aci_evt_params_data_credit_t data_credit;
aci_evt_params_data_ack_t data_ack;
aci_evt_params_data_received_t data_received;
aci_evt_params_pipe_error_t pipe_error;
aci_evt_params_display_passkey_t display_passkey;
aci_evt_params_key_request_t key_request;
} params;
} _aci_packed_ aci_evt_t;
ACI_ASSERT_SIZE(aci_evt_t, 33);
#endif // ACI_EVTS_H__

View File

@ -1,192 +1,192 @@
/* 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.
*/
/**
* @file
*
* @ingroup aci
*
* @brief This file contents defines for the position of all the fields of ACI
* command or event messages
*/
#ifndef ACI_OFFSET_H__
#define ACI_OFFSET_H__
#define OFFSET_ACI_LL_CONN_PARAMS_T_MIN_CONN_INTERVAL_LSB 0
#define OFFSET_ACI_LL_CONN_PARAMS_T_MIN_CONN_INTERVAL_MSB 1
#define OFFSET_ACI_LL_CONN_PARAMS_T_MAX_CONN_INTERVAL_LSB 2
#define OFFSET_ACI_LL_CONN_PARAMS_T_MAX_CONN_INTERVAL_MSB 3
#define OFFSET_ACI_LL_CONN_PARAMS_T_SLAVE_LATENCY_LSB 4
#define OFFSET_ACI_LL_CONN_PARAMS_T_SLAVE_LATENCY_MSB 5
#define OFFSET_ACI_LL_CONN_PARAMS_T_TIMEOUT_MULT_LSB 6
#define OFFSET_ACI_LL_CONN_PARAMS_T_TIMEOUT_MULT_MSB 7
#define OFFSET_ACI_TX_DATA_T_PIPE_NUMBER 0
#define OFFSET_ACI_TX_DATA_T_ACI_DATA 1
#define OFFSET_ACI_RX_DATA_T_PIPE_NUMBER 0
#define OFFSET_ACI_RX_DATA_T_ACI_DATA 1
#define OFFSET_ACI_CMD_PARAMS_TEST_T_TEST_MODE_CHANGE 0
#define OFFSET_ACI_CMD_PARAMS_ECHO_T_ECHO_DATA 0
#define OFFSET_ACI_CMD_PARAMS_DTM_CMD_T_CMD_MSB 0
#define OFFSET_ACI_CMD_PARAMS_DTM_CMD_T_CMD_LSB 1
#define OFFSET_ACI_CMD_PARAMS_SETUP_T_SETUP_DATA 0
#define OFFSET_ACI_CMD_PARAMS_WRITE_DYNAMIC_DATA_T_SEQ_NO 0
#define OFFSET_ACI_CMD_PARAMS_WRITE_DYNAMIC_DATA_T_DYNAMIC_DATA 1
#define OFFSET_ACI_CMD_PARAMS_SET_LOCAL_DATA_T_TX_DATA 0
#define OFFSET_ACI_CMD_PARAMS_CONNECT_T_TIMEOUT_LSB 0
#define OFFSET_ACI_CMD_PARAMS_CONNECT_T_TIMEOUT_MSB 1
#define OFFSET_ACI_CMD_PARAMS_CONNECT_T_ADV_INTERVAL_LSB 2
#define OFFSET_ACI_CMD_PARAMS_CONNECT_T_ADV_INTERVAL_MSB 3
#define OFFSET_ACI_CMD_PARAMS_BOND_T_TIMEOUT_LSB 0
#define OFFSET_ACI_CMD_PARAMS_BOND_T_TIMEOUT_MSB 1
#define OFFSET_ACI_CMD_PARAMS_BOND_T_ADV_INTERVAL_LSB 2
#define OFFSET_ACI_CMD_PARAMS_BOND_T_ADV_INTERVAL_MSB 3
#define OFFSET_ACI_CMD_PARAMS_DISCONNECT_T_REASON 0
#define OFFSET_ACI_CMD_PARAMS_SET_TX_POWER_T_DEVICE_POWER 0
#define OFFSET_ACI_CMD_PARAMS_CHANGE_TIMING_T_CONN_PARAMS 0
#define OFFSET_ACI_CMD_PARAMS_OPEN_REMOTE_PIPE_T_PIPE_NUMBER 0
#define OFFSET_ACI_CMD_PARAMS_SEND_DATA_T_TX_DATA 0
#define OFFSET_ACI_CMD_PARAMS_SEND_DATA_ACK_T_PIPE_NUMBER 0
#define OFFSET_ACI_CMD_PARAMS_REQUEST_DATA_T_PIPE_NUMBER 0
#define OFFSET_ACI_CMD_PARAMS_SEND_DATA_NACK_T_PIPE_NUMBER 0
#define OFFSET_ACI_CMD_PARAMS_SEND_DATA_NACK_T_ERROR_CODE 1
#define OFFSET_ACI_CMD_PARAMS_SET_APP_LATENCY_T_MODE 0
#define OFFSET_ACI_CMD_PARAMS_SET_APP_LATENCY_T_LATENCY_LSB 1
#define OFFSET_ACI_CMD_PARAMS_SET_APP_LATENCY_T_LATENCY_MSB 2
#define OFFSET_ACI_CMD_PARAMS_SET_KEY_T_KEY_TYPE 0
#define OFFSET_ACI_CMD_PARAMS_SET_KEY_T_PASSKEY 1
#define OFFSET_ACI_CMD_PARAMS_SET_KEY_T_OOB_KEY 1
#define OFFSET_ACI_CMD_PARAMS_OPEN_ADV_PIPE_T_PIPES 0
#define OFFSET_ACI_CMD_PARAMS_BROADCAST_T_TIMEOUT_LSB 0
#define OFFSET_ACI_CMD_PARAMS_BROADCAST_T_TIMEOUT_MSB 1
#define OFFSET_ACI_CMD_PARAMS_BROADCAST_T_ADV_INTERVAL_LSB 2
#define OFFSET_ACI_CMD_PARAMS_BROADCAST_T_ADV_INTERVAL_MSB 3
#define OFFSET_ACI_CMD_PARAMS_CLOSE_REMOTE_PIPE_T_PIPE_NUMBER 0
#define OFFSET_ACI_CMD_T_LEN 0
#define OFFSET_ACI_CMD_T_CMD_OPCODE 1
#define OFFSET_ACI_CMD_T_TEST 2
#define OFFSET_ACI_CMD_T_ECHO 2
#define OFFSET_ACI_CMD_T_DTM_CMD 2
#define OFFSET_ACI_CMD_T_SETUP 2
#define OFFSET_ACI_CMD_T_WRITE_DYNAMIC_DATA 2
#define OFFSET_ACI_CMD_T_SET_LOCAL_DATA 2
#define OFFSET_ACI_CMD_T_CONNECT 2
#define OFFSET_ACI_CMD_T_BOND 2
#define OFFSET_ACI_CMD_T_DISCONNECT 2
#define OFFSET_ACI_CMD_T_SET_TX_POWER 2
#define OFFSET_ACI_CMD_T_CHANGE_TIMING 2
#define OFFSET_ACI_CMD_T_OPEN_REMOTE_PIPE 2
#define OFFSET_ACI_CMD_T_SEND_DATA 2
#define OFFSET_ACI_CMD_T_SEND_DATA_ACK 2
#define OFFSET_ACI_CMD_T_REQUEST_DATA 2
#define OFFSET_ACI_CMD_T_SEND_DATA_NACK 2
#define OFFSET_ACI_CMD_T_SET_APP_LATENCY 2
#define OFFSET_ACI_CMD_T_SET_KEY 2
#define OFFSET_ACI_CMD_T_OPEN_ADV_PIPE 2
#define OFFSET_ACI_CMD_T_BROADCAST 2
#define OFFSET_ACI_CMD_T_CLOSE_REMOTE_PIPE 2
#define OFFSET_ACI_EVT_PARAMS_DEVICE_STARTED_T_DEVICE_MODE 0
#define OFFSET_ACI_EVT_PARAMS_DEVICE_STARTED_T_HW_ERROR 1
#define OFFSET_ACI_EVT_PARAMS_DEVICE_STARTED_T_CREDIT_AVAILABLE 2
#define OFFSET_ACI_EVT_PARAMS_HW_ERROR_T_LINE_NUM_LSB 0
#define OFFSET_ACI_EVT_PARAMS_HW_ERROR_T_LINE_NUM_MSB 1
#define OFFSET_ACI_EVT_PARAMS_HW_ERROR_T_FILE_NAME 2
#define OFFSET_ACI_EVT_CMD_RSP_PARAMS_DTM_CMD_T_EVT_MSB 0
#define OFFSET_ACI_EVT_CMD_RSP_PARAMS_DTM_CMD_T_EVT_LSB 1
#define OFFSET_ACI_EVT_CMD_RSP_READ_DYNAMIC_DATA_T_SEQ_NO 0
#define OFFSET_ACI_EVT_CMD_RSP_READ_DYNAMIC_DATA_T_DYNAMIC_DATA 1
#define OFFSET_ACI_EVT_CMD_RSP_PARAMS_GET_DEVICE_VERSION_T_CONFIGURATION_ID_LSB 0
#define OFFSET_ACI_EVT_CMD_RSP_PARAMS_GET_DEVICE_VERSION_T_CONFIGURATION_ID_MSB 1
#define OFFSET_ACI_EVT_CMD_RSP_PARAMS_GET_DEVICE_VERSION_T_ACI_VERSION 2
#define OFFSET_ACI_EVT_CMD_RSP_PARAMS_GET_DEVICE_VERSION_T_SETUP_FORMAT 3
#define OFFSET_ACI_EVT_CMD_RSP_PARAMS_GET_DEVICE_VERSION_T_SETUP_ID_LSB0 4
#define OFFSET_ACI_EVT_CMD_RSP_PARAMS_GET_DEVICE_VERSION_T_SETUP_ID_LSB1 5
#define OFFSET_ACI_EVT_CMD_RSP_PARAMS_GET_DEVICE_VERSION_T_SETUP_ID_MSB0 6
#define OFFSET_ACI_EVT_CMD_RSP_PARAMS_GET_DEVICE_VERSION_T_SETUP_ID_MSB1 7
#define OFFSET_ACI_EVT_CMD_RSP_PARAMS_GET_DEVICE_VERSION_T_SETUP_STATUS 8
#define OFFSET_ACI_EVT_CMD_RSP_PARAMS_GET_DEVICE_ADDRESS_T_BD_ADDR_OWN 0
#define OFFSET_ACI_EVT_CMD_RSP_PARAMS_GET_DEVICE_ADDRESS_T_BD_ADDR_TYPE 6
#define OFFSET_ACI_EVT_CMD_RSP_PARAMS_GET_BATTERY_LEVEL_T_BATTERY_LEVEL_LSB 0
#define OFFSET_ACI_EVT_CMD_RSP_PARAMS_GET_BATTERY_LEVEL_T_BATTERY_LEVEL_MSB 1
#define OFFSET_ACI_EVT_CMD_RSP_PARAMS_GET_TEMPERATURE_T_TEMPERATURE_VALUE_LSB 0
#define OFFSET_ACI_EVT_CMD_RSP_PARAMS_GET_TEMPERATURE_T_TEMPERATURE_VALUE_MSB 1
#define OFFSET_ACI_EVT_PARAMS_CMD_RSP_T_CMD_OPCODE 0
#define OFFSET_ACI_EVT_PARAMS_CMD_RSP_T_CMD_STATUS 1
#define OFFSET_ACI_EVT_PARAMS_CMD_RSP_T_DTM_CMD 2
#define OFFSET_ACI_EVT_PARAMS_CMD_RSP_T_READ_DYNAMIC_DATA 2
#define OFFSET_ACI_EVT_PARAMS_CMD_RSP_T_GET_DEVICE_VERSION 2
#define OFFSET_ACI_EVT_PARAMS_CMD_RSP_T_GET_DEVICE_ADDRESS 2
#define OFFSET_ACI_EVT_PARAMS_CMD_RSP_T_GET_BATTERY_LEVEL 2
#define OFFSET_ACI_EVT_PARAMS_CMD_RSP_T_GET_TEMPERATURE 2
#define OFFSET_ACI_EVT_PARAMS_CONNECTED_T_DEV_ADDR_TYPE 0
#define OFFSET_ACI_EVT_PARAMS_CONNECTED_T_DEV_ADDR 1
#define OFFSET_ACI_EVT_PARAMS_CONNECTED_T_CONN_RF_INTERVAL_LSB 7
#define OFFSET_ACI_EVT_PARAMS_CONNECTED_T_CONN_RF_INTERVAL_MSB 8
#define OFFSET_ACI_EVT_PARAMS_CONNECTED_T_CONN_SLAVE_RF_LATENCY_LSB 9
#define OFFSET_ACI_EVT_PARAMS_CONNECTED_T_CONN_SLAVE_RF_LATENCY_MSB 10
#define OFFSET_ACI_EVT_PARAMS_CONNECTED_T_CONN_RF_TIMEOUT_LSB 11
#define OFFSET_ACI_EVT_PARAMS_CONNECTED_T_CONN_RF_TIMEOUT_MSB 12
#define OFFSET_ACI_EVT_PARAMS_CONNECTED_T_MASTER_CLOCK_ACCURACY 13
#define OFFSET_ACI_EVT_PARAMS_DISCONNECTED_T_ACI_STATUS 0
#define OFFSET_ACI_EVT_PARAMS_DISCONNECTED_T_BTLE_STATUS 1
#define OFFSET_ACI_EVT_PARAMS_BOND_STATUS_T_STATUS_CODE 0
#define OFFSET_ACI_EVT_PARAMS_BOND_STATUS_T_STATUS_SOURCE 1
#define OFFSET_ACI_EVT_PARAMS_BOND_STATUS_T_SECMODE1_BITMAP 2
#define OFFSET_ACI_EVT_PARAMS_BOND_STATUS_T_SECMODE2_BITMAP 3
#define OFFSET_ACI_EVT_PARAMS_BOND_STATUS_T_KEYS_EXCHANGED_SLAVE 4
#define OFFSET_ACI_EVT_PARAMS_BOND_STATUS_T_KEYS_EXCHANGED_MASTER 5
#define OFFSET_ACI_EVT_PARAMS_PIPE_STATUS_T_PIPES_OPEN_BITMAP 0
#define OFFSET_ACI_EVT_PARAMS_PIPE_STATUS_T_PIPES_CLOSED_BITMAP 8
#define OFFSET_ACI_EVT_PARAMS_TIMING_T_CONN_RF_INTERVAL_LSB 0
#define OFFSET_ACI_EVT_PARAMS_TIMING_T_CONN_RF_INTERVAL_MSB 1
#define OFFSET_ACI_EVT_PARAMS_TIMING_T_CONN_SLAVE_RF_LATENCY_LSB 2
#define OFFSET_ACI_EVT_PARAMS_TIMING_T_CONN_SLAVE_RF_LATENCY_MSB 3
#define OFFSET_ACI_EVT_PARAMS_TIMING_T_CONN_RF_TIMEOUT_LSB 4
#define OFFSET_ACI_EVT_PARAMS_TIMING_T_CONN_RF_TIMEOUT_MSB 5
#define OFFSET_ACI_EVT_PARAMS_DATA_CREDIT_T_CREDIT 0
#define OFFSET_ACI_EVT_PARAMS_DATA_ACK_T_PIPE_NUMBER 0
#define OFFSET_ACI_EVT_PARAMS_DATA_RECEIVED_T_RX_DATA 0
#define OFFSET_ERROR_DATA_T_CONTENT 0
#define OFFSET_ACI_EVT_PARAMS_PIPE_ERROR_T_PIPE_NUMBER 0
#define OFFSET_ACI_EVT_PARAMS_PIPE_ERROR_T_ERROR_CODE 1
#define OFFSET_ACI_EVT_PARAMS_PIPE_ERROR_T_ERROR_DATA 2
#define OFFSET_ACI_EVT_PARAMS_DISPLAY_PASSKEY_T_PASSKEY 0
#define OFFSET_ACI_EVT_PARAMS_KEY_REQUEST_T_KEY_TYPE 0
#define OFFSET_ACI_EVT_T_LEN 0
#define OFFSET_ACI_EVT_T_EVT_OPCODE 1
#define OFFSET_ACI_EVT_T_DEVICE_STARTED 2
#define OFFSET_ACI_EVT_T_HW_ERROR 2
#define OFFSET_ACI_EVT_T_CMD_RSP 2
#define OFFSET_ACI_EVT_T_CONNECTED 2
#define OFFSET_ACI_EVT_T_DISCONNECTED 2
#define OFFSET_ACI_EVT_T_BOND_STATUS 2
#define OFFSET_ACI_EVT_T_PIPE_STATUS 2
#define OFFSET_ACI_EVT_T_TIMING 2
#define OFFSET_ACI_EVT_T_DATA_CREDIT 2
#define OFFSET_ACI_EVT_T_DATA_ACK 2
#define OFFSET_ACI_EVT_T_DATA_RECEIVED 2
#define OFFSET_ACI_EVT_T_PIPE_ERROR 2
#define OFFSET_ACI_EVT_T_DISPLAY_PASSKEY 2
#define OFFSET_ACI_EVT_T_KEY_REQUEST 2
#endif //ACI_OFFSET_H__
/* 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.
*/
/**
* @file
*
* @ingroup aci
*
* @brief This file contents defines for the position of all the fields of ACI
* command or event messages
*/
#ifndef ACI_OFFSET_H__
#define ACI_OFFSET_H__
#define OFFSET_ACI_LL_CONN_PARAMS_T_MIN_CONN_INTERVAL_LSB 0
#define OFFSET_ACI_LL_CONN_PARAMS_T_MIN_CONN_INTERVAL_MSB 1
#define OFFSET_ACI_LL_CONN_PARAMS_T_MAX_CONN_INTERVAL_LSB 2
#define OFFSET_ACI_LL_CONN_PARAMS_T_MAX_CONN_INTERVAL_MSB 3
#define OFFSET_ACI_LL_CONN_PARAMS_T_SLAVE_LATENCY_LSB 4
#define OFFSET_ACI_LL_CONN_PARAMS_T_SLAVE_LATENCY_MSB 5
#define OFFSET_ACI_LL_CONN_PARAMS_T_TIMEOUT_MULT_LSB 6
#define OFFSET_ACI_LL_CONN_PARAMS_T_TIMEOUT_MULT_MSB 7
#define OFFSET_ACI_TX_DATA_T_PIPE_NUMBER 0
#define OFFSET_ACI_TX_DATA_T_ACI_DATA 1
#define OFFSET_ACI_RX_DATA_T_PIPE_NUMBER 0
#define OFFSET_ACI_RX_DATA_T_ACI_DATA 1
#define OFFSET_ACI_CMD_PARAMS_TEST_T_TEST_MODE_CHANGE 0
#define OFFSET_ACI_CMD_PARAMS_ECHO_T_ECHO_DATA 0
#define OFFSET_ACI_CMD_PARAMS_DTM_CMD_T_CMD_MSB 0
#define OFFSET_ACI_CMD_PARAMS_DTM_CMD_T_CMD_LSB 1
#define OFFSET_ACI_CMD_PARAMS_SETUP_T_SETUP_DATA 0
#define OFFSET_ACI_CMD_PARAMS_WRITE_DYNAMIC_DATA_T_SEQ_NO 0
#define OFFSET_ACI_CMD_PARAMS_WRITE_DYNAMIC_DATA_T_DYNAMIC_DATA 1
#define OFFSET_ACI_CMD_PARAMS_SET_LOCAL_DATA_T_TX_DATA 0
#define OFFSET_ACI_CMD_PARAMS_CONNECT_T_TIMEOUT_LSB 0
#define OFFSET_ACI_CMD_PARAMS_CONNECT_T_TIMEOUT_MSB 1
#define OFFSET_ACI_CMD_PARAMS_CONNECT_T_ADV_INTERVAL_LSB 2
#define OFFSET_ACI_CMD_PARAMS_CONNECT_T_ADV_INTERVAL_MSB 3
#define OFFSET_ACI_CMD_PARAMS_BOND_T_TIMEOUT_LSB 0
#define OFFSET_ACI_CMD_PARAMS_BOND_T_TIMEOUT_MSB 1
#define OFFSET_ACI_CMD_PARAMS_BOND_T_ADV_INTERVAL_LSB 2
#define OFFSET_ACI_CMD_PARAMS_BOND_T_ADV_INTERVAL_MSB 3
#define OFFSET_ACI_CMD_PARAMS_DISCONNECT_T_REASON 0
#define OFFSET_ACI_CMD_PARAMS_SET_TX_POWER_T_DEVICE_POWER 0
#define OFFSET_ACI_CMD_PARAMS_CHANGE_TIMING_T_CONN_PARAMS 0
#define OFFSET_ACI_CMD_PARAMS_OPEN_REMOTE_PIPE_T_PIPE_NUMBER 0
#define OFFSET_ACI_CMD_PARAMS_SEND_DATA_T_TX_DATA 0
#define OFFSET_ACI_CMD_PARAMS_SEND_DATA_ACK_T_PIPE_NUMBER 0
#define OFFSET_ACI_CMD_PARAMS_REQUEST_DATA_T_PIPE_NUMBER 0
#define OFFSET_ACI_CMD_PARAMS_SEND_DATA_NACK_T_PIPE_NUMBER 0
#define OFFSET_ACI_CMD_PARAMS_SEND_DATA_NACK_T_ERROR_CODE 1
#define OFFSET_ACI_CMD_PARAMS_SET_APP_LATENCY_T_MODE 0
#define OFFSET_ACI_CMD_PARAMS_SET_APP_LATENCY_T_LATENCY_LSB 1
#define OFFSET_ACI_CMD_PARAMS_SET_APP_LATENCY_T_LATENCY_MSB 2
#define OFFSET_ACI_CMD_PARAMS_SET_KEY_T_KEY_TYPE 0
#define OFFSET_ACI_CMD_PARAMS_SET_KEY_T_PASSKEY 1
#define OFFSET_ACI_CMD_PARAMS_SET_KEY_T_OOB_KEY 1
#define OFFSET_ACI_CMD_PARAMS_OPEN_ADV_PIPE_T_PIPES 0
#define OFFSET_ACI_CMD_PARAMS_BROADCAST_T_TIMEOUT_LSB 0
#define OFFSET_ACI_CMD_PARAMS_BROADCAST_T_TIMEOUT_MSB 1
#define OFFSET_ACI_CMD_PARAMS_BROADCAST_T_ADV_INTERVAL_LSB 2
#define OFFSET_ACI_CMD_PARAMS_BROADCAST_T_ADV_INTERVAL_MSB 3
#define OFFSET_ACI_CMD_PARAMS_CLOSE_REMOTE_PIPE_T_PIPE_NUMBER 0
#define OFFSET_ACI_CMD_T_LEN 0
#define OFFSET_ACI_CMD_T_CMD_OPCODE 1
#define OFFSET_ACI_CMD_T_TEST 2
#define OFFSET_ACI_CMD_T_ECHO 2
#define OFFSET_ACI_CMD_T_DTM_CMD 2
#define OFFSET_ACI_CMD_T_SETUP 2
#define OFFSET_ACI_CMD_T_WRITE_DYNAMIC_DATA 2
#define OFFSET_ACI_CMD_T_SET_LOCAL_DATA 2
#define OFFSET_ACI_CMD_T_CONNECT 2
#define OFFSET_ACI_CMD_T_BOND 2
#define OFFSET_ACI_CMD_T_DISCONNECT 2
#define OFFSET_ACI_CMD_T_SET_TX_POWER 2
#define OFFSET_ACI_CMD_T_CHANGE_TIMING 2
#define OFFSET_ACI_CMD_T_OPEN_REMOTE_PIPE 2
#define OFFSET_ACI_CMD_T_SEND_DATA 2
#define OFFSET_ACI_CMD_T_SEND_DATA_ACK 2
#define OFFSET_ACI_CMD_T_REQUEST_DATA 2
#define OFFSET_ACI_CMD_T_SEND_DATA_NACK 2
#define OFFSET_ACI_CMD_T_SET_APP_LATENCY 2
#define OFFSET_ACI_CMD_T_SET_KEY 2
#define OFFSET_ACI_CMD_T_OPEN_ADV_PIPE 2
#define OFFSET_ACI_CMD_T_BROADCAST 2
#define OFFSET_ACI_CMD_T_CLOSE_REMOTE_PIPE 2
#define OFFSET_ACI_EVT_PARAMS_DEVICE_STARTED_T_DEVICE_MODE 0
#define OFFSET_ACI_EVT_PARAMS_DEVICE_STARTED_T_HW_ERROR 1
#define OFFSET_ACI_EVT_PARAMS_DEVICE_STARTED_T_CREDIT_AVAILABLE 2
#define OFFSET_ACI_EVT_PARAMS_HW_ERROR_T_LINE_NUM_LSB 0
#define OFFSET_ACI_EVT_PARAMS_HW_ERROR_T_LINE_NUM_MSB 1
#define OFFSET_ACI_EVT_PARAMS_HW_ERROR_T_FILE_NAME 2
#define OFFSET_ACI_EVT_CMD_RSP_PARAMS_DTM_CMD_T_EVT_MSB 0
#define OFFSET_ACI_EVT_CMD_RSP_PARAMS_DTM_CMD_T_EVT_LSB 1
#define OFFSET_ACI_EVT_CMD_RSP_READ_DYNAMIC_DATA_T_SEQ_NO 0
#define OFFSET_ACI_EVT_CMD_RSP_READ_DYNAMIC_DATA_T_DYNAMIC_DATA 1
#define OFFSET_ACI_EVT_CMD_RSP_PARAMS_GET_DEVICE_VERSION_T_CONFIGURATION_ID_LSB 0
#define OFFSET_ACI_EVT_CMD_RSP_PARAMS_GET_DEVICE_VERSION_T_CONFIGURATION_ID_MSB 1
#define OFFSET_ACI_EVT_CMD_RSP_PARAMS_GET_DEVICE_VERSION_T_ACI_VERSION 2
#define OFFSET_ACI_EVT_CMD_RSP_PARAMS_GET_DEVICE_VERSION_T_SETUP_FORMAT 3
#define OFFSET_ACI_EVT_CMD_RSP_PARAMS_GET_DEVICE_VERSION_T_SETUP_ID_LSB0 4
#define OFFSET_ACI_EVT_CMD_RSP_PARAMS_GET_DEVICE_VERSION_T_SETUP_ID_LSB1 5
#define OFFSET_ACI_EVT_CMD_RSP_PARAMS_GET_DEVICE_VERSION_T_SETUP_ID_MSB0 6
#define OFFSET_ACI_EVT_CMD_RSP_PARAMS_GET_DEVICE_VERSION_T_SETUP_ID_MSB1 7
#define OFFSET_ACI_EVT_CMD_RSP_PARAMS_GET_DEVICE_VERSION_T_SETUP_STATUS 8
#define OFFSET_ACI_EVT_CMD_RSP_PARAMS_GET_DEVICE_ADDRESS_T_BD_ADDR_OWN 0
#define OFFSET_ACI_EVT_CMD_RSP_PARAMS_GET_DEVICE_ADDRESS_T_BD_ADDR_TYPE 6
#define OFFSET_ACI_EVT_CMD_RSP_PARAMS_GET_BATTERY_LEVEL_T_BATTERY_LEVEL_LSB 0
#define OFFSET_ACI_EVT_CMD_RSP_PARAMS_GET_BATTERY_LEVEL_T_BATTERY_LEVEL_MSB 1
#define OFFSET_ACI_EVT_CMD_RSP_PARAMS_GET_TEMPERATURE_T_TEMPERATURE_VALUE_LSB 0
#define OFFSET_ACI_EVT_CMD_RSP_PARAMS_GET_TEMPERATURE_T_TEMPERATURE_VALUE_MSB 1
#define OFFSET_ACI_EVT_PARAMS_CMD_RSP_T_CMD_OPCODE 0
#define OFFSET_ACI_EVT_PARAMS_CMD_RSP_T_CMD_STATUS 1
#define OFFSET_ACI_EVT_PARAMS_CMD_RSP_T_DTM_CMD 2
#define OFFSET_ACI_EVT_PARAMS_CMD_RSP_T_READ_DYNAMIC_DATA 2
#define OFFSET_ACI_EVT_PARAMS_CMD_RSP_T_GET_DEVICE_VERSION 2
#define OFFSET_ACI_EVT_PARAMS_CMD_RSP_T_GET_DEVICE_ADDRESS 2
#define OFFSET_ACI_EVT_PARAMS_CMD_RSP_T_GET_BATTERY_LEVEL 2
#define OFFSET_ACI_EVT_PARAMS_CMD_RSP_T_GET_TEMPERATURE 2
#define OFFSET_ACI_EVT_PARAMS_CONNECTED_T_DEV_ADDR_TYPE 0
#define OFFSET_ACI_EVT_PARAMS_CONNECTED_T_DEV_ADDR 1
#define OFFSET_ACI_EVT_PARAMS_CONNECTED_T_CONN_RF_INTERVAL_LSB 7
#define OFFSET_ACI_EVT_PARAMS_CONNECTED_T_CONN_RF_INTERVAL_MSB 8
#define OFFSET_ACI_EVT_PARAMS_CONNECTED_T_CONN_SLAVE_RF_LATENCY_LSB 9
#define OFFSET_ACI_EVT_PARAMS_CONNECTED_T_CONN_SLAVE_RF_LATENCY_MSB 10
#define OFFSET_ACI_EVT_PARAMS_CONNECTED_T_CONN_RF_TIMEOUT_LSB 11
#define OFFSET_ACI_EVT_PARAMS_CONNECTED_T_CONN_RF_TIMEOUT_MSB 12
#define OFFSET_ACI_EVT_PARAMS_CONNECTED_T_MASTER_CLOCK_ACCURACY 13
#define OFFSET_ACI_EVT_PARAMS_DISCONNECTED_T_ACI_STATUS 0
#define OFFSET_ACI_EVT_PARAMS_DISCONNECTED_T_BTLE_STATUS 1
#define OFFSET_ACI_EVT_PARAMS_BOND_STATUS_T_STATUS_CODE 0
#define OFFSET_ACI_EVT_PARAMS_BOND_STATUS_T_STATUS_SOURCE 1
#define OFFSET_ACI_EVT_PARAMS_BOND_STATUS_T_SECMODE1_BITMAP 2
#define OFFSET_ACI_EVT_PARAMS_BOND_STATUS_T_SECMODE2_BITMAP 3
#define OFFSET_ACI_EVT_PARAMS_BOND_STATUS_T_KEYS_EXCHANGED_SLAVE 4
#define OFFSET_ACI_EVT_PARAMS_BOND_STATUS_T_KEYS_EXCHANGED_MASTER 5
#define OFFSET_ACI_EVT_PARAMS_PIPE_STATUS_T_PIPES_OPEN_BITMAP 0
#define OFFSET_ACI_EVT_PARAMS_PIPE_STATUS_T_PIPES_CLOSED_BITMAP 8
#define OFFSET_ACI_EVT_PARAMS_TIMING_T_CONN_RF_INTERVAL_LSB 0
#define OFFSET_ACI_EVT_PARAMS_TIMING_T_CONN_RF_INTERVAL_MSB 1
#define OFFSET_ACI_EVT_PARAMS_TIMING_T_CONN_SLAVE_RF_LATENCY_LSB 2
#define OFFSET_ACI_EVT_PARAMS_TIMING_T_CONN_SLAVE_RF_LATENCY_MSB 3
#define OFFSET_ACI_EVT_PARAMS_TIMING_T_CONN_RF_TIMEOUT_LSB 4
#define OFFSET_ACI_EVT_PARAMS_TIMING_T_CONN_RF_TIMEOUT_MSB 5
#define OFFSET_ACI_EVT_PARAMS_DATA_CREDIT_T_CREDIT 0
#define OFFSET_ACI_EVT_PARAMS_DATA_ACK_T_PIPE_NUMBER 0
#define OFFSET_ACI_EVT_PARAMS_DATA_RECEIVED_T_RX_DATA 0
#define OFFSET_ERROR_DATA_T_CONTENT 0
#define OFFSET_ACI_EVT_PARAMS_PIPE_ERROR_T_PIPE_NUMBER 0
#define OFFSET_ACI_EVT_PARAMS_PIPE_ERROR_T_ERROR_CODE 1
#define OFFSET_ACI_EVT_PARAMS_PIPE_ERROR_T_ERROR_DATA 2
#define OFFSET_ACI_EVT_PARAMS_DISPLAY_PASSKEY_T_PASSKEY 0
#define OFFSET_ACI_EVT_PARAMS_KEY_REQUEST_T_KEY_TYPE 0
#define OFFSET_ACI_EVT_T_LEN 0
#define OFFSET_ACI_EVT_T_EVT_OPCODE 1
#define OFFSET_ACI_EVT_T_DEVICE_STARTED 2
#define OFFSET_ACI_EVT_T_HW_ERROR 2
#define OFFSET_ACI_EVT_T_CMD_RSP 2
#define OFFSET_ACI_EVT_T_CONNECTED 2
#define OFFSET_ACI_EVT_T_DISCONNECTED 2
#define OFFSET_ACI_EVT_T_BOND_STATUS 2
#define OFFSET_ACI_EVT_T_PIPE_STATUS 2
#define OFFSET_ACI_EVT_T_TIMING 2
#define OFFSET_ACI_EVT_T_DATA_CREDIT 2
#define OFFSET_ACI_EVT_T_DATA_ACK 2
#define OFFSET_ACI_EVT_T_DATA_RECEIVED 2
#define OFFSET_ACI_EVT_T_PIPE_ERROR 2
#define OFFSET_ACI_EVT_T_DISPLAY_PASSKEY 2
#define OFFSET_ACI_EVT_T_KEY_REQUEST 2
#endif //ACI_OFFSET_H__

View File

@ -1,201 +1,201 @@
/* 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.
*/
/** @file
@brief Implementation of a circular queue for ACI data
*/
#include "hal_aci_tl.h"
#include "aci_queue.h"
void aci_queue_init(aci_queue_t *aci_q)
{
uint8_t loop;
// ble_assert(NULL != aci_q);
aci_q->head = 0;
aci_q->tail = 0;
for(loop=0; loop<ACI_QUEUE_SIZE; loop++)
{
aci_q->aci_data[loop].buffer[0] = 0x00;
aci_q->aci_data[loop].buffer[1] = 0x00;
}
}
bool aci_queue_dequeue(aci_queue_t *aci_q, hal_aci_data_t *p_data)
{
// ble_assert(NULL != aci_q);
// ble_assert(NULL != p_data);
if (aci_queue_is_empty(aci_q))
{
return false;
}
memcpy((uint8_t *)p_data, (uint8_t *)&(aci_q->aci_data[aci_q->head]), sizeof(hal_aci_data_t));
aci_q->head = (aci_q->head + 1) % ACI_QUEUE_SIZE;
return true;
}
bool aci_queue_dequeue_from_isr(aci_queue_t *aci_q, hal_aci_data_t *p_data)
{
// ble_assert(NULL != aci_q);
// ble_assert(NULL != p_data);
if (aci_queue_is_empty_from_isr(aci_q))
{
return false;
}
memcpy((uint8_t *)p_data, (uint8_t *)&(aci_q->aci_data[aci_q->head]), sizeof(hal_aci_data_t));
aci_q->head = (aci_q->head + 1) % ACI_QUEUE_SIZE;
return true;
}
bool aci_queue_enqueue(aci_queue_t *aci_q, hal_aci_data_t *p_data)
{
const uint8_t length = p_data->buffer[0];
// ble_assert(NULL != aci_q);
// ble_assert(NULL != p_data);
if (aci_queue_is_full(aci_q))
{
return false;
}
aci_q->aci_data[aci_q->tail].status_byte = 0;
memcpy((uint8_t *)&(aci_q->aci_data[aci_q->tail].buffer[0]), (uint8_t *)&p_data->buffer[0], length + 1);
aci_q->tail = (aci_q->tail + 1) % ACI_QUEUE_SIZE;
return true;
}
bool aci_queue_enqueue_from_isr(aci_queue_t *aci_q, hal_aci_data_t *p_data)
{
const uint8_t length = p_data->buffer[0];
// ble_assert(NULL != aci_q);
// ble_assert(NULL != p_data);
if (aci_queue_is_full_from_isr(aci_q))
{
return false;
}
aci_q->aci_data[aci_q->tail].status_byte = 0;
memcpy((uint8_t *)&(aci_q->aci_data[aci_q->tail].buffer[0]), (uint8_t *)&p_data->buffer[0], length + 1);
aci_q->tail = (aci_q->tail + 1) % ACI_QUEUE_SIZE;
return true;
}
bool aci_queue_is_empty(aci_queue_t *aci_q)
{
bool state = false;
// ble_assert(NULL != aci_q);
//Critical section
// noInterrupts();
if (aci_q->head == aci_q->tail)
{
state = true;
}
// interrupts();
return state;
}
bool aci_queue_is_empty_from_isr(aci_queue_t *aci_q)
{
// ble_assert(NULL != aci_q);
return aci_q->head == aci_q->tail;
}
bool aci_queue_is_full(aci_queue_t *aci_q)
{
uint8_t next;
bool state;
// ble_assert(NULL != aci_q);
//This should be done in a critical section
// noInterrupts();
next = (aci_q->tail + 1) % ACI_QUEUE_SIZE;
if (next == aci_q->head)
{
state = true;
}
else
{
state = false;
}
// interrupts();
//end
return state;
}
bool aci_queue_is_full_from_isr(aci_queue_t *aci_q)
{
const uint8_t next = (aci_q->tail + 1) % ACI_QUEUE_SIZE;
// ble_assert(NULL != aci_q);
return next == aci_q->head;
}
bool aci_queue_peek(aci_queue_t *aci_q, hal_aci_data_t *p_data)
{
// ble_assert(NULL != aci_q);
// ble_assert(NULL != p_data);
if (aci_queue_is_empty(aci_q))
{
return false;
}
memcpy((uint8_t *)p_data, (uint8_t *)&(aci_q->aci_data[aci_q->head]), sizeof(hal_aci_data_t));
return true;
}
bool aci_queue_peek_from_isr(aci_queue_t *aci_q, hal_aci_data_t *p_data)
{
// ble_assert(NULL != aci_q);
// ble_assert(NULL != p_data);
if (aci_queue_is_empty_from_isr(aci_q))
{
return false;
}
memcpy((uint8_t *)p_data, (uint8_t *)&(aci_q->aci_data[aci_q->head]), sizeof(hal_aci_data_t));
return true;
}
/* 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.
*/
/** @file
@brief Implementation of a circular queue for ACI data
*/
#include "hal_aci_tl.h"
#include "aci_queue.h"
void aci_queue_init(aci_queue_t *aci_q)
{
uint8_t loop;
// ble_assert(NULL != aci_q);
aci_q->head = 0;
aci_q->tail = 0;
for(loop=0; loop<ACI_QUEUE_SIZE; loop++)
{
aci_q->aci_data[loop].buffer[0] = 0x00;
aci_q->aci_data[loop].buffer[1] = 0x00;
}
}
bool aci_queue_dequeue(aci_queue_t *aci_q, hal_aci_data_t *p_data)
{
// ble_assert(NULL != aci_q);
// ble_assert(NULL != p_data);
if (aci_queue_is_empty(aci_q))
{
return false;
}
memcpy((uint8_t *)p_data, (uint8_t *)&(aci_q->aci_data[aci_q->head]), sizeof(hal_aci_data_t));
aci_q->head = (aci_q->head + 1) % ACI_QUEUE_SIZE;
return true;
}
bool aci_queue_dequeue_from_isr(aci_queue_t *aci_q, hal_aci_data_t *p_data)
{
// ble_assert(NULL != aci_q);
// ble_assert(NULL != p_data);
if (aci_queue_is_empty_from_isr(aci_q))
{
return false;
}
memcpy((uint8_t *)p_data, (uint8_t *)&(aci_q->aci_data[aci_q->head]), sizeof(hal_aci_data_t));
aci_q->head = (aci_q->head + 1) % ACI_QUEUE_SIZE;
return true;
}
bool aci_queue_enqueue(aci_queue_t *aci_q, hal_aci_data_t *p_data)
{
const uint8_t length = p_data->buffer[0];
// ble_assert(NULL != aci_q);
// ble_assert(NULL != p_data);
if (aci_queue_is_full(aci_q))
{
return false;
}
aci_q->aci_data[aci_q->tail].status_byte = 0;
memcpy((uint8_t *)&(aci_q->aci_data[aci_q->tail].buffer[0]), (uint8_t *)&p_data->buffer[0], length + 1);
aci_q->tail = (aci_q->tail + 1) % ACI_QUEUE_SIZE;
return true;
}
bool aci_queue_enqueue_from_isr(aci_queue_t *aci_q, hal_aci_data_t *p_data)
{
const uint8_t length = p_data->buffer[0];
// ble_assert(NULL != aci_q);
// ble_assert(NULL != p_data);
if (aci_queue_is_full_from_isr(aci_q))
{
return false;
}
aci_q->aci_data[aci_q->tail].status_byte = 0;
memcpy((uint8_t *)&(aci_q->aci_data[aci_q->tail].buffer[0]), (uint8_t *)&p_data->buffer[0], length + 1);
aci_q->tail = (aci_q->tail + 1) % ACI_QUEUE_SIZE;
return true;
}
bool aci_queue_is_empty(aci_queue_t *aci_q)
{
bool state = false;
// ble_assert(NULL != aci_q);
//Critical section
// noInterrupts();
if (aci_q->head == aci_q->tail)
{
state = true;
}
// interrupts();
return state;
}
bool aci_queue_is_empty_from_isr(aci_queue_t *aci_q)
{
// ble_assert(NULL != aci_q);
return aci_q->head == aci_q->tail;
}
bool aci_queue_is_full(aci_queue_t *aci_q)
{
uint8_t next;
bool state;
// ble_assert(NULL != aci_q);
//This should be done in a critical section
// noInterrupts();
next = (aci_q->tail + 1) % ACI_QUEUE_SIZE;
if (next == aci_q->head)
{
state = true;
}
else
{
state = false;
}
// interrupts();
//end
return state;
}
bool aci_queue_is_full_from_isr(aci_queue_t *aci_q)
{
const uint8_t next = (aci_q->tail + 1) % ACI_QUEUE_SIZE;
// ble_assert(NULL != aci_q);
return next == aci_q->head;
}
bool aci_queue_peek(aci_queue_t *aci_q, hal_aci_data_t *p_data)
{
// ble_assert(NULL != aci_q);
// ble_assert(NULL != p_data);
if (aci_queue_is_empty(aci_q))
{
return false;
}
memcpy((uint8_t *)p_data, (uint8_t *)&(aci_q->aci_data[aci_q->head]), sizeof(hal_aci_data_t));
return true;
}
bool aci_queue_peek_from_isr(aci_queue_t *aci_q, hal_aci_data_t *p_data)
{
// ble_assert(NULL != aci_q);
// ble_assert(NULL != p_data);
if (aci_queue_is_empty_from_isr(aci_q))
{
return false;
}
memcpy((uint8_t *)p_data, (uint8_t *)&(aci_q->aci_data[aci_q->head]), sizeof(hal_aci_data_t));
return true;
}

View File

@ -1,76 +1,76 @@
/* 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.
*/
/**
* @file
* @brief Interface for buffer.
* @ingroup aci
*/
/**
@{
*/
#ifndef ACI_QUEUE_H__
#define ACI_QUEUE_H__
#include "aci.h"
#include "hal_aci_tl.h"
/*********************************************************************** */
/* The ACI_QUEUE_SIZE determines the memory usage of the system. */
/* Successfully tested to a ACI_QUEUE_SIZE of 4 (interrupt) and 4 (polling) */
/*********************************************************************** */
#define ACI_QUEUE_SIZE 4
/** Data type for queue of data packets to send/receive from radio.
*
* A FIFO queue is maintained for packets. New packets are added (enqueued)
* at the tail and taken (dequeued) from the head. The head variable is the
* index of the next packet to dequeue while the tail variable is the index of
* where the next packet should be queued.
*/
typedef struct {
hal_aci_data_t aci_data[ACI_QUEUE_SIZE];
uint8_t head;
uint8_t tail;
} aci_queue_t;
void aci_queue_init(aci_queue_t *aci_q);
bool aci_queue_dequeue(aci_queue_t *aci_q, hal_aci_data_t *p_data);
bool aci_queue_dequeue_from_isr(aci_queue_t *aci_q, hal_aci_data_t *p_data);
bool aci_queue_enqueue(aci_queue_t *aci_q, hal_aci_data_t *p_data);
bool aci_queue_enqueue_from_isr(aci_queue_t *aci_q, hal_aci_data_t *p_data);
bool aci_queue_is_empty(aci_queue_t *aci_q);
bool aci_queue_is_empty_from_isr(aci_queue_t *aci_q);
bool aci_queue_is_full(aci_queue_t *aci_q);
bool aci_queue_is_full_from_isr(aci_queue_t *aci_q);
bool aci_queue_peek(aci_queue_t *aci_q, hal_aci_data_t *p_data);
bool aci_queue_peek_from_isr(aci_queue_t *aci_q, hal_aci_data_t *p_data);
#endif /* ACI_QUEUE_H__ */
/** @} */
/* 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.
*/
/**
* @file
* @brief Interface for buffer.
* @ingroup aci
*/
/**
@{
*/
#ifndef ACI_QUEUE_H__
#define ACI_QUEUE_H__
#include "aci.h"
#include "hal_aci_tl.h"
/*********************************************************************** */
/* The ACI_QUEUE_SIZE determines the memory usage of the system. */
/* Successfully tested to a ACI_QUEUE_SIZE of 4 (interrupt) and 4 (polling) */
/*********************************************************************** */
#define ACI_QUEUE_SIZE 4
/** Data type for queue of data packets to send/receive from radio.
*
* A FIFO queue is maintained for packets. New packets are added (enqueued)
* at the tail and taken (dequeued) from the head. The head variable is the
* index of the next packet to dequeue while the tail variable is the index of
* where the next packet should be queued.
*/
typedef struct {
hal_aci_data_t aci_data[ACI_QUEUE_SIZE];
uint8_t head;
uint8_t tail;
} aci_queue_t;
void aci_queue_init(aci_queue_t *aci_q);
bool aci_queue_dequeue(aci_queue_t *aci_q, hal_aci_data_t *p_data);
bool aci_queue_dequeue_from_isr(aci_queue_t *aci_q, hal_aci_data_t *p_data);
bool aci_queue_enqueue(aci_queue_t *aci_q, hal_aci_data_t *p_data);
bool aci_queue_enqueue_from_isr(aci_queue_t *aci_q, hal_aci_data_t *p_data);
bool aci_queue_is_empty(aci_queue_t *aci_q);
bool aci_queue_is_empty_from_isr(aci_queue_t *aci_q);
bool aci_queue_is_full(aci_queue_t *aci_q);
bool aci_queue_is_full_from_isr(aci_queue_t *aci_q);
bool aci_queue_peek(aci_queue_t *aci_q, hal_aci_data_t *p_data);
bool aci_queue_peek_from_isr(aci_queue_t *aci_q, hal_aci_data_t *p_data);
#endif /* ACI_QUEUE_H__ */
/** @} */

View File

@ -1,177 +1,177 @@
/* 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 "aci.h"
#include "hal_aci_tl.h"
#include <lib_aci.h>
#include "aci_setup.h"
// 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)
// hal_aci_data_t msg_to_send;
extern hal_aci_data_t msg_to_send;
/************************************************************************** */
/* Utility function to fill the the ACI command queue */
/* aci_stat Pointer to the ACI state */
/* num_cmd_offset(in/out) Offset in the Setup message array to start from */
/* offset is updated to the new index after the queue is filled */
/* or the last message us placed in the queue */
/* Returns true if at least one message was transferred */
/***************************************************************************/
bool aci_setup_fill(aci_state_t *aci_stat, uint8_t *num_cmd_offset)
{
bool ret_val = false;
while (*num_cmd_offset < aci_stat->aci_setup_info.num_setup_msgs)
{
//Board dependent defines
/*#if defined (__AVR__)
//For Arduino copy the setup ACI message from Flash to RAM.
memcpy_P(&msg_to_send, &(aci_stat->aci_setup_info.setup_msgs[*num_cmd_offset]),
pgm_read_byte_near(&(aci_stat->aci_setup_info.setup_msgs[*num_cmd_offset].buffer[0]))+2);
#elif defined(__PIC32MX__)
//In ChipKit we store the setup messages in RAM
//Add 2 bytes to the length byte for status byte, length for the total number of bytes
memcpy(&msg_to_send, &(aci_stat->aci_setup_info.setup_msgs[*num_cmd_offset]),
(aci_stat->aci_setup_info.setup_msgs[*num_cmd_offset].buffer[0]+2));
#endif*/
memcpy(&msg_to_send, &(aci_stat->aci_setup_info.setup_msgs[*num_cmd_offset]),
(aci_stat->aci_setup_info.setup_msgs[*num_cmd_offset].buffer[0]+2));
//Put the Setup ACI message in the command queue
if (!hal_aci_tl_send(&msg_to_send))
{
//ACI Command Queue is full
// *num_cmd_offset is now pointing to the index of the Setup command that did not get sent
return ret_val;
}
ret_val = true;
(*num_cmd_offset)++;
}
return ret_val;
}
uint8_t do_aci_setup(aci_state_t *aci_stat)
{
uint8_t setup_offset = 0;
uint32_t i = 0x0000;
aci_evt_t * aci_evt = NULL;
aci_status_code_t cmd_status = ACI_STATUS_ERROR_CRC_MISMATCH;
/*
We are using the same buffer since we are copying the contents of the buffer
when queuing and immediately processing the buffer when receiving
*/
hal_aci_evt_t *aci_data = (hal_aci_evt_t *)&msg_to_send;
/* Messages in the outgoing queue must be handled before the Setup routine can run.
* If it is non-empty we return. The user should then process the messages before calling
* do_aci_setup() again.
*/
if (!lib_aci_command_queue_empty())
{
return SETUP_FAIL_COMMAND_QUEUE_NOT_EMPTY;
}
/* If there are events pending from the device that are not relevant to setup, we return false
* so that the user can handle them. At this point we don't care what the event is,
* as any event is an error.
*/
if (lib_aci_event_peek(aci_data))
{
return SETUP_FAIL_EVENT_QUEUE_NOT_EMPTY;
}
/* Fill the ACI command queue with as many Setup messages as it will hold. */
aci_setup_fill(aci_stat, &setup_offset);
while (cmd_status != ACI_STATUS_TRANSACTION_COMPLETE)
{
/* This counter is used to ensure that this function does not loop forever. When the device
* returns a valid response, we reset the counter.
*/
if (i++ > 0xFFFFE)
{
return SETUP_FAIL_TIMEOUT;
}
if (lib_aci_event_peek(aci_data))
{
aci_evt = &(aci_data->evt);
if (ACI_EVT_CMD_RSP != aci_evt->evt_opcode)
{
//Receiving something other than a Command Response Event is an error.
return SETUP_FAIL_NOT_COMMAND_RESPONSE;
}
cmd_status = (aci_status_code_t) aci_evt->params.cmd_rsp.cmd_status;
switch (cmd_status)
{
case ACI_STATUS_TRANSACTION_CONTINUE:
//As the device is responding, reset guard counter
i = 0;
/* As the device has processed the Setup messages we put in the command queue earlier,
* we can proceed to fill the queue with new messages
*/
aci_setup_fill(aci_stat, &setup_offset);
break;
case ACI_STATUS_TRANSACTION_COMPLETE:
//Break out of the while loop when this status code appears
break;
default:
//An event with any other status code should be handled by the application
return SETUP_FAIL_NOT_SETUP_EVENT;
}
/* If we haven't returned at this point, the event was either ACI_STATUS_TRANSACTION_CONTINUE
* or ACI_STATUS_TRANSACTION_COMPLETE. We don't need the event itself, so we simply
* remove it from the queue.
*/
lib_aci_event_get (aci_stat, aci_data);
}
}
return SETUP_SUCCESS;
}
/* 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 "aci.h"
#include "hal_aci_tl.h"
#include <lib_aci.h>
#include "aci_setup.h"
// 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)
// hal_aci_data_t msg_to_send;
extern hal_aci_data_t msg_to_send;
/************************************************************************** */
/* Utility function to fill the the ACI command queue */
/* aci_stat Pointer to the ACI state */
/* num_cmd_offset(in/out) Offset in the Setup message array to start from */
/* offset is updated to the new index after the queue is filled */
/* or the last message us placed in the queue */
/* Returns true if at least one message was transferred */
/***************************************************************************/
bool aci_setup_fill(aci_state_t *aci_stat, uint8_t *num_cmd_offset)
{
bool ret_val = false;
while (*num_cmd_offset < aci_stat->aci_setup_info.num_setup_msgs)
{
//Board dependent defines
/*#if defined (__AVR__)
//For Arduino copy the setup ACI message from Flash to RAM.
memcpy_P(&msg_to_send, &(aci_stat->aci_setup_info.setup_msgs[*num_cmd_offset]),
pgm_read_byte_near(&(aci_stat->aci_setup_info.setup_msgs[*num_cmd_offset].buffer[0]))+2);
#elif defined(__PIC32MX__)
//In ChipKit we store the setup messages in RAM
//Add 2 bytes to the length byte for status byte, length for the total number of bytes
memcpy(&msg_to_send, &(aci_stat->aci_setup_info.setup_msgs[*num_cmd_offset]),
(aci_stat->aci_setup_info.setup_msgs[*num_cmd_offset].buffer[0]+2));
#endif*/
memcpy(&msg_to_send, &(aci_stat->aci_setup_info.setup_msgs[*num_cmd_offset]),
(aci_stat->aci_setup_info.setup_msgs[*num_cmd_offset].buffer[0]+2));
//Put the Setup ACI message in the command queue
if (!hal_aci_tl_send(&msg_to_send))
{
//ACI Command Queue is full
// *num_cmd_offset is now pointing to the index of the Setup command that did not get sent
return ret_val;
}
ret_val = true;
(*num_cmd_offset)++;
}
return ret_val;
}
uint8_t do_aci_setup(aci_state_t *aci_stat)
{
uint8_t setup_offset = 0;
uint32_t i = 0x0000;
aci_evt_t * aci_evt = NULL;
aci_status_code_t cmd_status = ACI_STATUS_ERROR_CRC_MISMATCH;
/*
We are using the same buffer since we are copying the contents of the buffer
when queuing and immediately processing the buffer when receiving
*/
hal_aci_evt_t *aci_data = (hal_aci_evt_t *)&msg_to_send;
/* Messages in the outgoing queue must be handled before the Setup routine can run.
* If it is non-empty we return. The user should then process the messages before calling
* do_aci_setup() again.
*/
if (!lib_aci_command_queue_empty())
{
return SETUP_FAIL_COMMAND_QUEUE_NOT_EMPTY;
}
/* If there are events pending from the device that are not relevant to setup, we return false
* so that the user can handle them. At this point we don't care what the event is,
* as any event is an error.
*/
if (lib_aci_event_peek(aci_data))
{
return SETUP_FAIL_EVENT_QUEUE_NOT_EMPTY;
}
/* Fill the ACI command queue with as many Setup messages as it will hold. */
aci_setup_fill(aci_stat, &setup_offset);
while (cmd_status != ACI_STATUS_TRANSACTION_COMPLETE)
{
/* This counter is used to ensure that this function does not loop forever. When the device
* returns a valid response, we reset the counter.
*/
if (i++ > 0xFFFFE)
{
return SETUP_FAIL_TIMEOUT;
}
if (lib_aci_event_peek(aci_data))
{
aci_evt = &(aci_data->evt);
if (ACI_EVT_CMD_RSP != aci_evt->evt_opcode)
{
//Receiving something other than a Command Response Event is an error.
return SETUP_FAIL_NOT_COMMAND_RESPONSE;
}
cmd_status = (aci_status_code_t) aci_evt->params.cmd_rsp.cmd_status;
switch (cmd_status)
{
case ACI_STATUS_TRANSACTION_CONTINUE:
//As the device is responding, reset guard counter
i = 0;
/* As the device has processed the Setup messages we put in the command queue earlier,
* we can proceed to fill the queue with new messages
*/
aci_setup_fill(aci_stat, &setup_offset);
break;
case ACI_STATUS_TRANSACTION_COMPLETE:
//Break out of the while loop when this status code appears
break;
default:
//An event with any other status code should be handled by the application
return SETUP_FAIL_NOT_SETUP_EVENT;
}
/* If we haven't returned at this point, the event was either ACI_STATUS_TRANSACTION_CONTINUE
* or ACI_STATUS_TRANSACTION_COMPLETE. We don't need the event itself, so we simply
* remove it from the queue.
*/
lib_aci_event_get (aci_stat, aci_data);
}
}
return SETUP_SUCCESS;
}

View File

@ -1,50 +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.
*/
/**
* @file
* @brief ACI setup functions
* @ingroup aci
*/
#ifndef H_ACI_SETUP
#define H_ACI_SETUP
#define SETUP_SUCCESS 0
#define SETUP_FAIL_COMMAND_QUEUE_NOT_EMPTY 1
#define SETUP_FAIL_EVENT_QUEUE_NOT_EMPTY 2
#define SETUP_FAIL_TIMEOUT 3
#define SETUP_FAIL_NOT_SETUP_EVENT 4
#define SETUP_FAIL_NOT_COMMAND_RESPONSE 5
bool aci_setup_fill(aci_state_t *aci_stat, uint8_t *num_cmd_offset);
/** @brief Setup the nRF8001 device
* @details
* Performs ACI Setup by transmitting the setup messages generated by nRFgo Studio to the
* nRF8001, and should be called when the nRF8001 starts or resets.
* Once all messages are sent, the nRF8001 will send a Device Started Event.
* The function requires that the Command queue is empty when it is invoked, and will fail
* otherwise.
* @returns An integer indicating the reason the function terminated
*/
uint8_t do_aci_setup(aci_state_t *aci_stat);
#endif
/* 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.
*/
/**
* @file
* @brief ACI setup functions
* @ingroup aci
*/
#ifndef H_ACI_SETUP
#define H_ACI_SETUP
#define SETUP_SUCCESS 0
#define SETUP_FAIL_COMMAND_QUEUE_NOT_EMPTY 1
#define SETUP_FAIL_EVENT_QUEUE_NOT_EMPTY 2
#define SETUP_FAIL_TIMEOUT 3
#define SETUP_FAIL_NOT_SETUP_EVENT 4
#define SETUP_FAIL_NOT_COMMAND_RESPONSE 5
bool aci_setup_fill(aci_state_t *aci_stat, uint8_t *num_cmd_offset);
/** @brief Setup the nRF8001 device
* @details
* Performs ACI Setup by transmitting the setup messages generated by nRFgo Studio to the
* nRF8001, and should be called when the nRF8001 starts or resets.
* Once all messages are sent, the nRF8001 will send a Device Started Event.
* The function requires that the Command queue is empty when it is invoked, and will fail
* otherwise.
* @returns An integer indicating the reason the function terminated
*/
uint8_t do_aci_setup(aci_state_t *aci_stat);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,61 +1,61 @@
/* 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.
*/
/**
* @file
*
* @ingroup aci-lib
*
* @brief Internal prototype for acilib module.
*/
#ifndef _acilib_H_
#define _acilib_H_
#define MSG_SET_LOCAL_DATA_BASE_LEN 2
#define MSG_CONNECT_LEN 5
#define MSG_BOND_LEN 5
#define MSG_DISCONNECT_LEN 2
#define MSG_BASEBAND_RESET_LEN 1
#define MSG_WAKEUP_LEN 1
#define MSG_SET_RADIO_TX_POWER_LEN 2
#define MSG_GET_DEVICE_ADDR_LEN 1
#define MSG_SEND_DATA_BASE_LEN 2
#define MSG_DATA_REQUEST_LEN 2
#define MSG_OPEN_REMOTE_PIPE_LEN 2
#define MSG_CLOSE_REMOTE_PIPE_LEN 2
#define MSG_DTM_CMD 3
#define MSG_WRITE_DYNAMIC_DATA_BASE_LEN 2
#define MSG_SETUP_CMD_BASE_LEN 1
#define MSG_ECHO_MSG_CMD_BASE_LEN 1
#define MSG_CHANGE_TIMING_LEN 9
#define MSG_SET_APP_LATENCY_LEN 4
#define MSG_CHANGE_TIMING_LEN_GAP_PPCP 1
#define MSG_DIRECT_CONNECT_LEN 1
#define MSG_SET_KEY_REJECT_LEN 2
#define MSG_SET_KEY_PASSKEY_LEN 8
#define MSG_SET_KEY_OOB_LEN 18
#define MSG_ACK_LEN 2
#define MSG_NACK_LEN 3
#define MSG_BROADCAST_LEN 5
#define MSG_OPEN_ADV_PIPES_LEN 9
#endif /* _acilib_H_ */
/* 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.
*/
/**
* @file
*
* @ingroup aci-lib
*
* @brief Internal prototype for acilib module.
*/
#ifndef _acilib_H_
#define _acilib_H_
#define MSG_SET_LOCAL_DATA_BASE_LEN 2
#define MSG_CONNECT_LEN 5
#define MSG_BOND_LEN 5
#define MSG_DISCONNECT_LEN 2
#define MSG_BASEBAND_RESET_LEN 1
#define MSG_WAKEUP_LEN 1
#define MSG_SET_RADIO_TX_POWER_LEN 2
#define MSG_GET_DEVICE_ADDR_LEN 1
#define MSG_SEND_DATA_BASE_LEN 2
#define MSG_DATA_REQUEST_LEN 2
#define MSG_OPEN_REMOTE_PIPE_LEN 2
#define MSG_CLOSE_REMOTE_PIPE_LEN 2
#define MSG_DTM_CMD 3
#define MSG_WRITE_DYNAMIC_DATA_BASE_LEN 2
#define MSG_SETUP_CMD_BASE_LEN 1
#define MSG_ECHO_MSG_CMD_BASE_LEN 1
#define MSG_CHANGE_TIMING_LEN 9
#define MSG_SET_APP_LATENCY_LEN 4
#define MSG_CHANGE_TIMING_LEN_GAP_PPCP 1
#define MSG_DIRECT_CONNECT_LEN 1
#define MSG_SET_KEY_REJECT_LEN 2
#define MSG_SET_KEY_PASSKEY_LEN 8
#define MSG_SET_KEY_OOB_LEN 18
#define MSG_ACK_LEN 2
#define MSG_NACK_LEN 3
#define MSG_BROADCAST_LEN 5
#define MSG_OPEN_ADV_PIPES_LEN 9
#endif /* _acilib_H_ */

View File

@ -1,37 +1,37 @@
/* 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.
*/
/**
* @file
*
* @ingroup aci-lib
*
* @brief Definitions for the acilib interfaces
*/
#ifndef _acilib_DEFS_H_
#define _acilib_DEFS_H_
#define ACIL_DECODE_EVT_GET_LENGTH(buffer_in) (*(buffer_in + OFFSET_ACI_EVT_T_LEN))
#define ACIL_DECODE_EVT_GET_OPCODE(buffer_in) (*(buffer_in + OFFSET_ACI_EVT_T_EVT_OPCODE))
#endif /* _acilib_DEFS_H_ */
/* 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.
*/
/**
* @file
*
* @ingroup aci-lib
*
* @brief Definitions for the acilib interfaces
*/
#ifndef _acilib_DEFS_H_
#define _acilib_DEFS_H_
#define ACIL_DECODE_EVT_GET_LENGTH(buffer_in) (*(buffer_in + OFFSET_ACI_EVT_T_LEN))
#define ACIL_DECODE_EVT_GET_OPCODE(buffer_in) (*(buffer_in + OFFSET_ACI_EVT_T_EVT_OPCODE))
#endif /* _acilib_DEFS_H_ */

View File

@ -1,471 +1,471 @@
/* 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.
*/
/**
* @file
*
* @ingroup aci-lib
*
* @brief Prototypes for the acilib interfaces.
*/
#ifndef _acilib_IF_H_
#define _acilib_IF_H_
/** @brief Encode the ACI message for set test mode command
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] test_mode Pointer to the test mode in ::aci_cmd_params_test_t
*
* @return None
*/
void acil_encode_cmd_set_test_mode(uint8_t *buffer, aci_cmd_params_test_t *p_aci_cmd_params_test);
/** @brief Encode the ACI message for sleep command
*
* @param[in,out] buffer Pointer to ACI message buffer
*
* @return None
*/
void acil_encode_cmd_sleep(uint8_t *buffer);
/** @brief Encode the ACI message for get device version
*
* @param[in,out] buffer Pointer to ACI message buffer
*
* @return None
*/
void acil_encode_cmd_get_device_version(uint8_t *buffer);
/** @brief Encode the ACI message for set local data
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] p_aci_cmd_params_set_local_data Pointer to the local data parameters in ::aci_cmd_params_set_local_data_t
* @param[in] data_size Size of data message
*
* @return None
*/
void acil_encode_cmd_set_local_data(uint8_t *buffer, aci_cmd_params_set_local_data_t *p_aci_cmd_params_set_local_data, uint8_t data_size);
/** @brief Encode the ACI message to connect
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] p_aci_cmd_params_connect Pointer to the run parameters in ::aci_cmd_params_connect_t
*
* @return None
*/
void acil_encode_cmd_connect(uint8_t *buffer, aci_cmd_params_connect_t *p_aci_cmd_params_connect);
/** @brief Encode the ACI message to bond
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] p_aci_cmd_params_bond Pointer to the run parameters in ::aci_cmd_params_bond_t
*
* @return None
*/
void acil_encode_cmd_bond(uint8_t *buffer, aci_cmd_params_bond_t *p_aci_cmd_params_bond);
/** @brief Encode the ACI message to disconnect
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] p_aci_cmd_params_disconnect Pointer to the run parameters in ::aci_cmd_params_disconnect_t
*
* @return None
*/
void acil_encode_cmd_disconnect(uint8_t *buffer, aci_cmd_params_disconnect_t *p_aci_cmd_params_disconnect);
/** @brief Encode the ACI message to baseband reset
*
* @param[in,out] buffer Pointer to ACI message buffer
*
* @return None
*/
void acil_encode_baseband_reset(uint8_t *buffer);
/** @brief Encode the ACI message for Directed Advertising
*
* @param[in,out] buffer Pointer to ACI message buffer
*
* @return None
*/
void acil_encode_direct_connect(uint8_t *buffer);
/** @brief Encode the ACI message to wakeup
*
* @param[in,out] buffer Pointer to ACI message buffer
*
* @return None
*/
void acil_encode_cmd_wakeup(uint8_t *buffer);
/** @brief Encode the ACI message for set radio Tx power
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] p_aci_cmd_params_set_tx_power Pointer to the set Tx power parameters in ::aci_cmd_params_set_tx_power_t
*
* @return None
*/
void acil_encode_cmd_set_radio_tx_power(uint8_t *buffer, aci_cmd_params_set_tx_power_t *p_aci_cmd_params_set_tx_power);
/** @brief Encode the ACI message for get device address
*
* @param[in,out] buffer Pointer to ACI message buffer
*
* @return None
*/
void acil_encode_cmd_get_address(uint8_t *buffer);
/** @brief Encode the ACI message for send data
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] p_aci_cmd_params_send_data_t Pointer to the data parameters in ::aci_cmd_params_send_data_t
* @param[in] data_size Size of data message
*
* @return None
*/
void acil_encode_cmd_send_data(uint8_t *buffer, aci_cmd_params_send_data_t *p_aci_cmd_params_send_data_t, uint8_t data_size);
/** @brief Encode the ACI message for request data
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] p_aci_cmd_params_request_data Pointer to the request data parameters in ::aci_cmd_params_request_data_t
*
* @return None
*/
void acil_encode_cmd_request_data(uint8_t *buffer, aci_cmd_params_request_data_t *p_aci_cmd_params_request_data);
/** @brief Encode the ACI message for open remote pipe
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] p_aci_cmd_params_open_remote_pipe Pointer to the dynamic data parameters in ::aci_cmd_params_open_remote_pipe_t
*
* @return None
*/
void acil_encode_cmd_open_remote_pipe(uint8_t *buffer, aci_cmd_params_open_remote_pipe_t *p_aci_cmd_params_open_remote_pipe);
/** @brief Encode the ACI message for close remote pipe
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] p_aci_cmd_params_close_remote_pipe Pointer to the dynamic data parameters in ::aci_cmd_params_close_remote_pipe_t
*
* @return None
*/
void acil_encode_cmd_close_remote_pipe(uint8_t *buffer, aci_cmd_params_close_remote_pipe_t *p_aci_cmd_params_close_remote_pipe);
/** @brief Encode the ACI message for echo message
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] p_cmd_params_echo Pointer to the dynamic data parameters in ::aci_cmd_params_echo_t
* @param[in] msg_size Size of the message
*
* @return None
*/
void acil_encode_cmd_echo_msg(uint8_t *buffer, aci_cmd_params_echo_t *p_cmd_params_echo, uint8_t msg_size);
/** @brief Encode the ACI message to battery level
*
* @param[in,out] buffer Pointer to ACI message buffer
*
* @return None
*/
void acil_encode_cmd_battery_level(uint8_t *buffer);
/** @brief Encode the ACI message to temparature
*
* @param[in,out] buffer Pointer to ACI message buffer
*
* @return None
*/
void acil_encode_cmd_temparature(uint8_t *buffer);
/** @brief Encode the ACI message to read dynamic data
*
* @param[in,out] buffer Pointer to ACI message buffer
*
* @return None
*/
void acil_encode_cmd_read_dynamic_data(uint8_t *buffer);
/** @brief Encode the ACI message to change timing request
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] p_aci_cmd_params_change_timing Pointer to the change timing parameters in ::aci_cmd_params_change_timing_t
*
* @return None
*/
void acil_encode_cmd_change_timing_req(uint8_t *buffer, aci_cmd_params_change_timing_t *p_aci_cmd_params_change_timing);
/** @brief Encode the ACI message to change timing request using the timing parameters from GAP PPCP
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] p_aci_cmd_params_change_timing Pointer to the change timing parameters in ::aci_cmd_params_change_timing_t
*
* @return None
*/
void acil_encode_cmd_change_timing_req_GAP_PPCP(uint8_t *buffer);
/** @brief Encode the ACI message for write dynamic data
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] seq_no Sequence number of the dynamic data (as received in the response to @c Read Dynamic Data)
* @param[in] dynamic_data Pointer to the dynamic data
* @param[in] dynamic_data_size Size of dynamic data
*
* @return None
*/
void acil_encode_cmd_write_dynamic_data(uint8_t *buffer, uint8_t seq_no, uint8_t* dynamic_data, uint8_t dynamic_data_size);
/** @brief Encode the ACI message to send data acknowledgement
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] pipe_number Pipe number for which the ack is to be sent
*
* @return None
*/
void acil_encode_cmd_send_data_ack(uint8_t *buffer, const uint8_t pipe_number);
/** @brief Encode the ACI message to send negative acknowledgement
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] pipe_number Pipe number for which the nack is to be sent
* @param[in] error_code Error code that has to be sent in the NACK
*
* @return None
*/
void acil_encode_cmd_send_data_nack(uint8_t *buffer, const uint8_t pipe_number,const uint8_t error_code);
/** @brief Encode the ACI message to set the application latency
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] p_aci_cmd_params_set_app_latency Pointer to the set_application_latency command parameters in ::aci_cmd_params_dtm_cmd_t
*
* @return None
*/
void acil_encode_cmd_set_app_latency(uint8_t *buffer, aci_cmd_params_set_app_latency_t *p_aci_cmd_params_set_app_latency);
/** @brief Encode the ACI message for setup
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] p_cmd_params_set_run_behaviour Pointer to the setup data in ::aci_cmd_params_setup_t
* @param[in] setup_data_size Size of setup message
*
* @return None
*/
void acil_encode_cmd_setup(uint8_t *buffer, aci_cmd_params_setup_t *p_aci_cmd_params_setup, uint8_t setup_data_size);
/** @brief Encode the ACI message for DTM command
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] p_cmd_params_set_run_behaviour Pointer to the DTM command parameters in ::aci_cmd_params_dtm_cmd_t
*
* @return None
*/
void acil_encode_cmd_dtm_cmd(uint8_t *buffer, aci_cmd_params_dtm_cmd_t *p_aci_cmd_params_dtm_cmd);
/** @brief Encode the ACI message for Set Key Request command
*
* @param[in,out] buffer Pointer to ACI message buffer
*
* @return None
*/
void acil_encode_cmd_set_key(uint8_t *buffer, aci_cmd_params_set_key_t *p_aci_cmd_params_set_key);
/** @brief Encode the ACI message for Bond Security Request command
*
* @param[in,out] buffer Pointer to ACI message buffer
*
* @return None
*/
void acil_encode_cmd_bond_security_request(uint8_t *buffer);
/** @brief Encode the ACI message
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] p_aci_cmd Pointer to ACI command data in ::aci_cmd_t
* @param[in] bool
*
* @return bool true, if succesful, else returns false
*/
bool acil_encode_cmd(uint8_t *buffer, aci_cmd_t *p_aci_cmd);
/** @brief Encode the ACI message for Broadcast command
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] p_aci_cmd Pointer to ACI command data in ::aci_cmd_params_broadcast_t
*
* @return None
*/
void acil_encode_cmd_broadcast(uint8_t *buffer, aci_cmd_params_broadcast_t * p_aci_cmd_params_broadcast);
/** @brief Encode the ACI message for Open Adv Pipes
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] p_aci_cmd Pointer to ACI command data in ::aci_cmd_params_open_adv_pipe_t
*
* @return None
*/
void acil_encode_cmd_open_adv_pipes(uint8_t *buffer, aci_cmd_params_open_adv_pipe_t * p_aci_cmd_params_set_adv_svc_data);
/** @brief Decode the ACI event command response
*
* @param[in] buffer_in Pointer to message received
* @param[in,out] buffer Pointer to the decoded message in ::aci_evt_params_cmd_rsp_t
*
* @return None
*/
void acil_decode_evt_command_response(uint8_t *buffer_in, aci_evt_params_cmd_rsp_t *p_evt_params_cmd_rsp);
/** @brief Decode the ACI event device started
*
* @param[in] buffer_in Pointer to message received
* @param[in,out] p_aci_evt Pointer to the decoded message in ::aci_evt_params_device_started_t
*
* @return None
*/
void acil_decode_evt_device_started(uint8_t *buffer_in, aci_evt_params_device_started_t *p_evt_params_device_started);
/** @brief Decode the ACI event pipe status
*
* @param[in] buffer_in Pointer to message received
* @param[in,out] p_aci_evt_params_pipe_status Pointer to the decoded message in ::aci_evt_params_pipe_status_t
*
* @return None
*/
void acil_decode_evt_pipe_status(uint8_t *buffer_in, aci_evt_params_pipe_status_t *p_aci_evt_params_pipe_status);
/** @brief Decode the ACI event for disconnected
*
* @param[in] buffer_in Pointer to message received
* @param[in,out] p_aci_evt_params_disconnected Pointer to the decoded message in ::aci_evt_params_disconnected_t
*
* @return None
*/
void acil_decode_evt_disconnected(uint8_t *buffer_in, aci_evt_params_disconnected_t *p_aci_evt_params_disconnected);
/** @brief Decode the ACI event for bond status
*
* @param[in] buffer_in Pointer to message received
* @param[in,out] p_aci_evt_params_bond_status Pointer to the decoded message in ::aci_evt_params_bond_status_t
*
* @return None
*/
void acil_decode_evt_bond_status(uint8_t *buffer_in, aci_evt_params_bond_status_t *p_aci_evt_params_bond_status);
/** @brief Decode the ACI event for data received
*
* @param[in] buffer_in Pointer to message received
* @param[in,out] p_evt_params_data_received Pointer to the decoded message in ::aci_evt_params_data_received_t
*
* @return size Received data size
*/
uint8_t acil_decode_evt_data_received(uint8_t *buffer_in, aci_evt_params_data_received_t *p_evt_params_data_received);
/** @brief Decode the ACI event data acknowledgement
*
* @param[in] buffer_in Pointer to message received
* @param[in,out] p_evt_params_data_ack Pointer to the decoded message in ::aci_evt_params_data_ack_t
*
* @return None
*/
void acil_decode_evt_data_ack(uint8_t *buffer_in, aci_evt_params_data_ack_t *p_evt_params_data_ack);
/** @brief Decode the ACI event for hardware error
*
* @param[in] buffer_in Pointer to message received
* @param[in,out] p_aci_evt_params_hw_error Pointer to the decoded message in ::aci_evt_params_hw_error_t
*
* @return size Size of debug information
*/
uint8_t acil_decode_evt_hw_error(uint8_t *buffer_in, aci_evt_params_hw_error_t *p_aci_evt_params_hw_error);
/** @brief Decode the ACI event data credit
*
* @param[in] buffer_in Pointer to message received
* @param[in,out] p_evt_params_data_credit Pointer to the decoded message in ::aci_evt_params_data_credit_t
*
* @return None
*/
void acil_decode_evt_credit(uint8_t *buffer_in, aci_evt_params_data_credit_t *p_evt_params_data_credit);
/** @brief Decode the ACI event for connected
*
* @param[in] buffer_in Pointer to message received
* @param[in,out] p_aci_evt_params_connected Pointer to the decoded message in ::aci_evt_params_connected_t
*
* @return None
*/
void acil_decode_evt_connected(uint8_t *buffer_in, aci_evt_params_connected_t *p_aci_evt_params_connected);
/** @brief Decode the ACI event for timing
*
* @param[in] buffer_in Pointer to message received
* @param[in,out] p_evt_params_timing Pointer to the decoded message in ::aci_evt_params_timing_t
*
* @return None
*/
void acil_decode_evt_timing(uint8_t *buffer_in, aci_evt_params_timing_t *p_evt_params_timing);
/** @brief Decode the ACI event for pipe error
*
* @param[in] buffer_in Pointer to message received
* @param[in,out] p_evt_params_pipe_error Pointer to the decoded message in ::aci_evt_params_pipe_error_t
*
*/
void acil_decode_evt_pipe_error(uint8_t *buffer_in, aci_evt_params_pipe_error_t *p_evt_params_pipe_error);
/** @brief Decode the ACI event for key request
*
* @param[in] buffer_in Pointer to message received
* @param[in,out] p_evt_params_key_type Pointer to the decoded message in ::aci_evt_params_key_type_t
*
* @return None
*/
void acil_decode_evt_key_request(uint8_t *buffer_in, aci_evt_params_key_request_t *p_evt_params_key_request);
/** @brief Decode the ACI event for echo
*
* @param[in] buffer_in Pointer to message received
* @param[in,out] buffer_out Pointer to the echo message (max size of buffer ::ACI_ECHO_DATA_MAX_LEN)
*
* @return size Received echo message size
*/
uint8_t acil_decode_evt_echo(uint8_t *buffer_in, aci_evt_params_echo_t *buffer_out);
/** @brief Decode the ACI event
*
* @param[in] buffer_in Pointer to message received
* @param[in,out] p_aci_evt Pointer to the decoded message in ::aci_evt_t
*
* @return bool true, if succesful, else returns false
*/
bool acil_decode_evt(uint8_t *buffer_in, aci_evt_t *p_aci_evt);
/** @brief Decode the Display Key Event
*
* @param[in] buffer_in Pointer to message received
* @param[in,out] p_aci_evt Pointer to the decoded message in ::aci_evt_params_display_passkey_t
*
* @return None
*/
void acil_decode_evt_display_passkey(uint8_t *buffer_in, aci_evt_params_display_passkey_t *p_aci_evt_params_display_passkey);
#endif /* _acilib_IF_H_ */
/* 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.
*/
/**
* @file
*
* @ingroup aci-lib
*
* @brief Prototypes for the acilib interfaces.
*/
#ifndef _acilib_IF_H_
#define _acilib_IF_H_
/** @brief Encode the ACI message for set test mode command
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] test_mode Pointer to the test mode in ::aci_cmd_params_test_t
*
* @return None
*/
void acil_encode_cmd_set_test_mode(uint8_t *buffer, aci_cmd_params_test_t *p_aci_cmd_params_test);
/** @brief Encode the ACI message for sleep command
*
* @param[in,out] buffer Pointer to ACI message buffer
*
* @return None
*/
void acil_encode_cmd_sleep(uint8_t *buffer);
/** @brief Encode the ACI message for get device version
*
* @param[in,out] buffer Pointer to ACI message buffer
*
* @return None
*/
void acil_encode_cmd_get_device_version(uint8_t *buffer);
/** @brief Encode the ACI message for set local data
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] p_aci_cmd_params_set_local_data Pointer to the local data parameters in ::aci_cmd_params_set_local_data_t
* @param[in] data_size Size of data message
*
* @return None
*/
void acil_encode_cmd_set_local_data(uint8_t *buffer, aci_cmd_params_set_local_data_t *p_aci_cmd_params_set_local_data, uint8_t data_size);
/** @brief Encode the ACI message to connect
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] p_aci_cmd_params_connect Pointer to the run parameters in ::aci_cmd_params_connect_t
*
* @return None
*/
void acil_encode_cmd_connect(uint8_t *buffer, aci_cmd_params_connect_t *p_aci_cmd_params_connect);
/** @brief Encode the ACI message to bond
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] p_aci_cmd_params_bond Pointer to the run parameters in ::aci_cmd_params_bond_t
*
* @return None
*/
void acil_encode_cmd_bond(uint8_t *buffer, aci_cmd_params_bond_t *p_aci_cmd_params_bond);
/** @brief Encode the ACI message to disconnect
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] p_aci_cmd_params_disconnect Pointer to the run parameters in ::aci_cmd_params_disconnect_t
*
* @return None
*/
void acil_encode_cmd_disconnect(uint8_t *buffer, aci_cmd_params_disconnect_t *p_aci_cmd_params_disconnect);
/** @brief Encode the ACI message to baseband reset
*
* @param[in,out] buffer Pointer to ACI message buffer
*
* @return None
*/
void acil_encode_baseband_reset(uint8_t *buffer);
/** @brief Encode the ACI message for Directed Advertising
*
* @param[in,out] buffer Pointer to ACI message buffer
*
* @return None
*/
void acil_encode_direct_connect(uint8_t *buffer);
/** @brief Encode the ACI message to wakeup
*
* @param[in,out] buffer Pointer to ACI message buffer
*
* @return None
*/
void acil_encode_cmd_wakeup(uint8_t *buffer);
/** @brief Encode the ACI message for set radio Tx power
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] p_aci_cmd_params_set_tx_power Pointer to the set Tx power parameters in ::aci_cmd_params_set_tx_power_t
*
* @return None
*/
void acil_encode_cmd_set_radio_tx_power(uint8_t *buffer, aci_cmd_params_set_tx_power_t *p_aci_cmd_params_set_tx_power);
/** @brief Encode the ACI message for get device address
*
* @param[in,out] buffer Pointer to ACI message buffer
*
* @return None
*/
void acil_encode_cmd_get_address(uint8_t *buffer);
/** @brief Encode the ACI message for send data
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] p_aci_cmd_params_send_data_t Pointer to the data parameters in ::aci_cmd_params_send_data_t
* @param[in] data_size Size of data message
*
* @return None
*/
void acil_encode_cmd_send_data(uint8_t *buffer, aci_cmd_params_send_data_t *p_aci_cmd_params_send_data_t, uint8_t data_size);
/** @brief Encode the ACI message for request data
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] p_aci_cmd_params_request_data Pointer to the request data parameters in ::aci_cmd_params_request_data_t
*
* @return None
*/
void acil_encode_cmd_request_data(uint8_t *buffer, aci_cmd_params_request_data_t *p_aci_cmd_params_request_data);
/** @brief Encode the ACI message for open remote pipe
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] p_aci_cmd_params_open_remote_pipe Pointer to the dynamic data parameters in ::aci_cmd_params_open_remote_pipe_t
*
* @return None
*/
void acil_encode_cmd_open_remote_pipe(uint8_t *buffer, aci_cmd_params_open_remote_pipe_t *p_aci_cmd_params_open_remote_pipe);
/** @brief Encode the ACI message for close remote pipe
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] p_aci_cmd_params_close_remote_pipe Pointer to the dynamic data parameters in ::aci_cmd_params_close_remote_pipe_t
*
* @return None
*/
void acil_encode_cmd_close_remote_pipe(uint8_t *buffer, aci_cmd_params_close_remote_pipe_t *p_aci_cmd_params_close_remote_pipe);
/** @brief Encode the ACI message for echo message
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] p_cmd_params_echo Pointer to the dynamic data parameters in ::aci_cmd_params_echo_t
* @param[in] msg_size Size of the message
*
* @return None
*/
void acil_encode_cmd_echo_msg(uint8_t *buffer, aci_cmd_params_echo_t *p_cmd_params_echo, uint8_t msg_size);
/** @brief Encode the ACI message to battery level
*
* @param[in,out] buffer Pointer to ACI message buffer
*
* @return None
*/
void acil_encode_cmd_battery_level(uint8_t *buffer);
/** @brief Encode the ACI message to temparature
*
* @param[in,out] buffer Pointer to ACI message buffer
*
* @return None
*/
void acil_encode_cmd_temparature(uint8_t *buffer);
/** @brief Encode the ACI message to read dynamic data
*
* @param[in,out] buffer Pointer to ACI message buffer
*
* @return None
*/
void acil_encode_cmd_read_dynamic_data(uint8_t *buffer);
/** @brief Encode the ACI message to change timing request
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] p_aci_cmd_params_change_timing Pointer to the change timing parameters in ::aci_cmd_params_change_timing_t
*
* @return None
*/
void acil_encode_cmd_change_timing_req(uint8_t *buffer, aci_cmd_params_change_timing_t *p_aci_cmd_params_change_timing);
/** @brief Encode the ACI message to change timing request using the timing parameters from GAP PPCP
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] p_aci_cmd_params_change_timing Pointer to the change timing parameters in ::aci_cmd_params_change_timing_t
*
* @return None
*/
void acil_encode_cmd_change_timing_req_GAP_PPCP(uint8_t *buffer);
/** @brief Encode the ACI message for write dynamic data
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] seq_no Sequence number of the dynamic data (as received in the response to @c Read Dynamic Data)
* @param[in] dynamic_data Pointer to the dynamic data
* @param[in] dynamic_data_size Size of dynamic data
*
* @return None
*/
void acil_encode_cmd_write_dynamic_data(uint8_t *buffer, uint8_t seq_no, uint8_t* dynamic_data, uint8_t dynamic_data_size);
/** @brief Encode the ACI message to send data acknowledgement
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] pipe_number Pipe number for which the ack is to be sent
*
* @return None
*/
void acil_encode_cmd_send_data_ack(uint8_t *buffer, const uint8_t pipe_number);
/** @brief Encode the ACI message to send negative acknowledgement
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] pipe_number Pipe number for which the nack is to be sent
* @param[in] error_code Error code that has to be sent in the NACK
*
* @return None
*/
void acil_encode_cmd_send_data_nack(uint8_t *buffer, const uint8_t pipe_number,const uint8_t error_code);
/** @brief Encode the ACI message to set the application latency
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] p_aci_cmd_params_set_app_latency Pointer to the set_application_latency command parameters in ::aci_cmd_params_dtm_cmd_t
*
* @return None
*/
void acil_encode_cmd_set_app_latency(uint8_t *buffer, aci_cmd_params_set_app_latency_t *p_aci_cmd_params_set_app_latency);
/** @brief Encode the ACI message for setup
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] p_cmd_params_set_run_behaviour Pointer to the setup data in ::aci_cmd_params_setup_t
* @param[in] setup_data_size Size of setup message
*
* @return None
*/
void acil_encode_cmd_setup(uint8_t *buffer, aci_cmd_params_setup_t *p_aci_cmd_params_setup, uint8_t setup_data_size);
/** @brief Encode the ACI message for DTM command
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] p_cmd_params_set_run_behaviour Pointer to the DTM command parameters in ::aci_cmd_params_dtm_cmd_t
*
* @return None
*/
void acil_encode_cmd_dtm_cmd(uint8_t *buffer, aci_cmd_params_dtm_cmd_t *p_aci_cmd_params_dtm_cmd);
/** @brief Encode the ACI message for Set Key Request command
*
* @param[in,out] buffer Pointer to ACI message buffer
*
* @return None
*/
void acil_encode_cmd_set_key(uint8_t *buffer, aci_cmd_params_set_key_t *p_aci_cmd_params_set_key);
/** @brief Encode the ACI message for Bond Security Request command
*
* @param[in,out] buffer Pointer to ACI message buffer
*
* @return None
*/
void acil_encode_cmd_bond_security_request(uint8_t *buffer);
/** @brief Encode the ACI message
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] p_aci_cmd Pointer to ACI command data in ::aci_cmd_t
* @param[in] bool
*
* @return bool true, if succesful, else returns false
*/
bool acil_encode_cmd(uint8_t *buffer, aci_cmd_t *p_aci_cmd);
/** @brief Encode the ACI message for Broadcast command
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] p_aci_cmd Pointer to ACI command data in ::aci_cmd_params_broadcast_t
*
* @return None
*/
void acil_encode_cmd_broadcast(uint8_t *buffer, aci_cmd_params_broadcast_t * p_aci_cmd_params_broadcast);
/** @brief Encode the ACI message for Open Adv Pipes
*
* @param[in,out] buffer Pointer to ACI message buffer
* @param[in] p_aci_cmd Pointer to ACI command data in ::aci_cmd_params_open_adv_pipe_t
*
* @return None
*/
void acil_encode_cmd_open_adv_pipes(uint8_t *buffer, aci_cmd_params_open_adv_pipe_t * p_aci_cmd_params_set_adv_svc_data);
/** @brief Decode the ACI event command response
*
* @param[in] buffer_in Pointer to message received
* @param[in,out] buffer Pointer to the decoded message in ::aci_evt_params_cmd_rsp_t
*
* @return None
*/
void acil_decode_evt_command_response(uint8_t *buffer_in, aci_evt_params_cmd_rsp_t *p_evt_params_cmd_rsp);
/** @brief Decode the ACI event device started
*
* @param[in] buffer_in Pointer to message received
* @param[in,out] p_aci_evt Pointer to the decoded message in ::aci_evt_params_device_started_t
*
* @return None
*/
void acil_decode_evt_device_started(uint8_t *buffer_in, aci_evt_params_device_started_t *p_evt_params_device_started);
/** @brief Decode the ACI event pipe status
*
* @param[in] buffer_in Pointer to message received
* @param[in,out] p_aci_evt_params_pipe_status Pointer to the decoded message in ::aci_evt_params_pipe_status_t
*
* @return None
*/
void acil_decode_evt_pipe_status(uint8_t *buffer_in, aci_evt_params_pipe_status_t *p_aci_evt_params_pipe_status);
/** @brief Decode the ACI event for disconnected
*
* @param[in] buffer_in Pointer to message received
* @param[in,out] p_aci_evt_params_disconnected Pointer to the decoded message in ::aci_evt_params_disconnected_t
*
* @return None
*/
void acil_decode_evt_disconnected(uint8_t *buffer_in, aci_evt_params_disconnected_t *p_aci_evt_params_disconnected);
/** @brief Decode the ACI event for bond status
*
* @param[in] buffer_in Pointer to message received
* @param[in,out] p_aci_evt_params_bond_status Pointer to the decoded message in ::aci_evt_params_bond_status_t
*
* @return None
*/
void acil_decode_evt_bond_status(uint8_t *buffer_in, aci_evt_params_bond_status_t *p_aci_evt_params_bond_status);
/** @brief Decode the ACI event for data received
*
* @param[in] buffer_in Pointer to message received
* @param[in,out] p_evt_params_data_received Pointer to the decoded message in ::aci_evt_params_data_received_t
*
* @return size Received data size
*/
uint8_t acil_decode_evt_data_received(uint8_t *buffer_in, aci_evt_params_data_received_t *p_evt_params_data_received);
/** @brief Decode the ACI event data acknowledgement
*
* @param[in] buffer_in Pointer to message received
* @param[in,out] p_evt_params_data_ack Pointer to the decoded message in ::aci_evt_params_data_ack_t
*
* @return None
*/
void acil_decode_evt_data_ack(uint8_t *buffer_in, aci_evt_params_data_ack_t *p_evt_params_data_ack);
/** @brief Decode the ACI event for hardware error
*
* @param[in] buffer_in Pointer to message received
* @param[in,out] p_aci_evt_params_hw_error Pointer to the decoded message in ::aci_evt_params_hw_error_t
*
* @return size Size of debug information
*/
uint8_t acil_decode_evt_hw_error(uint8_t *buffer_in, aci_evt_params_hw_error_t *p_aci_evt_params_hw_error);
/** @brief Decode the ACI event data credit
*
* @param[in] buffer_in Pointer to message received
* @param[in,out] p_evt_params_data_credit Pointer to the decoded message in ::aci_evt_params_data_credit_t
*
* @return None
*/
void acil_decode_evt_credit(uint8_t *buffer_in, aci_evt_params_data_credit_t *p_evt_params_data_credit);
/** @brief Decode the ACI event for connected
*
* @param[in] buffer_in Pointer to message received
* @param[in,out] p_aci_evt_params_connected Pointer to the decoded message in ::aci_evt_params_connected_t
*
* @return None
*/
void acil_decode_evt_connected(uint8_t *buffer_in, aci_evt_params_connected_t *p_aci_evt_params_connected);
/** @brief Decode the ACI event for timing
*
* @param[in] buffer_in Pointer to message received
* @param[in,out] p_evt_params_timing Pointer to the decoded message in ::aci_evt_params_timing_t
*
* @return None
*/
void acil_decode_evt_timing(uint8_t *buffer_in, aci_evt_params_timing_t *p_evt_params_timing);
/** @brief Decode the ACI event for pipe error
*
* @param[in] buffer_in Pointer to message received
* @param[in,out] p_evt_params_pipe_error Pointer to the decoded message in ::aci_evt_params_pipe_error_t
*
*/
void acil_decode_evt_pipe_error(uint8_t *buffer_in, aci_evt_params_pipe_error_t *p_evt_params_pipe_error);
/** @brief Decode the ACI event for key request
*
* @param[in] buffer_in Pointer to message received
* @param[in,out] p_evt_params_key_type Pointer to the decoded message in ::aci_evt_params_key_type_t
*
* @return None
*/
void acil_decode_evt_key_request(uint8_t *buffer_in, aci_evt_params_key_request_t *p_evt_params_key_request);
/** @brief Decode the ACI event for echo
*
* @param[in] buffer_in Pointer to message received
* @param[in,out] buffer_out Pointer to the echo message (max size of buffer ::ACI_ECHO_DATA_MAX_LEN)
*
* @return size Received echo message size
*/
uint8_t acil_decode_evt_echo(uint8_t *buffer_in, aci_evt_params_echo_t *buffer_out);
/** @brief Decode the ACI event
*
* @param[in] buffer_in Pointer to message received
* @param[in,out] p_aci_evt Pointer to the decoded message in ::aci_evt_t
*
* @return bool true, if succesful, else returns false
*/
bool acil_decode_evt(uint8_t *buffer_in, aci_evt_t *p_aci_evt);
/** @brief Decode the Display Key Event
*
* @param[in] buffer_in Pointer to message received
* @param[in,out] p_aci_evt Pointer to the decoded message in ::aci_evt_params_display_passkey_t
*
* @return None
*/
void acil_decode_evt_display_passkey(uint8_t *buffer_in, aci_evt_params_display_passkey_t *p_aci_evt_params_display_passkey);
#endif /* _acilib_IF_H_ */

View File

@ -1,33 +1,33 @@
/* 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.
*/
/**
* @file
*
* @ingroup aci-lib
*
* @brief Type used in the acilib interfaces
*/
#ifndef _acilib_TYPES_H_
#define _acilib_TYPES_H_
#endif /* _acilib_TYPES_H_ */
/* 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.
*/
/**
* @file
*
* @ingroup aci-lib
*
* @brief Type used in the acilib interfaces
*/
#ifndef _acilib_TYPES_H_
#define _acilib_TYPES_H_
#endif /* _acilib_TYPES_H_ */

View File

@ -1,36 +1,36 @@
/* 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.
*/
/**
* @file
* @brief Defines for the different Bluetooth low energy boards
* @ingroup nrf8001
*/
#ifndef _BLE_BOARDS_H_
#define _BLE_BOARDS_H_
#define BOARD_DEFAULT 0 /**< Use this if you do not know the board you are using or you are creating a new one */
#define REDBEARLAB_SHIELD_V1_1 1 /**< Redbearlab Bluetooth low energy shield v1.1 */
#define REDBEARLAB_SHIELD_V2012_07 1 /**< Identical to Redbearlab v1.1 shield */
#define REDBEARLAB_SHIELD_V2 0 /**< Redbearlab Bluetooth low energy shield v2.x - No special handling required for pin reset same as default */
#endif
/* 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.
*/
/**
* @file
* @brief Defines for the different Bluetooth low energy boards
* @ingroup nrf8001
*/
#ifndef _BLE_BOARDS_H_
#define _BLE_BOARDS_H_
#define BOARD_DEFAULT 0 /**< Use this if you do not know the board you are using or you are creating a new one */
#define REDBEARLAB_SHIELD_V1_1 1 /**< Redbearlab Bluetooth low energy shield v1.1 */
#define REDBEARLAB_SHIELD_V2012_07 1 /**< Identical to Redbearlab v1.1 shield */
#define REDBEARLAB_SHIELD_V2 0 /**< Redbearlab Bluetooth low energy shield v2.x - No special handling required for pin reset same as default */
#endif

View File

@ -1,63 +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.
*/
/**
* @file
*
* @ingroup aci-lib
*
* @brief Internal prototype for acilib module.
*/
#ifndef DTM_H__
#define DTM_H__
/** @brief DTM command codes (upper two bits in the DTM command), use a bitwise OR with the frequency N = 0x00 - 0x27: N = (F-2402)/2 Frequency Range 2402 MHz
to 2480 MHz*/
#define DTM_LE_CMD_RESET 0x00 /**< DTM reset command code */
#define DTM_LE_CMD_RECEIVER_TEST 0x40 /**< DTM receiver test command code */
#define DTM_LE_CMD_TRANSMITTER_TEST 0x80 /**< DTM transmitter test command code */
#define DTM_LE_CMD_TEST_END 0xC0 /**< DTM test end command code */
/** @brief Defined packet types for DTM */
#define DTM_LE_PKT_PRBS9 0x00 /**< Bit pattern PRBS9. */
#define DTM_LE_PKT_0X0F 0x01 /**< Bit pattern 11110000 (LSB is the leftmost bit). */
#define DTM_LE_PKT_0X55 0x02 /**< Bit pattern 10101010 (LSB is the leftmost bit). */
#define DTM_LE_PKT_VENDOR 0x03 /**< Vendor specific. Nordic: continous carrier test */
/** @brief Defined bit fields for DTM responses. */
#define LE_PACKET_REPORTING_EVENT_MSB_BIT 0x80 /**< Bit field for most significant bit */
#define LE_TEST_STATUS_EVENT_LSB_BIT 0x01 /**< Bit field for least significant bit */
/** @brief DTM response types. */
#define LE_TEST_STATUS_EVENT 0x00 /**< DTM event response */
#define LE_TEST_PACKET_REPORT_EVENT 0x80 /**< DTM packet report reponse */
/** @brief DTM return values. */
#define LE_TEST_STATUS_SUCCESS 0x00 /**< DTM success return value */
#define LE_TEST_STATUS_FAILURE 0x01 /**< DTM failure return value */
#endif //DTM_H__
/** @} */
/* 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.
*/
/**
* @file
*
* @ingroup aci-lib
*
* @brief Internal prototype for acilib module.
*/
#ifndef DTM_H__
#define DTM_H__
/** @brief DTM command codes (upper two bits in the DTM command), use a bitwise OR with the frequency N = 0x00 - 0x27: N = (F-2402)/2 Frequency Range 2402 MHz
to 2480 MHz*/
#define DTM_LE_CMD_RESET 0x00 /**< DTM reset command code */
#define DTM_LE_CMD_RECEIVER_TEST 0x40 /**< DTM receiver test command code */
#define DTM_LE_CMD_TRANSMITTER_TEST 0x80 /**< DTM transmitter test command code */
#define DTM_LE_CMD_TEST_END 0xC0 /**< DTM test end command code */
/** @brief Defined packet types for DTM */
#define DTM_LE_PKT_PRBS9 0x00 /**< Bit pattern PRBS9. */
#define DTM_LE_PKT_0X0F 0x01 /**< Bit pattern 11110000 (LSB is the leftmost bit). */
#define DTM_LE_PKT_0X55 0x02 /**< Bit pattern 10101010 (LSB is the leftmost bit). */
#define DTM_LE_PKT_VENDOR 0x03 /**< Vendor specific. Nordic: continous carrier test */
/** @brief Defined bit fields for DTM responses. */
#define LE_PACKET_REPORTING_EVENT_MSB_BIT 0x80 /**< Bit field for most significant bit */
#define LE_TEST_STATUS_EVENT_LSB_BIT 0x01 /**< Bit field for least significant bit */
/** @brief DTM response types. */
#define LE_TEST_STATUS_EVENT 0x00 /**< DTM event response */
#define LE_TEST_PACKET_REPORT_EVENT 0x80 /**< DTM packet report reponse */
/** @brief DTM return values. */
#define LE_TEST_STATUS_SUCCESS 0x00 /**< DTM success return value */
#define LE_TEST_STATUS_FAILURE 0x01 /**< DTM failure return value */
#endif //DTM_H__
/** @} */

View File

@ -1,459 +1,459 @@
/* 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.
*/
/** @file
@brief Implementation of the ACI transport layer module
*/
#include <string>
#include <stdexcept>
#include <stdio.h>
#include "hal_platform.h"
#include "hal_aci_tl.h"
#include "aci_queue.h"
#define HIGH 1
#define LOW 0
#define REVERSE_BITS(byte) (((reverse_lookup[(byte & 0x0F)]) << 4) + reverse_lookup[((byte & 0xF0) >> 4)])
static const uint8_t reverse_lookup[] = { 0, 8, 4, 12, 2, 10, 6, 14,1, 9, 5, 13,3, 11, 7, 15 };
static void m_aci_data_print(hal_aci_data_t *p_data);
static void m_aci_event_check(void);
static void m_aci_isr(void);
static void m_aci_pins_set(aci_pins_t *a_pins_ptr);
static inline void m_aci_reqn_disable (void);
static inline void m_aci_reqn_enable (void);
static void m_aci_q_flush(void);
static bool m_aci_spi_transfer(hal_aci_data_t * data_to_send, hal_aci_data_t * received_data);
static uint8_t spi_readwrite(uint8_t aci_byte);
static bool aci_debug_print = false;
aci_queue_t aci_tx_q;
aci_queue_t aci_rx_q;
static aci_pins_t *a_pins_local_ptr;
void m_aci_data_print(hal_aci_data_t *p_data)
{
const uint8_t length = p_data->buffer[0];
uint8_t i;
printf("%d\n", length);
printf(" :\n");
for (i=0; i<=length; i++)
{
printf("%x", p_data->buffer[i]);
printf(", ");
}
printf("\n");
}
/*
Interrupt service routine called when the RDYN line goes low. Runs the SPI transfer.
*/
static void m_aci_isr(void)
{
hal_aci_data_t data_to_send;
hal_aci_data_t received_data;
// Receive from queue
if (!aci_queue_dequeue_from_isr(&aci_tx_q, &data_to_send))
{
/* queue was empty, nothing to send */
data_to_send.status_byte = 0;
data_to_send.buffer[0] = 0;
}
// Receive and/or transmit data
m_aci_spi_transfer(&data_to_send, &received_data);
if (!aci_queue_is_full_from_isr(&aci_rx_q) && !aci_queue_is_empty_from_isr(&aci_tx_q))
{
m_aci_reqn_enable();
}
// Check if we received data
if (received_data.buffer[0] > 0)
{
if (!aci_queue_enqueue_from_isr(&aci_rx_q, &received_data))
{
/* Receive Buffer full.
Should never happen.
Spin in a while loop.
*/
while(1);
}
// Disable ready line interrupt until we have room to store incoming messages
if (aci_queue_is_full_from_isr(&aci_rx_q))
{
// detachInterrupt(a_pins_local_ptr->interrupt_number);
}
}
return;
}
/*
Checks the RDYN line and runs the SPI transfer if required.
*/
static void m_aci_event_check(void)
{
hal_aci_data_t data_to_send;
hal_aci_data_t received_data;
// No room to store incoming messages
if (aci_queue_is_full(&aci_rx_q))
{
return;
}
// If the ready line is disabled and we have pending messages outgoing we enable the request line
if (HIGH == mraa_gpio_read (a_pins_local_ptr->m_rdy_ctx))
// if (HIGH == digitalRead(a_pins_local_ptr->rdyn_pin))
{
if (!aci_queue_is_empty(&aci_tx_q))
{
m_aci_reqn_enable();
}
return;
}
// Receive from queue
if (!aci_queue_dequeue(&aci_tx_q, &data_to_send))
{
/* queue was empty, nothing to send */
data_to_send.status_byte = 0;
data_to_send.buffer[0] = 0;
}
// Receive and/or transmit data
m_aci_spi_transfer(&data_to_send, &received_data);
/* If there are messages to transmit, and we can store the reply, we request a new transfer */
if (!aci_queue_is_full(&aci_rx_q) && !aci_queue_is_empty(&aci_tx_q))
{
m_aci_reqn_enable();
}
// Check if we received data
if (received_data.buffer[0] > 0)
{
if (!aci_queue_enqueue(&aci_rx_q, &received_data))
{
/* Receive Buffer full.
Should never happen.
Spin in a while loop.
*/
while(1);
}
}
return;
}
/** @brief Point the low level library at the ACI pins specified
* @details
* The ACI pins are specified in the application and a pointer is made available for
* the low level library to use
*/
static void m_aci_pins_set(aci_pins_t *a_pins_ptr)
{
a_pins_local_ptr = a_pins_ptr;
}
static inline void m_aci_reqn_disable (void)
{
mraa_gpio_write (a_pins_local_ptr->m_req_ctx, HIGH);
}
static inline void m_aci_reqn_enable (void)
{
mraa_gpio_write (a_pins_local_ptr->m_req_ctx, LOW);
}
static void m_aci_q_flush(void)
{
// noInterrupts();
/* re-initialize aci cmd queue and aci event queue to flush them*/
aci_queue_init(&aci_tx_q);
aci_queue_init(&aci_rx_q);
// interrupts();
}
static bool m_aci_spi_transfer(hal_aci_data_t * data_to_send, hal_aci_data_t * received_data)
{
uint8_t byte_cnt;
uint8_t byte_sent_cnt;
uint8_t max_bytes;
m_aci_reqn_enable();
// Send length, receive header
byte_sent_cnt = 0;
received_data->status_byte = spi_readwrite(data_to_send->buffer[byte_sent_cnt++]);
// Send first byte, receive length from slave
received_data->buffer[0] = spi_readwrite(data_to_send->buffer[byte_sent_cnt++]);
if (0 == data_to_send->buffer[0])
{
max_bytes = received_data->buffer[0];
}
else
{
// Set the maximum to the biggest size. One command byte is already sent
max_bytes = (received_data->buffer[0] > (data_to_send->buffer[0] - 1))
? received_data->buffer[0]
: (data_to_send->buffer[0] - 1);
}
if (max_bytes > HAL_ACI_MAX_LENGTH)
{
max_bytes = HAL_ACI_MAX_LENGTH;
}
// Transmit/receive the rest of the packet
for (byte_cnt = 0; byte_cnt < max_bytes; byte_cnt++)
{
received_data->buffer[byte_cnt+1] = spi_readwrite(data_to_send->buffer[byte_sent_cnt++]);
}
// RDYN should follow the REQN line in approx 100ns
m_aci_reqn_disable();
return (max_bytes > 0);
}
void hal_aci_tl_debug_print(bool enable)
{
aci_debug_print = enable;
}
void hal_aci_tl_pin_reset(void)
{
if (UNUSED != a_pins_local_ptr->reset_pin)
{
// pinMode(a_pins_local_ptr->reset_pin, OUTPUT);
if ((REDBEARLAB_SHIELD_V1_1 == a_pins_local_ptr->board_name) ||
(REDBEARLAB_SHIELD_V2012_07 == a_pins_local_ptr->board_name))
{
//The reset for the Redbearlab v1.1 and v2012.07 boards are inverted and has a Power On Reset
//circuit that takes about 100ms to trigger the reset
mraa_gpio_write (a_pins_local_ptr->m_rst_ctx, HIGH);
usleep (100000);
mraa_gpio_write (a_pins_local_ptr->m_rst_ctx, LOW);
}
else
{
mraa_gpio_write (a_pins_local_ptr->m_rst_ctx, HIGH);
mraa_gpio_write (a_pins_local_ptr->m_rst_ctx, LOW);
mraa_gpio_write (a_pins_local_ptr->m_rst_ctx, HIGH);
}
}
}
bool hal_aci_tl_event_peek(hal_aci_data_t *p_aci_data)
{
if (!a_pins_local_ptr->interface_is_interrupt)
{
m_aci_event_check();
}
if (aci_queue_peek(&aci_rx_q, p_aci_data))
{
return true;
}
return false;
}
bool hal_aci_tl_event_get(hal_aci_data_t *p_aci_data)
{
bool was_full;
if (!a_pins_local_ptr->interface_is_interrupt && !aci_queue_is_full(&aci_rx_q))
{
m_aci_event_check();
}
was_full = aci_queue_is_full(&aci_rx_q);
if (aci_queue_dequeue(&aci_rx_q, p_aci_data))
{
if (aci_debug_print)
{
printf(" E");
m_aci_data_print(p_aci_data);
}
if (was_full && a_pins_local_ptr->interface_is_interrupt)
{
/* Enable RDY line interrupt again */
// attachInterrupt(a_pins_local_ptr->interrupt_number, m_aci_isr, LOW);
}
/* Attempt to pull REQN LOW since we've made room for new messages */
if (!aci_queue_is_full(&aci_rx_q) && !aci_queue_is_empty(&aci_tx_q))
{
m_aci_reqn_enable();
}
return true;
}
return false;
}
void hal_aci_tl_init(aci_pins_t *a_pins, bool debug)
{
mraa_result_t error = MRAA_SUCCESS;
aci_debug_print = debug;
/* Needs to be called as the first thing for proper intialization*/
m_aci_pins_set(a_pins);
/*
* Init SPI
*/
a_pins->m_spi = mraa_spi_init (0);
if (a_pins->m_spi == NULL) {
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_spi_init() failed");
}
mraa_spi_frequency (a_pins->m_spi, 2000000);
mraa_spi_mode (a_pins->m_spi, MRAA_SPI_MODE0);
/* Initialize the ACI Command queue. This must be called after the delay above. */
aci_queue_init(&aci_tx_q);
aci_queue_init(&aci_rx_q);
// Configure the IO lines
a_pins->m_rdy_ctx = mraa_gpio_init (a_pins->rdyn_pin);
if (a_pins->m_rdy_ctx == NULL) {
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_gpio_init(rdyn) failed, invalid pin?");
}
a_pins->m_req_ctx = mraa_gpio_init (a_pins->reqn_pin);
if (a_pins->m_req_ctx == NULL) {
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_gpio_init(reqn) failed, invalid pin?");
}
a_pins->m_rst_ctx = mraa_gpio_init (a_pins->reset_pin);
if (a_pins->m_rst_ctx == NULL) {
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_gpio_init(reset) failed, invalid pin?");
}
error = mraa_gpio_dir (a_pins->m_rdy_ctx, MRAA_GPIO_IN);
if (error != MRAA_SUCCESS) {
printf ("[ERROR] GPIO failed to initialize \n");
}
error = mraa_gpio_dir (a_pins->m_req_ctx, MRAA_GPIO_OUT);
if (error != MRAA_SUCCESS) {
printf ("[ERROR] GPIO failed to initialize \n");
}
error = mraa_gpio_dir (a_pins->m_rst_ctx, MRAA_GPIO_OUT);
if (error != MRAA_SUCCESS) {
printf ("[ERROR] GPIO failed to initialize \n");
}
if (UNUSED != a_pins->active_pin) {
}
/* Pin reset the nRF8001, required when the nRF8001 setup is being changed */
hal_aci_tl_pin_reset();
/* Set the nRF8001 to a known state as required by the datasheet*/
mraa_gpio_write (a_pins->m_req_ctx, LOW);
usleep(30000); //Wait for the nRF8001 to get hold of its lines - the lines float for a few ms after the reset
/* Attach the interrupt to the RDYN line as requested by the caller */
if (a_pins->interface_is_interrupt) {
// We use the LOW level of the RDYN line as the atmega328 can wakeup from sleep only on LOW
// attachInterrupt(a_pins->interrupt_number, m_aci_isr, LOW);
}
}
bool hal_aci_tl_send(hal_aci_data_t *p_aci_cmd)
{
const uint8_t length = p_aci_cmd->buffer[0];
bool ret_val = false;
if (length > HAL_ACI_MAX_LENGTH)
{
return false;
}
ret_val = aci_queue_enqueue(&aci_tx_q, p_aci_cmd);
if (ret_val)
{
if(!aci_queue_is_full(&aci_rx_q))
{
// Lower the REQN only when successfully enqueued
m_aci_reqn_enable();
}
}
return ret_val;
}
static uint8_t spi_readwrite(const uint8_t aci_byte)
{
uint8_t reversed, ret;
reversed = mraa_spi_write (a_pins_local_ptr->m_spi, REVERSE_BITS (aci_byte));
ret = REVERSE_BITS (reversed);
return ret;
}
bool hal_aci_tl_rx_q_empty (void)
{
return aci_queue_is_empty(&aci_rx_q);
}
bool hal_aci_tl_rx_q_full (void)
{
return aci_queue_is_full(&aci_rx_q);
}
bool hal_aci_tl_tx_q_empty (void)
{
return aci_queue_is_empty(&aci_tx_q);
}
bool hal_aci_tl_tx_q_full (void)
{
return aci_queue_is_full(&aci_tx_q);
}
void hal_aci_tl_q_flush (void)
{
m_aci_q_flush();
}
/* 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.
*/
/** @file
@brief Implementation of the ACI transport layer module
*/
#include <string>
#include <stdexcept>
#include <stdio.h>
#include "hal_platform.h"
#include "hal_aci_tl.h"
#include "aci_queue.h"
#define HIGH 1
#define LOW 0
#define REVERSE_BITS(byte) (((reverse_lookup[(byte & 0x0F)]) << 4) + reverse_lookup[((byte & 0xF0) >> 4)])
static const uint8_t reverse_lookup[] = { 0, 8, 4, 12, 2, 10, 6, 14,1, 9, 5, 13,3, 11, 7, 15 };
static void m_aci_data_print(hal_aci_data_t *p_data);
static void m_aci_event_check(void);
static void m_aci_isr(void);
static void m_aci_pins_set(aci_pins_t *a_pins_ptr);
static inline void m_aci_reqn_disable (void);
static inline void m_aci_reqn_enable (void);
static void m_aci_q_flush(void);
static bool m_aci_spi_transfer(hal_aci_data_t * data_to_send, hal_aci_data_t * received_data);
static uint8_t spi_readwrite(uint8_t aci_byte);
static bool aci_debug_print = false;
aci_queue_t aci_tx_q;
aci_queue_t aci_rx_q;
static aci_pins_t *a_pins_local_ptr;
void m_aci_data_print(hal_aci_data_t *p_data)
{
const uint8_t length = p_data->buffer[0];
uint8_t i;
printf("%d\n", length);
printf(" :\n");
for (i=0; i<=length; i++)
{
printf("%x", p_data->buffer[i]);
printf(", ");
}
printf("\n");
}
/*
Interrupt service routine called when the RDYN line goes low. Runs the SPI transfer.
*/
static void m_aci_isr(void)
{
hal_aci_data_t data_to_send;
hal_aci_data_t received_data;
// Receive from queue
if (!aci_queue_dequeue_from_isr(&aci_tx_q, &data_to_send))
{
/* queue was empty, nothing to send */
data_to_send.status_byte = 0;
data_to_send.buffer[0] = 0;
}
// Receive and/or transmit data
m_aci_spi_transfer(&data_to_send, &received_data);
if (!aci_queue_is_full_from_isr(&aci_rx_q) && !aci_queue_is_empty_from_isr(&aci_tx_q))
{
m_aci_reqn_enable();
}
// Check if we received data
if (received_data.buffer[0] > 0)
{
if (!aci_queue_enqueue_from_isr(&aci_rx_q, &received_data))
{
/* Receive Buffer full.
Should never happen.
Spin in a while loop.
*/
while(1);
}
// Disable ready line interrupt until we have room to store incoming messages
if (aci_queue_is_full_from_isr(&aci_rx_q))
{
// detachInterrupt(a_pins_local_ptr->interrupt_number);
}
}
return;
}
/*
Checks the RDYN line and runs the SPI transfer if required.
*/
static void m_aci_event_check(void)
{
hal_aci_data_t data_to_send;
hal_aci_data_t received_data;
// No room to store incoming messages
if (aci_queue_is_full(&aci_rx_q))
{
return;
}
// If the ready line is disabled and we have pending messages outgoing we enable the request line
if (HIGH == mraa_gpio_read (a_pins_local_ptr->m_rdy_ctx))
// if (HIGH == digitalRead(a_pins_local_ptr->rdyn_pin))
{
if (!aci_queue_is_empty(&aci_tx_q))
{
m_aci_reqn_enable();
}
return;
}
// Receive from queue
if (!aci_queue_dequeue(&aci_tx_q, &data_to_send))
{
/* queue was empty, nothing to send */
data_to_send.status_byte = 0;
data_to_send.buffer[0] = 0;
}
// Receive and/or transmit data
m_aci_spi_transfer(&data_to_send, &received_data);
/* If there are messages to transmit, and we can store the reply, we request a new transfer */
if (!aci_queue_is_full(&aci_rx_q) && !aci_queue_is_empty(&aci_tx_q))
{
m_aci_reqn_enable();
}
// Check if we received data
if (received_data.buffer[0] > 0)
{
if (!aci_queue_enqueue(&aci_rx_q, &received_data))
{
/* Receive Buffer full.
Should never happen.
Spin in a while loop.
*/
while(1);
}
}
return;
}
/** @brief Point the low level library at the ACI pins specified
* @details
* The ACI pins are specified in the application and a pointer is made available for
* the low level library to use
*/
static void m_aci_pins_set(aci_pins_t *a_pins_ptr)
{
a_pins_local_ptr = a_pins_ptr;
}
static inline void m_aci_reqn_disable (void)
{
mraa_gpio_write (a_pins_local_ptr->m_req_ctx, HIGH);
}
static inline void m_aci_reqn_enable (void)
{
mraa_gpio_write (a_pins_local_ptr->m_req_ctx, LOW);
}
static void m_aci_q_flush(void)
{
// noInterrupts();
/* re-initialize aci cmd queue and aci event queue to flush them*/
aci_queue_init(&aci_tx_q);
aci_queue_init(&aci_rx_q);
// interrupts();
}
static bool m_aci_spi_transfer(hal_aci_data_t * data_to_send, hal_aci_data_t * received_data)
{
uint8_t byte_cnt;
uint8_t byte_sent_cnt;
uint8_t max_bytes;
m_aci_reqn_enable();
// Send length, receive header
byte_sent_cnt = 0;
received_data->status_byte = spi_readwrite(data_to_send->buffer[byte_sent_cnt++]);
// Send first byte, receive length from slave
received_data->buffer[0] = spi_readwrite(data_to_send->buffer[byte_sent_cnt++]);
if (0 == data_to_send->buffer[0])
{
max_bytes = received_data->buffer[0];
}
else
{
// Set the maximum to the biggest size. One command byte is already sent
max_bytes = (received_data->buffer[0] > (data_to_send->buffer[0] - 1))
? received_data->buffer[0]
: (data_to_send->buffer[0] - 1);
}
if (max_bytes > HAL_ACI_MAX_LENGTH)
{
max_bytes = HAL_ACI_MAX_LENGTH;
}
// Transmit/receive the rest of the packet
for (byte_cnt = 0; byte_cnt < max_bytes; byte_cnt++)
{
received_data->buffer[byte_cnt+1] = spi_readwrite(data_to_send->buffer[byte_sent_cnt++]);
}
// RDYN should follow the REQN line in approx 100ns
m_aci_reqn_disable();
return (max_bytes > 0);
}
void hal_aci_tl_debug_print(bool enable)
{
aci_debug_print = enable;
}
void hal_aci_tl_pin_reset(void)
{
if (UNUSED != a_pins_local_ptr->reset_pin)
{
// pinMode(a_pins_local_ptr->reset_pin, OUTPUT);
if ((REDBEARLAB_SHIELD_V1_1 == a_pins_local_ptr->board_name) ||
(REDBEARLAB_SHIELD_V2012_07 == a_pins_local_ptr->board_name))
{
//The reset for the Redbearlab v1.1 and v2012.07 boards are inverted and has a Power On Reset
//circuit that takes about 100ms to trigger the reset
mraa_gpio_write (a_pins_local_ptr->m_rst_ctx, HIGH);
usleep (100000);
mraa_gpio_write (a_pins_local_ptr->m_rst_ctx, LOW);
}
else
{
mraa_gpio_write (a_pins_local_ptr->m_rst_ctx, HIGH);
mraa_gpio_write (a_pins_local_ptr->m_rst_ctx, LOW);
mraa_gpio_write (a_pins_local_ptr->m_rst_ctx, HIGH);
}
}
}
bool hal_aci_tl_event_peek(hal_aci_data_t *p_aci_data)
{
if (!a_pins_local_ptr->interface_is_interrupt)
{
m_aci_event_check();
}
if (aci_queue_peek(&aci_rx_q, p_aci_data))
{
return true;
}
return false;
}
bool hal_aci_tl_event_get(hal_aci_data_t *p_aci_data)
{
bool was_full;
if (!a_pins_local_ptr->interface_is_interrupt && !aci_queue_is_full(&aci_rx_q))
{
m_aci_event_check();
}
was_full = aci_queue_is_full(&aci_rx_q);
if (aci_queue_dequeue(&aci_rx_q, p_aci_data))
{
if (aci_debug_print)
{
printf(" E");
m_aci_data_print(p_aci_data);
}
if (was_full && a_pins_local_ptr->interface_is_interrupt)
{
/* Enable RDY line interrupt again */
// attachInterrupt(a_pins_local_ptr->interrupt_number, m_aci_isr, LOW);
}
/* Attempt to pull REQN LOW since we've made room for new messages */
if (!aci_queue_is_full(&aci_rx_q) && !aci_queue_is_empty(&aci_tx_q))
{
m_aci_reqn_enable();
}
return true;
}
return false;
}
void hal_aci_tl_init(aci_pins_t *a_pins, bool debug)
{
mraa_result_t error = MRAA_SUCCESS;
aci_debug_print = debug;
/* Needs to be called as the first thing for proper intialization*/
m_aci_pins_set(a_pins);
/*
* Init SPI
*/
a_pins->m_spi = mraa_spi_init (0);
if (a_pins->m_spi == NULL) {
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_spi_init() failed");
}
mraa_spi_frequency (a_pins->m_spi, 2000000);
mraa_spi_mode (a_pins->m_spi, MRAA_SPI_MODE0);
/* Initialize the ACI Command queue. This must be called after the delay above. */
aci_queue_init(&aci_tx_q);
aci_queue_init(&aci_rx_q);
// Configure the IO lines
a_pins->m_rdy_ctx = mraa_gpio_init (a_pins->rdyn_pin);
if (a_pins->m_rdy_ctx == NULL) {
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_gpio_init(rdyn) failed, invalid pin?");
}
a_pins->m_req_ctx = mraa_gpio_init (a_pins->reqn_pin);
if (a_pins->m_req_ctx == NULL) {
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_gpio_init(reqn) failed, invalid pin?");
}
a_pins->m_rst_ctx = mraa_gpio_init (a_pins->reset_pin);
if (a_pins->m_rst_ctx == NULL) {
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_gpio_init(reset) failed, invalid pin?");
}
error = mraa_gpio_dir (a_pins->m_rdy_ctx, MRAA_GPIO_IN);
if (error != MRAA_SUCCESS) {
printf ("[ERROR] GPIO failed to initialize \n");
}
error = mraa_gpio_dir (a_pins->m_req_ctx, MRAA_GPIO_OUT);
if (error != MRAA_SUCCESS) {
printf ("[ERROR] GPIO failed to initialize \n");
}
error = mraa_gpio_dir (a_pins->m_rst_ctx, MRAA_GPIO_OUT);
if (error != MRAA_SUCCESS) {
printf ("[ERROR] GPIO failed to initialize \n");
}
if (UNUSED != a_pins->active_pin) {
}
/* Pin reset the nRF8001, required when the nRF8001 setup is being changed */
hal_aci_tl_pin_reset();
/* Set the nRF8001 to a known state as required by the datasheet*/
mraa_gpio_write (a_pins->m_req_ctx, LOW);
usleep(30000); //Wait for the nRF8001 to get hold of its lines - the lines float for a few ms after the reset
/* Attach the interrupt to the RDYN line as requested by the caller */
if (a_pins->interface_is_interrupt) {
// We use the LOW level of the RDYN line as the atmega328 can wakeup from sleep only on LOW
// attachInterrupt(a_pins->interrupt_number, m_aci_isr, LOW);
}
}
bool hal_aci_tl_send(hal_aci_data_t *p_aci_cmd)
{
const uint8_t length = p_aci_cmd->buffer[0];
bool ret_val = false;
if (length > HAL_ACI_MAX_LENGTH)
{
return false;
}
ret_val = aci_queue_enqueue(&aci_tx_q, p_aci_cmd);
if (ret_val)
{
if(!aci_queue_is_full(&aci_rx_q))
{
// Lower the REQN only when successfully enqueued
m_aci_reqn_enable();
}
}
return ret_val;
}
static uint8_t spi_readwrite(const uint8_t aci_byte)
{
uint8_t reversed, ret;
reversed = mraa_spi_write (a_pins_local_ptr->m_spi, REVERSE_BITS (aci_byte));
ret = REVERSE_BITS (reversed);
return ret;
}
bool hal_aci_tl_rx_q_empty (void)
{
return aci_queue_is_empty(&aci_rx_q);
}
bool hal_aci_tl_rx_q_full (void)
{
return aci_queue_is_full(&aci_rx_q);
}
bool hal_aci_tl_tx_q_empty (void)
{
return aci_queue_is_empty(&aci_tx_q);
}
bool hal_aci_tl_tx_q_full (void)
{
return aci_queue_is_full(&aci_tx_q);
}
void hal_aci_tl_q_flush (void)
{
m_aci_q_flush();
}

View File

@ -1,189 +1,189 @@
/* 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.
*/
/**
* @file
* @brief Interface for hal_aci_tl.
* @ingroup nrf8001
*/
/**
@{
@brief Module for the ACI Transport Layer interface
@details This module is responsible for sending and receiving messages over the ACI interface of the nRF8001 chip.
The hal_aci_tl_send_cmd() can be called directly to send ACI commands.
The RDYN line is hooked to an interrupt on the MCU when the level is low.
The SPI master clocks in the interrupt context.
The ACI Command is taken from the head of the command queue is sent over the SPI
and the received ACI event is placed in the tail of the event queue.
*/
#ifndef HAL_ACI_TL_H__
#define HAL_ACI_TL_H__
#include "hal_platform.h"
#include "aci.h"
#include "boards.h"
#include <mraa/aio.h>
#include <mraa/gpio.h>
#include <mraa/spi.h>
#ifndef HAL_ACI_MAX_LENGTH
#define HAL_ACI_MAX_LENGTH 31
#endif
/************************************************************************/
/* Unused nRF8001 pin */
/************************************************************************/
#define UNUSED 255
/** Data type for ACI commands and events */
typedef struct {
uint8_t status_byte;
uint8_t buffer[HAL_ACI_MAX_LENGTH+1];
} _aci_packed_ hal_aci_data_t;
ACI_ASSERT_SIZE(hal_aci_data_t, HAL_ACI_MAX_LENGTH + 2);
/** Datatype for ACI pins and interface (polling/interrupt)*/
typedef struct aci_pins_t
{
mraa_spi_context m_spi;
mraa_gpio_context m_rdy_ctx;
mraa_gpio_context m_req_ctx;
mraa_gpio_context m_rst_ctx;
uint8_t board_name; //Optional : Use BOARD_DEFAULT if you do not know. See boards.h
uint8_t reqn_pin; //Required
uint8_t rdyn_pin; //Required
uint8_t mosi_pin; //Required
uint8_t miso_pin; //Required
uint8_t sck_pin; //Required
uint8_t spi_clock_divider; //Required : Clock divider on the SPI clock : nRF8001 supports a maximum clock of 3MHz
uint8_t reset_pin; //Recommended but optional - Set it to UNUSED when not connected
uint8_t active_pin; //Optional - Set it to UNUSED when not connected
uint8_t optional_chip_sel_pin; //Optional - Used only when the reqn line is required to be separate from the SPI chip select. Eg. Arduino DUE
bool interface_is_interrupt; //Required - true = Uses interrupt on RDYN pin. false - Uses polling on RDYN pin
uint8_t interrupt_number; //Required when using interrupts, otherwise ignored
} aci_pins_t;
/** @brief ACI Transport Layer initialization.
* @details
* This function initializes the transport layer, including configuring the SPI, creating
* message queues for Commands and Events and setting up interrupt if required.
* @param a_pins Pins on the MCU used to connect to the nRF8001
* @param bool True if debug printing should be enabled on the Serial.
*/
void hal_aci_tl_init(aci_pins_t *a_pins, bool debug);
/** @brief Sends an ACI command to the radio.
* @details
* This function sends an ACI command to the radio. This queue up the message to send and
* lower the request line. When the device lowers the ready line, @ref m_aci_spi_transfer()
* will send the data.
* @param aci_buffer Pointer to the message to send.
* @return True if the data was successfully queued for sending,
* false if there is no more space to store messages to send.
*/
bool hal_aci_tl_send(hal_aci_data_t *aci_buffer);
/** @brief Process pending transactions.
* @details
* The library code takes care of calling this function to check if the nRF8001 RDYN line indicates a
* pending transaction. It will send a pending message if there is one and return any receive message
* that was pending.
* @return Points to data buffer for received data. Length byte in buffer is 0 if no data received.
*/
hal_aci_data_t * hal_aci_tl_poll_get(void);
/** @brief Get an ACI event from the event queue
* @details
* Call this function from the main context to get an event from the ACI event queue
* This is called by lib_aci_event_get
*/
bool hal_aci_tl_event_get(hal_aci_data_t *p_aci_data);
/** @brief Peek an ACI event from the event queue
* @details
* Call this function from the main context to peek an event from the ACI event queue.
* This is called by lib_aci_event_peek
*/
bool hal_aci_tl_event_peek(hal_aci_data_t *p_aci_data);
/** @brief Enable debug printing of all ACI commands sent and ACI events received
* @details
* when the enable parameter is true. The debug printing is enabled on the Serial.
* When the enable parameter is false. The debug printing is disabled on the Serial.
* By default the debug printing is disabled.
*/
void hal_aci_tl_debug_print(bool enable);
/** @brief Pin reset the nRF8001
* @details
* The reset line of the nF8001 needs to kept low for 200 ns.
* Redbearlab shield v1.1 and v2012.07 are exceptions as they
* have a Power ON Reset circuit that works differently.
* The function handles the exceptions based on the board_name in aci_pins_t
*/
void hal_aci_tl_pin_reset(void);
/** @brief Return full status of transmit queue
* @details
*
*/
bool hal_aci_tl_rx_q_full(void);
/** @brief Return empty status of receive queue
* @details
*
*/
bool hal_aci_tl_rx_q_empty(void);
/** @brief Return full status of receive queue
* @details
*
*/
bool hal_aci_tl_tx_q_full(void);
/** @brief Return empty status of transmit queue
* @details
*
*/
bool hal_aci_tl_tx_q_empty(void);
/** @brief Flush the ACI command Queue and the ACI Event Queue
* @details
* Call this function in the main thread
*/
void hal_aci_tl_q_flush(void);
#endif // HAL_ACI_TL_H__
/** @} */
/* 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.
*/
/**
* @file
* @brief Interface for hal_aci_tl.
* @ingroup nrf8001
*/
/**
@{
@brief Module for the ACI Transport Layer interface
@details This module is responsible for sending and receiving messages over the ACI interface of the nRF8001 chip.
The hal_aci_tl_send_cmd() can be called directly to send ACI commands.
The RDYN line is hooked to an interrupt on the MCU when the level is low.
The SPI master clocks in the interrupt context.
The ACI Command is taken from the head of the command queue is sent over the SPI
and the received ACI event is placed in the tail of the event queue.
*/
#ifndef HAL_ACI_TL_H__
#define HAL_ACI_TL_H__
#include "hal_platform.h"
#include "aci.h"
#include "boards.h"
#include <mraa/aio.h>
#include <mraa/gpio.h>
#include <mraa/spi.h>
#ifndef HAL_ACI_MAX_LENGTH
#define HAL_ACI_MAX_LENGTH 31
#endif
/************************************************************************/
/* Unused nRF8001 pin */
/************************************************************************/
#define UNUSED 255
/** Data type for ACI commands and events */
typedef struct {
uint8_t status_byte;
uint8_t buffer[HAL_ACI_MAX_LENGTH+1];
} _aci_packed_ hal_aci_data_t;
ACI_ASSERT_SIZE(hal_aci_data_t, HAL_ACI_MAX_LENGTH + 2);
/** Datatype for ACI pins and interface (polling/interrupt)*/
typedef struct aci_pins_t
{
mraa_spi_context m_spi;
mraa_gpio_context m_rdy_ctx;
mraa_gpio_context m_req_ctx;
mraa_gpio_context m_rst_ctx;
uint8_t board_name; //Optional : Use BOARD_DEFAULT if you do not know. See boards.h
uint8_t reqn_pin; //Required
uint8_t rdyn_pin; //Required
uint8_t mosi_pin; //Required
uint8_t miso_pin; //Required
uint8_t sck_pin; //Required
uint8_t spi_clock_divider; //Required : Clock divider on the SPI clock : nRF8001 supports a maximum clock of 3MHz
uint8_t reset_pin; //Recommended but optional - Set it to UNUSED when not connected
uint8_t active_pin; //Optional - Set it to UNUSED when not connected
uint8_t optional_chip_sel_pin; //Optional - Used only when the reqn line is required to be separate from the SPI chip select. Eg. Arduino DUE
bool interface_is_interrupt; //Required - true = Uses interrupt on RDYN pin. false - Uses polling on RDYN pin
uint8_t interrupt_number; //Required when using interrupts, otherwise ignored
} aci_pins_t;
/** @brief ACI Transport Layer initialization.
* @details
* This function initializes the transport layer, including configuring the SPI, creating
* message queues for Commands and Events and setting up interrupt if required.
* @param a_pins Pins on the MCU used to connect to the nRF8001
* @param bool True if debug printing should be enabled on the Serial.
*/
void hal_aci_tl_init(aci_pins_t *a_pins, bool debug);
/** @brief Sends an ACI command to the radio.
* @details
* This function sends an ACI command to the radio. This queue up the message to send and
* lower the request line. When the device lowers the ready line, @ref m_aci_spi_transfer()
* will send the data.
* @param aci_buffer Pointer to the message to send.
* @return True if the data was successfully queued for sending,
* false if there is no more space to store messages to send.
*/
bool hal_aci_tl_send(hal_aci_data_t *aci_buffer);
/** @brief Process pending transactions.
* @details
* The library code takes care of calling this function to check if the nRF8001 RDYN line indicates a
* pending transaction. It will send a pending message if there is one and return any receive message
* that was pending.
* @return Points to data buffer for received data. Length byte in buffer is 0 if no data received.
*/
hal_aci_data_t * hal_aci_tl_poll_get(void);
/** @brief Get an ACI event from the event queue
* @details
* Call this function from the main context to get an event from the ACI event queue
* This is called by lib_aci_event_get
*/
bool hal_aci_tl_event_get(hal_aci_data_t *p_aci_data);
/** @brief Peek an ACI event from the event queue
* @details
* Call this function from the main context to peek an event from the ACI event queue.
* This is called by lib_aci_event_peek
*/
bool hal_aci_tl_event_peek(hal_aci_data_t *p_aci_data);
/** @brief Enable debug printing of all ACI commands sent and ACI events received
* @details
* when the enable parameter is true. The debug printing is enabled on the Serial.
* When the enable parameter is false. The debug printing is disabled on the Serial.
* By default the debug printing is disabled.
*/
void hal_aci_tl_debug_print(bool enable);
/** @brief Pin reset the nRF8001
* @details
* The reset line of the nF8001 needs to kept low for 200 ns.
* Redbearlab shield v1.1 and v2012.07 are exceptions as they
* have a Power ON Reset circuit that works differently.
* The function handles the exceptions based on the board_name in aci_pins_t
*/
void hal_aci_tl_pin_reset(void);
/** @brief Return full status of transmit queue
* @details
*
*/
bool hal_aci_tl_rx_q_full(void);
/** @brief Return empty status of receive queue
* @details
*
*/
bool hal_aci_tl_rx_q_empty(void);
/** @brief Return full status of receive queue
* @details
*
*/
bool hal_aci_tl_tx_q_full(void);
/** @brief Return empty status of transmit queue
* @details
*
*/
bool hal_aci_tl_tx_q_empty(void);
/** @brief Flush the ACI command Queue and the ACI Event Queue
* @details
* Call this function in the main thread
*/
void hal_aci_tl_q_flush(void);
#endif // HAL_ACI_TL_H__
/** @} */

View File

@ -1,78 +1,78 @@
/* 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.
*/
/**
* @file
* @brief HAL specific macros
* @ingroup nrf8001
*/
#ifndef PLATFORM_H__
#define PLATFORM_H__
//Board dependent defines
#if defined (__AVR__)
//For Arduino this AVR specific library has to be used for reading from Flash memory
#include <avr/pgmspace.h>
#include "Arduino.h"
#ifdef PROGMEM
#undef PROGMEM
#define PROGMEM __attribute__(( section(".progmem.data") ))
#endif
#elif defined(__PIC32MX__)
//For Chipkit add the following libraries.
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <wiring.h>
#include <WProgram.h>
//For making the Serial.Print compatible between Arduino and Chipkit
#define F(X) (X)
//For ChipKit neither PROGMEM or PSTR are needed for PIC32
#define PROGMEM
#define PSTR(s) (s)
#define pgm_read_byte(x) (*((char *)x))
#define pgm_read_byte_near(x) (*((char *)x))
#define pgm_read_byte_far(x) (*((char *)x))
#define pgm_read_word(x) (*((short *)x))
#define pgm_read_word_near(x) (*((short *)x))
#define pgm_read_workd_far(x) (*((short *)x))
#define prog_void const void
#define prog_char const char
#define prog_uchar const unsigned char
#define prog_int8_t const int8_t
#define prog_uint8_t const uint8_t
#define prog_int16_t const int16_t
#define prog_uint16_t const uint16_t
#define prog_int32_t const int32_t
#define prog_uint32_t const uint32_t
#define prog_int64_t const int64_t
#define prog_uint64_t const uint64_t
//Redefine the function for reading from flash in ChipKit
#define memcpy_P memcpy
#endif
#endif /* PLATFORM_H__ */
/* 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.
*/
/**
* @file
* @brief HAL specific macros
* @ingroup nrf8001
*/
#ifndef PLATFORM_H__
#define PLATFORM_H__
//Board dependent defines
#if defined (__AVR__)
//For Arduino this AVR specific library has to be used for reading from Flash memory
#include <avr/pgmspace.h>
#include "Arduino.h"
#ifdef PROGMEM
#undef PROGMEM
#define PROGMEM __attribute__(( section(".progmem.data") ))
#endif
#elif defined(__PIC32MX__)
//For Chipkit add the following libraries.
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <wiring.h>
#include <WProgram.h>
//For making the Serial.Print compatible between Arduino and Chipkit
#define F(X) (X)
//For ChipKit neither PROGMEM or PSTR are needed for PIC32
#define PROGMEM
#define PSTR(s) (s)
#define pgm_read_byte(x) (*((char *)x))
#define pgm_read_byte_near(x) (*((char *)x))
#define pgm_read_byte_far(x) (*((char *)x))
#define pgm_read_word(x) (*((short *)x))
#define pgm_read_word_near(x) (*((short *)x))
#define pgm_read_workd_far(x) (*((short *)x))
#define prog_void const void
#define prog_char const char
#define prog_uchar const unsigned char
#define prog_int8_t const int8_t
#define prog_uint8_t const uint8_t
#define prog_int16_t const int16_t
#define prog_uint16_t const uint16_t
#define prog_int32_t const int32_t
#define prog_uint32_t const uint32_t
#define prog_int64_t const int64_t
#define prog_uint64_t const uint64_t
//Redefine the function for reading from flash in ChipKit
#define memcpy_P memcpy
#endif
#endif /* PLATFORM_H__ */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,79 +1,79 @@
/* 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.
*
* 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.
*
* 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.
*/
/**
* @file
* @brief BLE specific macros
* @ingroup nrf8001
*/
#ifndef UART_OVER_BLE_H__
#define UART_OVER_BLE_H__
/**
* @def UART_OVER_BLE_DISCONNECT
* @brief
* Command to queue a ACI Disconnect to the nRF8001
*/
#define UART_OVER_BLE_DISCONNECT (0x01)
/**
* @def UART_OVER_BLE_LINK_TIMING_REQ
* @brief
* Command to queue a ACI Change Timing to the nRF8001
*/
#define UART_OVER_BLE_LINK_TIMING_REQ (0x02)
/**
* @def UART_OVER_BLE_TRANSMIT_STOP
* @brief
* Command to stop sending UART over BLE packets
*/
#define UART_OVER_BLE_TRANSMIT_STOP (0x03)
/**
* @def UART_OVER_BLE_TRANSMIT_OK
* @brief
* Command to allow sending UART over BLE packets
*/
#define UART_OVER_BLE_TRANSMIT_OK (0x04)
/**
* @struct uart_over_ble_t
* @brief State of the UART RTS over Bluetooth Low Energy(BLE)
*/
typedef struct
{
uint8_t uart_rts_local; /**< State of the local UART RTS */
uint8_t uart_rts_remote; /**< State of the remote UART RTS */
} uart_over_ble_t;
#endif // UART_OVER_BLE_H__
/* 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.
*
* 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.
*
* 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.
*/
/**
* @file
* @brief BLE specific macros
* @ingroup nrf8001
*/
#ifndef UART_OVER_BLE_H__
#define UART_OVER_BLE_H__
/**
* @def UART_OVER_BLE_DISCONNECT
* @brief
* Command to queue a ACI Disconnect to the nRF8001
*/
#define UART_OVER_BLE_DISCONNECT (0x01)
/**
* @def UART_OVER_BLE_LINK_TIMING_REQ
* @brief
* Command to queue a ACI Change Timing to the nRF8001
*/
#define UART_OVER_BLE_LINK_TIMING_REQ (0x02)
/**
* @def UART_OVER_BLE_TRANSMIT_STOP
* @brief
* Command to stop sending UART over BLE packets
*/
#define UART_OVER_BLE_TRANSMIT_STOP (0x03)
/**
* @def UART_OVER_BLE_TRANSMIT_OK
* @brief
* Command to allow sending UART over BLE packets
*/
#define UART_OVER_BLE_TRANSMIT_OK (0x04)
/**
* @struct uart_over_ble_t
* @brief State of the UART RTS over Bluetooth Low Energy(BLE)
*/
typedef struct
{
uint8_t uart_rts_local; /**< State of the local UART RTS */
uint8_t uart_rts_remote; /**< State of the remote UART RTS */
} uart_over_ble_t;
#endif // UART_OVER_BLE_H__

View File

@ -83,7 +83,7 @@ namespace upm {
typedef enum {
FORMAT_VGA = 7, // 640x480
FORMAT_CIF = 5, // 352×288
FORMAT_CIF = 5, // 352*288
FORMAT_OCIF = 3 // ??? (maybe they meant QCIF?)
} PIC_FORMATS_T;

View File

@ -57,9 +57,9 @@ namespace upm {
* The TB7200 Series PI thermostats are designed for zoning
* applications, and the TB7300 Series PI thermostats are designed
* for fan coil control. Both Series are communicating thermostats
* with models available in BACnet® MS/TP protocol and can be easily
* with models available in BACnet(r) MS/TP protocol and can be easily
* integrated into a WEBs-AX building automation system based on the
* NiagaraAX® platform.
* NiagaraAX(r) platform.
*
* TB7200 and TB7300 Series thermostats are compatible with the
* Honeywell Occupancy Sensor Cover. Thermostats equipped with an

View File

@ -2,6 +2,13 @@ add_test (NAME check_consistency COMMAND ${PYTHON_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/check_consistency.py
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
# Check file encodings in src tree
if (PYTHON2INTERP_FOUND)
add_test (NAME check_file_encoding COMMAND ${PYTHON_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/check_file_encoding.py
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src)
endif (PYTHON2INTERP_FOUND)
if (BUILDSWIGJAVA)
add_test (NAME check_autoloadlibrary COMMAND ${PYTHON_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/check_autoloadlibrary.py

54
tests/check_file_encoding.py Executable file
View File

@ -0,0 +1,54 @@
#!/usr/bin/python
import unittest
import os
import chardet
target_exts = ['.h', '.hpp', '.hxx', '.txt']
valid_encodings = ['ascii', 'utf-8']
class EncodingTests(unittest.TestCase):
'''Non-ascii/utf-8 encodings can cause failures on downstream tools
such as documentation-generation and python2 module loading. This
class helps find those files which could cause an encoding problem'''
def test_headers_ascii(self):
'''Assert/print list of:
file:linenumber offending line
for all lines of matching files which are not in valid_encodings'''
# Keep a map of files with alternate encodes to report
invalid_files = {}
# Recusively search cwd for files with target_exts
for root, dirs, files in os.walk(os.curdir):
# Work on full paths
for file in files:
file = os.path.join(root, file)
# Skip any files not ending with target_exts
if not any(file.lower().endswith(x) for x in target_exts):
continue
# Check each with chardet
with open(file, 'r') as f:
for ndx, line in enumerate(f):
result = chardet.detect(line)
if not result['encoding'] in valid_encodings:
if not invalid_files.has_key(file):
invalid_files[file] = []
invalid_files[file].append([ndx,line])
# Sort the failures by filename
skeys = list(invalid_files.keys())
skeys.sort()
invalid_lines = ''
for fn in skeys:
for line in invalid_files[fn]:
invalid_lines += '%s:%d %s' % (fn, line[0], line[1])
self.assertEqual( len(invalid_files), 0,
"\nThe following modules have alternate encodings:\n" + \
invalid_lines)
if __name__ == '__main__':
unittest.main()