 #include <ArduinoJson.h>
+#include <vmcell.h>
 #include <LGPRS.h>
 #include <LGPRSClient.h>
 #include <LBattery.h>
 #include <LGPS.h>
-#define MQTT_BUFFER_SIZE 256
+#include <LTask.h>
 #include <MQTTClient.h>
 
 #define JSON_BUF_SIZE 256

static void check_need_report() {
  if (millis() - g_last_report_ms > 240000) {
    g_last_report_ms = millis();
    g_need_report = true;
  }
}

static void handle_report() {
  if (!g_need_report) {
    return;
  }

  StaticJsonBuffer<JSON_BUF_SIZE> json_buf;
  JsonObject& root = json_buf.createObject();

  root["lock"] = (g_lock_status == LOCK_LOCKED);

  LGPS.getData(&g_gps_info);
  String gps = String((char *)g_gps_info.GPGGA);
  gps.trim();
  root["gps"] = gps;

  root["battery"] = LBattery.level();
  root["charge"] = (LBattery.isCharging() == true);

  String json;
  root.printTo(json);

  Serial.println("publish: " + json);
  g_mqtt_client.publish(g_report_topic, json);
  g_need_report = false;
}

static void unlock() {

static LGPRSClient g_net_client;
static MQTTClient g_mqtt_client;

static bool g_report_lock = true;
static bool g_report_other = true;

static gpsSentenceInfoStruct g_gps_info;
static unsigned long g_last_report_ms = 0;
