Ejemplo n.º 1
0
int mqttClient_disconnectData(mqttClient_t* clientData)
{
  int rc = LE_OK;

  if (!clientData->requestRef)
  {
    LE_ERROR("no data connection reference.");
    goto cleanup;
  }
    
  if (clientData->session.isConnected)
  {
    LE_INFO("Dispose MQTT resources.");
    mqttClient_disconnect(clientData);

    rc = mqttClient_close(clientData);
    if (rc)
    {
      LE_ERROR("mqttClient_close() failed(%d)", rc);
      goto cleanup;
    }
  }

  LE_INFO("releasing the data connection.");
  le_data_Release(clientData->requestRef);
  clientData->requestRef = NULL;
  mqttClient_SendConnStateEvent(false, 0, 0);

cleanup:
  return rc;
}
Ejemplo n.º 2
0
/* Asynchronous connectionRelease Lua API.
 * Final result will be received by ConnectionStateHandler.
 *
 * @param Lua userdata containing the Request id as returned by l_connectionRequest
 *
 * @returns on success: "ok" string.
 *          to be given back to le_data_Release.
 * @returns on error: nil+error_string
 */
static int l_release(lua_State *L)
{
    nmctx* nmud = (nmctx*) luaL_checkudata(L, 1, USERDATA);
    if (!nmud || !nmud->data_ref) {
      //data_ref is set to NULL after le_data_Release is done
      //nmud NULL would be internal error (luaL_checkudata should make Lua error)
      lua_pushnil(L);
      lua_pushstring(L, "connection already released");
      return 2;
    }
    le_data_Release(nmud->data_ref); //le_data_Release is void
    nmud->data_ref = NULL;
    lua_pushstring(L, "ok");
    return 1;
}
Ejemplo n.º 3
0
// -------------------------------------------------------------------------------------------------
static void GoOffline
(
    char* buffer   ///< [OUT] On success or failure, a message is written to this buffer.
)
{
    if(!RequestRef)
    {
        LE_ERROR("Not existing connection reference.");
        return;
    }

    le_data_Release(RequestRef);
    LE_INFO("Releasing the default data connection.");

    RequestRef = NULL;
}
Ejemplo n.º 4
0
static void ConnectionStateHandler
(
    const char *intfName,
    bool isConnected,
    void *contextPtr
)
{
    if (isConnected)
    {
        WaitingForConnection = false;
        LE_INFO("Interface %s connected.", intfName);
        GetUrl();
        le_data_Release(ConnectionRef);
    }
    else
    {
        LE_INFO("Interface %s disconnected.", intfName);
    }

}