-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from asterics/newBLE
NewBLE branch merged. Before merging, the master branch was tagged with "PreMergeNewBLE".
- Loading branch information
Showing
96 changed files
with
20,220 additions
and
2,712 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* BLE2902.cpp | ||
* | ||
* Created on: Jun 25, 2017 | ||
* Author: kolban | ||
*/ | ||
|
||
/* | ||
* See also: | ||
* https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.descriptor.gatt.client_characteristic_configuration.xml | ||
*/ | ||
#include "sdkconfig.h" | ||
#if defined(CONFIG_BT_ENABLED) | ||
|
||
#include "BLE2902.h" | ||
|
||
BLE2902::BLE2902() : BLEDescriptor(BLEUUID((uint16_t) 0x2902)) { | ||
uint8_t data[2] = {0,0}; | ||
setValue(data, 2); | ||
} // BLE2902 | ||
|
||
|
||
/** | ||
* @brief Get the notifications value. | ||
* @return The notifications value. True if notifications are enabled and false if not. | ||
*/ | ||
bool BLE2902::getNotifications() { | ||
return (getValue()[0] & (1 << 0)) != 0; | ||
} // getNotifications | ||
|
||
|
||
/** | ||
* @brief Get the indications value. | ||
* @return The indications value. True if indications are enabled and false if not. | ||
*/ | ||
bool BLE2902::getIndications() { | ||
return (getValue()[0] & (1 << 1)) != 0; | ||
} // getIndications | ||
|
||
|
||
/** | ||
* @brief Set the indications flag. | ||
* @param [in] flag The indications flag. | ||
*/ | ||
void BLE2902::setIndications(bool flag) { | ||
uint8_t *pValue = getValue(); | ||
if (flag) { | ||
pValue[0] |= 1<<1; | ||
} else { | ||
pValue[0] &= ~(1<<1); | ||
} | ||
} // setIndications | ||
|
||
|
||
/** | ||
* @brief Set the notifications flag. | ||
* @param [in] flag The notifications flag. | ||
*/ | ||
void BLE2902::setNotifications(bool flag) { | ||
uint8_t *pValue = getValue(); | ||
if (flag) { | ||
pValue[0] |= 1<<0; | ||
} else { | ||
pValue[0] &= ~(1<<0); | ||
} | ||
} // setNotifications | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* BLE2902.h | ||
* | ||
* Created on: Jun 25, 2017 | ||
* Author: kolban | ||
*/ | ||
|
||
#ifndef COMPONENTS_CPP_UTILS_BLE2902_H_ | ||
#define COMPONENTS_CPP_UTILS_BLE2902_H_ | ||
#include "sdkconfig.h" | ||
#if defined(CONFIG_BT_ENABLED) | ||
|
||
#include "BLEDescriptor.h" | ||
|
||
/** | ||
* @brief Descriptor for Client Characteristic Configuration. | ||
* | ||
* This is a convenience descriptor for the Client Characteristic Configuration which has a UUID of 0x2902. | ||
* | ||
* See also: | ||
* https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.descriptor.gatt.client_characteristic_configuration.xml | ||
*/ | ||
class BLE2902: public BLEDescriptor { | ||
public: | ||
BLE2902(); | ||
bool getNotifications(); | ||
bool getIndications(); | ||
void setNotifications(bool flag); | ||
void setIndications(bool flag); | ||
|
||
}; // BLE2902 | ||
|
||
#endif /* CONFIG_BT_ENABLED */ | ||
#endif /* COMPONENTS_CPP_UTILS_BLE2902_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* BLE2904.cpp | ||
* | ||
* Created on: Dec 23, 2017 | ||
* Author: kolban | ||
*/ | ||
|
||
/* | ||
* See also: | ||
* https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.descriptor.gatt.characteristic_presentation_format.xml | ||
*/ | ||
#include "sdkconfig.h" | ||
#if defined(CONFIG_BT_ENABLED) | ||
|
||
#include "BLE2904.h" | ||
|
||
|
||
BLE2904::BLE2904() : BLEDescriptor(BLEUUID((uint16_t) 0x2904)) { | ||
m_data.m_format = 0; | ||
m_data.m_exponent = 0; | ||
m_data.m_namespace = 1; // 1 = Bluetooth SIG Assigned Numbers | ||
m_data.m_unit = 0; | ||
m_data.m_description = 0; | ||
setValue((uint8_t*)&m_data, sizeof(m_data)); | ||
} // BLE2902 | ||
|
||
|
||
/** | ||
* @brief Set the description. | ||
*/ | ||
void BLE2904::setDescription(uint16_t description) { | ||
m_data.m_description = description; | ||
setValue((uint8_t*)&m_data, sizeof(m_data)); | ||
} | ||
|
||
|
||
/** | ||
* @brief Set the exponent. | ||
*/ | ||
void BLE2904::setExponent(int8_t exponent) { | ||
m_data.m_exponent = exponent; | ||
setValue((uint8_t*)&m_data, sizeof(m_data)); | ||
} // setExponent | ||
|
||
|
||
/** | ||
* @brief Set the format. | ||
*/ | ||
void BLE2904::setFormat(uint8_t format) { | ||
m_data.m_format = format; | ||
setValue((uint8_t*)&m_data, sizeof(m_data)); | ||
} // setFormat | ||
|
||
|
||
/** | ||
* @brief Set the namespace. | ||
*/ | ||
void BLE2904::setNamespace(uint8_t namespace_value) { | ||
m_data.m_namespace = namespace_value; | ||
setValue((uint8_t*)&m_data, sizeof(m_data)); | ||
} // setNamespace | ||
|
||
|
||
/** | ||
* @brief Set the units for this value. It should be one of the encoded values defined here: | ||
* https://www.bluetooth.com/specifications/assigned-numbers/units | ||
* @param [in] uint The type of units of this characteristic as defined by assigned numbers. | ||
*/ | ||
void BLE2904::setUnit(uint16_t unit) { | ||
m_data.m_unit = unit; | ||
setValue((uint8_t*)&m_data, sizeof(m_data)); | ||
} // setUnit | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* BLE2904.h | ||
* | ||
* Created on: Dec 23, 2017 | ||
* Author: kolban | ||
*/ | ||
|
||
#ifndef COMPONENTS_CPP_UTILS_BLE2904_H_ | ||
#define COMPONENTS_CPP_UTILS_BLE2904_H_ | ||
#include "sdkconfig.h" | ||
#if defined(CONFIG_BT_ENABLED) | ||
|
||
#include "BLEDescriptor.h" | ||
|
||
struct BLE2904_Data { | ||
uint8_t m_format; | ||
int8_t m_exponent; | ||
uint16_t m_unit; // See https://www.bluetooth.com/specifications/assigned-numbers/units | ||
uint8_t m_namespace; | ||
uint16_t m_description; | ||
|
||
} __attribute__((packed)); | ||
|
||
/** | ||
* @brief Descriptor for Characteristic Presentation Format. | ||
* | ||
* This is a convenience descriptor for the Characteristic Presentation Format which has a UUID of 0x2904. | ||
* | ||
* See also: | ||
* https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.descriptor.gatt.characteristic_presentation_format.xml | ||
*/ | ||
class BLE2904: public BLEDescriptor { | ||
public: | ||
BLE2904(); | ||
static const uint8_t FORMAT_BOOLEAN = 1; | ||
static const uint8_t FORMAT_UINT2 = 2; | ||
static const uint8_t FORMAT_UINT4 = 3; | ||
static const uint8_t FORMAT_UINT8 = 4; | ||
static const uint8_t FORMAT_UINT12 = 5; | ||
static const uint8_t FORMAT_UINT16 = 6; | ||
static const uint8_t FORMAT_UINT24 = 7; | ||
static const uint8_t FORMAT_UINT32 = 8; | ||
static const uint8_t FORMAT_UINT48 = 9; | ||
static const uint8_t FORMAT_UINT64 = 10; | ||
static const uint8_t FORMAT_UINT128 = 11; | ||
static const uint8_t FORMAT_SINT8 = 12; | ||
static const uint8_t FORMAT_SINT12 = 13; | ||
static const uint8_t FORMAT_SINT16 = 14; | ||
static const uint8_t FORMAT_SINT24 = 15; | ||
static const uint8_t FORMAT_SINT32 = 16; | ||
static const uint8_t FORMAT_SINT48 = 17; | ||
static const uint8_t FORMAT_SINT64 = 18; | ||
static const uint8_t FORMAT_SINT128 = 19; | ||
static const uint8_t FORMAT_FLOAT32 = 20; | ||
static const uint8_t FORMAT_FLOAT64 = 21; | ||
static const uint8_t FORMAT_SFLOAT16 = 22; | ||
static const uint8_t FORMAT_SFLOAT32 = 23; | ||
static const uint8_t FORMAT_IEEE20601 = 24; | ||
static const uint8_t FORMAT_UTF8 = 25; | ||
static const uint8_t FORMAT_UTF16 = 26; | ||
static const uint8_t FORMAT_OPAQUE = 27; | ||
|
||
void setDescription(uint16_t); | ||
void setExponent(int8_t exponent); | ||
void setFormat(uint8_t format); | ||
void setNamespace(uint8_t namespace_value); | ||
void setUnit(uint16_t unit); | ||
|
||
private: | ||
BLE2904_Data m_data; | ||
}; // BLE2904 | ||
|
||
#endif /* CONFIG_BT_ENABLED */ | ||
#endif /* COMPONENTS_CPP_UTILS_BLE2904_H_ */ |
Oops, something went wrong.