GapAdvertisingData::addFlags() should take a uint8_t bitmask instead of a 'Flags'

This commit is contained in:
Rohit Grover 2014-06-19 14:09:37 +01:00
parent f80ce69ccb
commit a0b9857682
2 changed files with 74 additions and 233 deletions

View file

@ -156,9 +156,9 @@ ble_error_t GapAdvertisingData::addAppearance(Appearance appearance)
\endcode
*/
/**************************************************************************/
ble_error_t GapAdvertisingData::addFlags(Flags flag)
ble_error_t GapAdvertisingData::addFlags(uint8_t flags)
{
return addData(GapAdvertisingData::FLAGS, (uint8_t *)&flag, 1);
return addData(GapAdvertisingData::FLAGS, &flags, 1);
}
/**************************************************************************/

View file

@ -85,76 +85,23 @@ public:
\li \c https://www.bluetooth.org/en-us/specification/assigned-numbers/generic-access-profile
*/
/**********************************************************************/
enum DataType
{
FLAGS = 0x01, /**< \ref
*Flags */
INCOMPLETE_LIST_16BIT_SERVICE_IDS = 0x02, /**<
*Incomplete
*list of
*16-bit
*Service IDs
**/
COMPLETE_LIST_16BIT_SERVICE_IDS = 0x03, /**< Complete
*list of
*16-bit
*Service IDs
**/
INCOMPLETE_LIST_32BIT_SERVICE_IDS = 0x04, /**<
*Incomplete
*list of
*32-bit
*Service IDs
*(not
*relevant for
*Bluetooth
*4.0) */
COMPLETE_LIST_32BIT_SERVICE_IDS = 0x05, /**< Complete
*list of
*32-bit
*Service IDs
*(not
*relevant for
*Bluetooth
*4.0) */
INCOMPLETE_LIST_128BIT_SERVICE_IDS = 0x06, /**<
*Incomplete
*list of
*128-bit
*Service IDs
**/
COMPLETE_LIST_128BIT_SERVICE_IDS = 0x07, /**< Complete
*list of
*128-bit
*Service IDs
**/
SHORTENED_LOCAL_NAME = 0x08, /**< Shortened
*Local Name
**/
COMPLETE_LOCAL_NAME = 0x09, /**< Complete
*Local Name
**/
TX_POWER_LEVEL = 0x0A, /**< TX Power
*Level (in
*dBm) */
DEVICE_ID = 0x10, /**< Device ID
**/
SLAVE_CONNECTION_INTERVAL_RANGE = 0x12, /**< Slave
*Connection
*Interval
*Range */
SERVICE_DATA = 0x16, /**< Service
*Data */
APPEARANCE = 0x19, /**< \ref
*Appearance
**/
ADVERTISING_INTERVAL = 0x1A, /**<
*Advertising
*Interval */
MANUFACTURER_SPECIFIC_DATA = 0xFF /**<
*Manufacturer
*Specific
*Data */
enum DataType {
FLAGS = 0x01, /**< \ref *Flags */
INCOMPLETE_LIST_16BIT_SERVICE_IDS = 0x02, /**< Incomplete list of 16-bit Service IDs */
COMPLETE_LIST_16BIT_SERVICE_IDS = 0x03, /**< Complete list of 16-bit Service IDs */
INCOMPLETE_LIST_32BIT_SERVICE_IDS = 0x04, /**< Incomplete list of 32-bit Service IDs (not relevant for Bluetooth 4.0) */
COMPLETE_LIST_32BIT_SERVICE_IDS = 0x05, /**< Complete list of 32-bit Service IDs (not relevant for Bluetooth 4.0) */
INCOMPLETE_LIST_128BIT_SERVICE_IDS = 0x06, /**< Incomplete list of 128-bit Service IDs */
COMPLETE_LIST_128BIT_SERVICE_IDS = 0x07, /**< Complete list of 128-bit Service IDs */
SHORTENED_LOCAL_NAME = 0x08, /**< Shortened Local Name */
COMPLETE_LOCAL_NAME = 0x09, /**< Complete Local Name */
TX_POWER_LEVEL = 0x0A, /**< TX Power Level (in dBm) */
DEVICE_ID = 0x10, /**< Device ID */
SLAVE_CONNECTION_INTERVAL_RANGE = 0x12, /**< Slave Connection Interval Range */
SERVICE_DATA = 0x16, /**< Service Data */
APPEARANCE = 0x19, /**< \ref Appearance */
ADVERTISING_INTERVAL = 0x1A, /**< Advertising Interval */
MANUFACTURER_SPECIFIC_DATA = 0xFF /**< Manufacturer Specific Data */
};
/**********************************************************************/
@ -170,34 +117,12 @@ public:
\li \c Bluetooth Core Specification 4.0 (Vol. 3), Part C, Section 18.1
*/
/**********************************************************************/
enum Flags
{
LE_LIMITED_DISCOVERABLE = 0x01, /**<
*Peripheral
*device is
*discoverable
*for a
*limited
*period of
*time */
LE_GENERAL_DISCOVERABLE = 0x02, /**<
*Peripheral
*device is
*discoverable
*at any
*moment */
BREDR_NOT_SUPPORTED = 0x04, /**<
*Peripheral
*device is LE
*only */
SIMULTANEOUS_LE_BREDR_C = 0x08, /**< Not
*relevant -
*central mode
*only */
SIMULTANEOUS_LE_BREDR_H = 0x10 /**< Not
*relevant -
*central mode
*only */
enum Flags {
LE_LIMITED_DISCOVERABLE = 0x01, /**< *Peripheral device is discoverable for a limited period of time */
LE_GENERAL_DISCOVERABLE = 0x02, /**< Peripheral device is discoverable at any moment */
BREDR_NOT_SUPPORTED = 0x04, /**< Peripheral device is LE only */
SIMULTANEOUS_LE_BREDR_C = 0x08, /**< Not relevant - central mode only */
SIMULTANEOUS_LE_BREDR_H = 0x10 /**< Not relevant - central mode only */
};
/**********************************************************************/
@ -212,139 +137,55 @@ public:
\li \c https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.gap.appearance.xml
*/
/**********************************************************************/
enum Appearance
{
UNKNOWN = 0, /**< Unknown
*of
*unspecified
*appearance
*type */
GENERIC_PHONE = 64, /**< Generic
*Phone */
GENERIC_COMPUTER = 128, /**< Generic
*Computer */
GENERIC_WATCH = 192, /**< Generic
*Watch */
WATCH_SPORTS_WATCH = 193, /**< Sports
*Watch */
GENERIC_CLOCK = 256, /**< Generic
*Clock */
GENERIC_DISPLAY = 320, /**< Generic
*Display */
GENERIC_REMOTE_CONTROL = 384, /**< Generic
*Remote
*Control */
GENERIC_EYE_GLASSES = 448, /**< Generic
*Eye Glasses
**/
GENERIC_TAG = 512, /**< Generic
*Tag */
GENERIC_KEYRING = 576, /**< Generic
*Keyring */
GENERIC_MEDIA_PLAYER = 640, /**< Generic
*Media Player
**/
GENERIC_BARCODE_SCANNER = 704, /**< Generic
*Barcode
*Scanner */
GENERIC_THERMOMETER = 768, /**< Generic
*Thermometer
**/
THERMOMETER_EAR = 769, /**< Ear
*Thermometer
**/
GENERIC_HEART_RATE_SENSOR = 832, /**< Generic
*Heart Rate
*Sensor */
HEART_RATE_SENSOR_HEART_RATE_BELT = 833, /**< Belt
*Heart Rate
*Sensor */
GENERIC_BLOOD_PRESSURE = 896, /**< Generic
*Blood
*Pressure */
BLOOD_PRESSURE_ARM = 897, /**< Arm Blood
*Pressure */
BLOOD_PRESSURE_WRIST = 898, /**< Wrist
*Blood
*Pressure */
HUMAN_INTERFACE_DEVICE_HID = 960, /**< Human
*Interface
*Device (HID)
**/
KEYBOARD = 961, /**< Keyboard
**/
enum Appearance {
UNKNOWN = 0, /**< Unknown of unspecified appearance type */
GENERIC_PHONE = 64, /**< Generic Phone */
GENERIC_COMPUTER = 128, /**< Generic Computer */
GENERIC_WATCH = 192, /**< Generic Watch */
WATCH_SPORTS_WATCH = 193, /**< Sports Watch */
GENERIC_CLOCK = 256, /**< Generic Clock */
GENERIC_DISPLAY = 320, /**< Generic Display */
GENERIC_REMOTE_CONTROL = 384, /**< Generic Remote Control */
GENERIC_EYE_GLASSES = 448, /**< Generic Eye Glasses */
GENERIC_TAG = 512, /**< Generic Tag */
GENERIC_KEYRING = 576, /**< Generic Keyring */
GENERIC_MEDIA_PLAYER = 640, /**< Generic Media Player */
GENERIC_BARCODE_SCANNER = 704, /**< Generic Barcode Scanner */
GENERIC_THERMOMETER = 768, /**< Generic Thermometer */
THERMOMETER_EAR = 769, /**< Ear Thermometer */
GENERIC_HEART_RATE_SENSOR = 832, /**< Generic Heart Rate Sensor */
HEART_RATE_SENSOR_HEART_RATE_BELT = 833, /**< Belt Heart Rate Sensor */
GENERIC_BLOOD_PRESSURE = 896, /**< Generic Blood Pressure */
BLOOD_PRESSURE_ARM = 897, /**< Arm Blood Pressure */
BLOOD_PRESSURE_WRIST = 898, /**< Wrist Blood Pressure */
HUMAN_INTERFACE_DEVICE_HID = 960, /**< Human Interface Device (HID) */
KEYBOARD = 961, /**< Keyboard */
MOUSE = 962, /**< Mouse */
JOYSTICK = 963, /**< Joystick
**/
GAMEPAD = 964, /**< Gamepad
**/
DIGITIZER_TABLET = 965, /**< Digitizer
*Tablet */
CARD_READER = 966, /**< Card Read
**/
DIGITAL_PEN = 967, /**< Digital
*Pen */
BARCODE_SCANNER = 968, /**< Barcode
*Scanner */
GENERIC_GLUCOSE_METER = 1024, /**< Generic
*Glucose
*Meter */
GENERIC_RUNNING_WALKING_SENSOR = 1088, /**< Generic
*Running/Walking
*Sensor */
RUNNING_WALKING_SENSOR_IN_SHOE = 1089, /**< In Shoe
*Running/Walking
*Sensor */
RUNNING_WALKING_SENSOR_ON_SHOE = 1090, /**< On Shoe
*Running/Walking
*Sensor */
RUNNING_WALKING_SENSOR_ON_HIP = 1091, /**< On Hip
*Running/Walking
*Sensor */
GENERIC_CYCLING = 1152, /**< Generic
*Cycling */
CYCLING_CYCLING_COMPUTER = 1153, /**< Cycling
*Computer */
CYCLING_SPEED_SENSOR = 1154, /**< Cycling
*Speed Senspr
**/
CYCLING_CADENCE_SENSOR = 1155, /**< Cycling
*Cadence
*Sensor */
CYCLING_POWER_SENSOR = 1156, /**< Cycling
*Power Sensor
**/
CYCLING_SPEED_AND_CADENCE_SENSOR = 1157, /**< Cycling
*Speed and
*Cadence
*Sensor */
PULSE_OXIMETER_GENERIC = 3136, /**< Generic
*Pulse
*Oximeter */
PULSE_OXIMETER_FINGERTIP = 3137, /**< Fingertip
*Pulse
*Oximeter */
PULSE_OXIMETER_WRIST_WORN = 3138, /**< Wrist
*Worn Pulse
*Oximeter */
OUTDOOR_GENERIC = 5184, /**< Generic
*Outdoor */
OUTDOOR_LOCATION_DISPLAY_DEVICE = 5185, /**< Outdoor
*Location
*Display
*Device */
OUTDOOR_LOCATION_AND_NAVIGATION_DISPLAY_DEVICE = 5186, /**< Outdoor
*Location and
*Navigation
*Display
*Device */
OUTDOOR_LOCATION_POD = 5187, /**< Outdoor
*Location Pod
**/
OUTDOOR_LOCATION_AND_NAVIGATION_POD = 5188 /**< Outdoor
*Location and
*Navigation
*Pod */
JOYSTICK = 963, /**< Joystick */
GAMEPAD = 964, /**< Gamepad */
DIGITIZER_TABLET = 965, /**< Digitizer Tablet */
CARD_READER = 966, /**< Card Read */
DIGITAL_PEN = 967, /**< Digital Pen */
BARCODE_SCANNER = 968, /**< Barcode Scanner */
GENERIC_GLUCOSE_METER = 1024, /**< Generic Glucose Meter */
GENERIC_RUNNING_WALKING_SENSOR = 1088, /**< Generic Running/Walking Sensor */
RUNNING_WALKING_SENSOR_IN_SHOE = 1089, /**< In Shoe Running/Walking Sensor */
RUNNING_WALKING_SENSOR_ON_SHOE = 1090, /**< On Shoe Running/Walking Sensor */
RUNNING_WALKING_SENSOR_ON_HIP = 1091, /**< On Hip Running/Walking Sensor */
GENERIC_CYCLING = 1152, /**< Generic Cycling */
CYCLING_CYCLING_COMPUTER = 1153, /**< Cycling Computer */
CYCLING_SPEED_SENSOR = 1154, /**< Cycling Speed Senspr */
CYCLING_CADENCE_SENSOR = 1155, /**< Cycling Cadence Sensor */
CYCLING_POWER_SENSOR = 1156, /**< Cycling Power Sensor */
CYCLING_SPEED_AND_CADENCE_SENSOR = 1157, /**< Cycling Speed and Cadence Sensor */
PULSE_OXIMETER_GENERIC = 3136, /**< Generic Pulse Oximeter */
PULSE_OXIMETER_FINGERTIP = 3137, /**< Fingertip Pulse Oximeter */
PULSE_OXIMETER_WRIST_WORN = 3138, /**< Wrist Worn Pulse Oximeter */
OUTDOOR_GENERIC = 5184, /**< Generic Outdoor */
OUTDOOR_LOCATION_DISPLAY_DEVICE = 5185, /**< Outdoor Location Display Device */
OUTDOOR_LOCATION_AND_NAVIGATION_DISPLAY_DEVICE = 5186, /**< Outdoor Location and Navigation Display Device */
OUTDOOR_LOCATION_POD = 5187, /**< Outdoor Location Pod */
OUTDOOR_LOCATION_AND_NAVIGATION_POD = 5188 /**< Outdoor Location and Navigation Pod */
};
GapAdvertisingData(void);
@ -352,7 +193,7 @@ public:
ble_error_t addData(DataType, const uint8_t *, uint8_t);
ble_error_t addAppearance(Appearance appearance = GENERIC_TAG);
ble_error_t addFlags(Flags flag = LE_GENERAL_DISCOVERABLE);
ble_error_t addFlags(uint8_t flags = LE_GENERAL_DISCOVERABLE);
ble_error_t addTxPower(int8_t txPower);
void clear(void);
const uint8_t *getPayload(void) const;