diff options
Diffstat (limited to 'api')
-rw-r--r-- | api/direct_bt/DBGattServer.hpp | 28 |
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. * |