Ll_write: write() rc -1, errno; conn_handshake: err 0xffffffff

Hi!
I have tried to add a another char* to respond to the device shadow, but when i flash the ESP32 with my firmware it connects to mDash and directly disconnects…

The code:

static void reportShadowState(struct device_state *state) {
  //state->temp = 0.0;
  mDashShadowUpdate("{\"state\":{\"reported\":{\"on\":%B,\"temp\":%T\"name\":%Q}}}",
                    state->on, state->temp == NULL ? "20" : "20", state->name == NULL ? "My Light" : state->name);
}

// "Shadow.Delta" RPC handler
// Called by the mDash when it generates shadow delta
static void onShadowDelta(struct jsonrpc_request *r) {
  struct device_state *state = (struct device_state *) r->userdata;
  char buf[50];
  char buf_t[50];
  //double t;
  int iv;
  if (mjson_get_bool(r->params, r->params_len, "$.state.on", &iv)) {
    state->on = iv;
  }
  if(mjson_get_string(r->params, r->params_len, "$.state.temp", buf_t,
                       sizeof(buf_t)) > 0) {
    free(state->temp);
    state->temp = strdup(buf_t);
  }
  if (mjson_get_string(r->params, r->params_len, "$.state.app.name", buf,
                       sizeof(buf)) > 0) {
    free(state->name);
    state->name = strdup(buf);
  }
  gpio_set_level(LED_PIN, state->on);  // Synchronise with the shadow
  reportShadowState(state);            // And report to mDash
}

.
.
.
.

void app_main() {
  struct device_state state = {.on = false, .temp = NULL, .name = NULL};
  mDashBeginWithWifi(init_wifi, NULL, NULL, NULL);
  jsonrpc_export("Shadow.Delta", onShadowDelta, &state);
  mDashRegisterEventHandler(MDASH_EVENT_CLOUD_CONNECTED, onConnnected, &state);
....
}

The error messages i get are:

  • ll_write: write() rc -1, errno 113
  • conn_handshake: err 0xffffffff

I’m using esp-idf.

Thank you in advance!

\"temp\":%T. %T is not a valid format descriptor.