19 WppClient::WppClient(
WppConnection &connection, WppErrHandler errHandler): _connection(connection), _errHandler(errHandler) {
63 return _client != NULL;
99 return _lwm2m_context->state;
103 return *_lwm2m_context;
115 lwm2m_observe_step(_lwm2m_context);
122 if (nextTaskCallIntervalSec < sleepTimeSec) sleepTimeSec = nextTaskCallIntervalSec;
126 int result = lwm2m_step(_lwm2m_context, &sleepTimeSec);
130 if (_errHandler) _errHandler(*
this, result);
131 _lwm2m_context->state = STATE_INITIAL;
141 lwm2m_deregister(_lwm2m_context);
144 #if defined(LWM2M_SUPPORT_SENML_JSON) && RES_1_23
145 bool WppClient::send(
const DataLink &link) {
146 WPP_LOGD(
TAG_WPP_CLIENT,
"Send data to servers: object ID -> %d, instance ID -> %d, resource ID -> %d, resource instance ID -> %d",
149 return !lwm2m_send_operation(_lwm2m_context, &uri);
154 bool WppClient::lwm2mContextOpen() {
155 _lwm2m_context = lwm2m_init(
this);
156 return _lwm2m_context != NULL;
159 void WppClient::lwm2mContextClose() {
160 lwm2m_close(_lwm2m_context);
161 _lwm2m_context = NULL;
164 bool WppClient::lwm2mConfigure(
const std::string &endpointName,
const std::string &msisdn,
const std::string &altPath) {
168 uint16_t objectsCnt =
sizeof(lwm2m_major_objects) /
sizeof(lwm2m_object_t *);
169 const char *msisdn_c = msisdn.empty()? NULL : msisdn.c_str();
170 const char *altPath_c = altPath.empty()? NULL : altPath.c_str();
171 return !lwm2m_configure(_lwm2m_context, endpointName.c_str(), msisdn_c, altPath_c, objectsCnt, lwm2m_major_objects);
#define WPP_CLIENT_MAX_SLEEP_TIME_S
#define WPP_LOGE(TAG, FMT,...)
#define WPP_LOGW(TAG, FMT,...)
#define WPP_LOGD(TAG, FMT,...)
#define WPP_LOGI(TAG, FMT,...)
static Object & object(WppClient &ctx)
Gets the Object reference.
static Object & object(WppClient &ctx)
Gets the Object reference.
static Object & object(WppClient &ctx)
Gets the Object reference.
lwm2m_object_t & getLwm2mObject()
Gets the lwm2m_object_t object.
Represents a client interface for Wpp library.
static WppClient * takeOwnership()
Takes ownership of the WppClient.
lwm2m_context_t & getContext()
Gets the LwM2M context associated with the WppClient.
void giveOwnership()
Gives up ownership of the WppClient.
static void remove()
Removes the WppClient.
time_t loop()
Processes the state of the Wakaama core. This function performs the necessary work by the Wakaama cor...
WppConnection & connection()
Gets the WppConnection associated with the WppClient.
lwm2m_client_state_t getState()
Gets the state of the Wakaama client.
static bool isCreated()
Checks if the WppClient is created.
static WppClient * takeOwnershipBlocking()
Takes ownership of the WppClient, blocking until it becomes available.
static bool create(const ClientInfo &info, WppConnection &connection, WppErrHandler errHandler=NULL)
Creates a WppClient with the specified client information, connection, and maximum sleep time.
std::function< void(WppClient &client, int errCode)> WppErrHandler
void deregister()
Deregisters the client from the servers.
WppRegistry & registry()
Gets the WppRegistry associated with the WppClient.
void clearPacketQueue()
Clears the packet queue.
void handlePacketsInQueue(WppClient &client)
Processes the packets in the packet queue.
The WppGuard class provides a linker callback class that must be implemented by the user.
bool try_lock()
Tries to lock the guard object.
void unlock()
Unlocks the guard object.
void lock()
Locks the guard object.
The WppRegistry class represents a registry for managing LWM2M objects.
static time_t handleEachTask(WppClient &client)
Execute each task in the queue and delete it from queue if task returns false or task state is SHOULD...
static size_t getTaskCnt()
Returns count of tasks in the queue. Tasks count does not immediately updated after request to remove...
static void hardReset()
Blocks task handling, calls of other methods, and deletes all tasks from the queue,...
The WppConnection class represents a connection interface for the Wpp library.
Represents the information required to create a WppClient.