Beispiel #1
0
static void console_make_clubby_call(struct v7 *v7, char *logs) {
  clubby_handle_t clubby_h = console_get_current_clubby(v7);
  struct ub_ctx *ctx = ub_ctx_new();
  ub_val_t log_cmd_args = ub_create_object(ctx);
  /*
   * TODO(alashkin): we need ub_create_string_n for non-zero terminated
   * strings
   */
  ub_add_prop(ctx, log_cmd_args, "msg", ub_create_string(ctx, logs));
  /* TODO(alashkin): set command timeout */
  s_waiting_for_resp = 1;
  sj_clubby_call(clubby_h, NULL, "/v1/Log.Log", ctx, log_cmd_args, 0, clubby_cb,
                 v7);
}
Beispiel #2
0
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;
}