aboutsummaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-10-27 09:14:31 +0200
committerSven Gothel <[email protected]>2023-10-27 09:14:31 +0200
commit8f2aee1820abb45fb06873e7f195885f499fda9e (patch)
tree8ceddf92f855520381ffca784af28538f125e31c /api
parent9cfa085535f80f90514d407e28602783c60a6252 (diff)
Convenience: Add DBGattValue.make(..) for java and 'POctets make_gvalue(..)' for C++ for general use (commonly used to ctor a DBGattServer)
Diffstat (limited to 'api')
-rw-r--r--api/direct_bt/DBGattServer.hpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/api/direct_bt/DBGattServer.hpp b/api/direct_bt/DBGattServer.hpp
index 4d899d45..e2fc23a6 100644
--- a/api/direct_bt/DBGattServer.hpp
+++ b/api/direct_bt/DBGattServer.hpp
@@ -501,6 +501,34 @@ namespace direct_bt {
typedef std::shared_ptr<DBGattChar> DBGattCharRef;
+ /** Convenience jau::POctets ctor function to create DBGattChar or DBGattDesc values. */
+ inline jau::POctets make_gvalue(const char* name) {
+ return jau::POctets( (const uint8_t*)name, (jau::nsize_t)strlen(name), jau::endian::little );
+ }
+
+ /** Convenience jau::POctets ctor function to create DBGattChar or DBGattDesc values. */
+ inline jau::POctets make_gvalue(const char* name, const jau::nsize_t capacity) {
+ const jau::nsize_t name_len = (jau::nsize_t)strlen(name);
+ jau::POctets p( std::max<jau::nsize_t>(capacity, name_len), name_len, jau::endian::little );
+ p.bzero();
+ p.put_bytes_nc(0, reinterpret_cast<const uint8_t*>(name), name_len);
+ return p;
+ }
+
+ /** Convenience jau::POctets ctor function to create DBGattChar or DBGattDesc values. */
+ inline jau::POctets make_gvalue(const uint16_t v) {
+ jau::POctets p(2, jau::endian::little);
+ p.put_uint16_nc(0, v);
+ return p;
+ }
+
+ /** Convenience jau::POctets ctor function to create DBGattChar or DBGattDesc values. */
+ inline jau::POctets make_gvalue(const jau::nsize_t capacity, const jau::nsize_t size) {
+ jau::POctets p(capacity, size, jau::endian::little);
+ p.bzero();
+ return p;
+ }
+
/**
* Representing a Gatt Service object from the ::GATTRole::Server perspective.
*