summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/main.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/main/main.cpp b/main/main.cpp
index 7858a77..354d015 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -140,7 +140,7 @@ static int on_config_item(void *ctx, const char* key, const char* value) {
typedef int (kv_event_handler)(void *ctx, const char *key, const char *value);
static int config_read_on_line(kv_event_handler *event_handler, void *ctx, const char* line, size_t sz) {
- printf("Handling line: #%d, %s\n", sz, line);
+ // printf("Handling line: #%d, %s\n", sz, line);
char *ptr = strchr(line, '=');
if (ptr == NULL) {
printf("Could not find '='\n");
@@ -159,7 +159,7 @@ static int config_read(kv_event_handler *event_handler, void *ctx)
int pos = 0;
int fd = open("config", O_RDONLY, 0);
- printf("fd=%d\n", fd);
+ // printf("fd=%d\n", fd);
if (fd < 0) {
ret = -1;
goto fail;
@@ -177,17 +177,17 @@ static int config_read(kv_event_handler *event_handler, void *ctx)
}
ret = read(fd, buf, sizeof(buf));
- printf("read: pos=%d, ret=%d\n", (int) pos, ret);
+ // printf("read: pos=%d, ret=%d\n", (int) pos, ret);
if (ret > 0) {
char *end = (char *)memchr(buf, 0, ret);
if (end == NULL) {
- printf("too line line, could not find newline\n");
+ printf("could not find newline\n");
ret = -1;
goto fail;
} else {
*end = '\0';
size_t line_sz = end - buf;
- printf("line_sz=%d\n", line_sz);
+ // printf("line_sz=%d\n", line_sz);
pos += line_sz + 1;
ret = config_read_on_line(event_handler, ctx, buf, line_sz);
@@ -205,7 +205,7 @@ fail:
close(fd);
}
- printf("%s: ret=%d\n", __FUNCTION__, ret);
+ // printf("%s: ret=%d\n", __FUNCTION__, ret);
return ret;
}
@@ -213,7 +213,7 @@ fail:
static int config_write_kv(int fd, const char *key, const char *value) {
int ret;
char c;
- printf("Writing %s=%s\n", key, value);
+ // printf("Writing %s=%s\n", key, value);
size_t sz = strlen(key);
ret = write(fd, (char *)key, sz);
@@ -269,7 +269,7 @@ fail:
close(fd);
}
- printf("%s: ret=%d\n", __FUNCTION__, ret);
+ // printf("%s: ret=%d\n", __FUNCTION__, ret);
return ret;
}
@@ -281,7 +281,7 @@ void wifi_event_handler_cb(System_Event_t *event)
}
if (event->event_id == EVENT_STAMODE_GOT_IP) {
- printf("STA GOT IP\n");
+ // printf("STA GOT IP\n");
if (main_task_handle) {
xTaskNotify(main_task_handle, EVENTS_GOT_IP, eSetBits);
}
@@ -339,7 +339,7 @@ static int mqtt_connect() {
goto fail;
}
- printf("%s: network connected\n", __FUNCTION__);
+ // printf("%s: network connected\n", __FUNCTION__);
#if defined(MQTT_TASK)
if ((ret = MQTTStartTask(&mqtt_client)) != pdPASS) {
@@ -355,7 +355,7 @@ static int mqtt_connect() {
printf("%s: MQTTConnect:%d\n", __FUNCTION__, ret);
goto fail;
}
- printf("%s: mqtt connected\n", __FUNCTION__);
+ // printf("%s: mqtt connected\n", __FUNCTION__);
return 0;
@@ -380,14 +380,15 @@ static int mqtt_publish(const char *topic, const char *value) {
MQTTMessage m;
bzero(&m, sizeof(m));
- m.qos = QOS0;
+ m.qos = QOS1;
m.payloadlen = strlen(value);
m.payload = (void *)value;
+ m.retained = 1;
return MQTTPublish(&mqtt_client, buf, &m);
}
static void set_station_mode(struct config &config) {
- printf("STATION_MODE\n");
+ // printf("STATION_MODE\n");
if (wifi_get_opmode_default() != NULL_MODE) {
printf("Setting default station mode");
wifi_set_opmode(NULL_MODE);
@@ -457,6 +458,8 @@ void user_init() {
int ret;
os_printf("SDK version: %s, free: %d\n", system_get_sdk_version(), system_get_free_heap_size());
+ os_printf("App: instace: " CONFIG_ESPTOOLPY_APP_NUM ", build: %s\n", __TIMESTAMP__);
+ os_printf("Upgrade: boot mode: %d, version: %d, user addr=%08x, flash map: %d\n", system_get_boot_mode(), system_get_boot_version(), system_get_userbin_addr(), system_get_flash_size_map());
fs_init();