コード例 #1
0
ファイル: sj_console.c プロジェクト: SnlanRao/mongoose-iot
static void console_process_data(struct v7 *v7) {
  clubby_handle_t clubby_h;
  if ((clubby_h = console_get_current_clubby(v7)) == NULL) {
    LOG(LL_DEBUG, ("Clubby is not set"));
    return;
  }
  if (sj_clubby_can_send(clubby_h)) {
    if (s_cache.file_names.len != 0) {
      /* There are unsent files, send them first */
      console_send_file(v7, &s_cache);
    } else if (s_cache.logs.len != 0) {
      /* No stored files, just send */
      console_make_clubby_call_mbuf(v7, &s_cache.logs);
    }
  }
}
コード例 #2
0
ファイル: cc3200_console.c プロジェクト: jamser/mongoose-iot
void cc3200_console_cloud_push() {
  if (s_cctx.buf.len == 0 || !s_cctx.initialized) return;
  int l = cc3200_console_next_msg_len();
  if (l == 0) return;  // Only send full messages.
  struct clubby *c = sj_clubby_get_global();
  if (c == NULL || !sj_clubby_is_connected(c)) {
    /* If connection drops, do not wait for reply as it may never arrive. */
    s_cctx.request_in_flight = 0;
    return;
  }
  if (s_cctx.request_in_flight || !sj_clubby_can_send(c)) return;
  s_cctx.request_in_flight = 1;
  s_cctx.in_console = 1;
  sj_clubby_call(c, NULL, "/v1/Log.Log", mg_mk_str_n(s_cctx.buf.buf, l - 1), 0,
                 clubby_cb, NULL);
  mbuf_remove(&s_cctx.buf, l);
  if (s_cctx.buf.len == 0) mbuf_trim(&s_cctx.buf);
  s_cctx.in_console = 0;
}