int __exapp_connectivity_uninit(void)
{
  int ret;

  ret = ts_core_fd_unregister(g_conman_client.sd);
  if (ret < 0)
    {
      exapp_dbg("ts_core_fd_unregister failed\n");
    }

  if (g_connid != UINT32_MAX)
    {
      ret = con_timer_cb(-1, NULL, NULL);
      if (ret < 0)
        {
          exapp_dbg("con_timer_cb failed\n");
        }
    }

  exapp_dbg(">> Destroy all connections...\n");

  ret = conman_client_destroy_connection(&g_conman_client, CONMAN_CONNID_ALL);
  if (ret != OK)
    {
      exapp_dbg("conman_client_destroy_connection(CONMAN_CONNID_ALL) failed\n");
    }

  exapp_dbg(">> Done...\n");

  conman_client_uninit(&g_conman_client);

  return ret;
}
Exemple #2
0
static int ts_gps_core_reconfigure(void)
{
  struct pollfd pfd = {};
  int timeout_ms;
  int ret;

  /* Get new poll setup. */

  ret = ubgps_poll_setup(ts_gps, &pfd, &timeout_ms);
  if (ret < 0)
    {
      return ret;
    }

  /* Reconfigure poll events. */

  if (ts_core_gps.fd >= 0)
    ts_core_fd_unregister(ts_core_gps.fd);
  if (pfd.fd >= 0)
    {
      ret = ts_core_fd_register(pfd.fd, pfd.events, ts_gps_poll_callback,
                                NULL);
      DEBUGASSERT(ret >= 0);
    }

  ts_core_gps.fd = pfd.fd;

  /* Reconfigure timers. */

  if (ts_core_gps.timerid >= 0)
    ts_core_timer_stop(ts_core_gps.timerid);
  if (timeout_ms >= 0)
    {
      ret = ts_core_timer_setup(TS_TIMER_TYPE_TIMEOUT, timeout_ms,
                                ts_gps_timer_callback, NULL);
      DEBUGASSERT(ret >= 0);
      ts_core_gps.timerid = ret;
    }
  else
    {
      ts_core_gps.timerid = -1;
    }

  return OK;
}