Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • c3pb/GeavisionReverse
1 result
Show changes
Commits on Source (3)
*.pyc *.pyc
.venv .venv
\ No newline at end of file build
\ No newline at end of file
...@@ -23,5 +23,11 @@ menu "GeaVision" ...@@ -23,5 +23,11 @@ menu "GeaVision"
default "mqtt://192.168.2.100" default "mqtt://192.168.2.100"
help help
Url form the orbiter mqtt server Url form the orbiter mqtt server
config GEA_DISPLAY_CHARACTERS
int "Number of GV33 Display panels"
default 48
help
Number of GV33 Display panels
endmenu endmenu
\ No newline at end of file
...@@ -62,24 +62,24 @@ static void log_error_if_nonzero(const char* message, int error_code) { ...@@ -62,24 +62,24 @@ static void log_error_if_nonzero(const char* message, int error_code) {
} }
} }
char* bin2str(char* data, int& len) { char* bin2str(char* data, size_t& len) {
char* buffer = new char[len * 3 + 4]; // two chars plus space per byte char* buffer = new char[len * 3 + 5]; // two chars plus space per byte
std::fill(buffer, buffer + (len * 3), 0); std::fill(buffer, buffer + (len * 3), 0);
uint cursor = 0; uint cursor = 0;
std::string dbgmsg = ""; std::string dbgmsg = "";
cursor += sprintf(buffer + cursor, "RAW="); cursor += sprintf(buffer + cursor, "RAW=");
std::for_each(data, data + len, [&cursor, &buffer](char c) { cursor += sprintf(buffer + cursor, " %hhx", c); }); std::for_each(data, data + len, [&cursor, &buffer](char c) { cursor += sprintf(buffer + cursor, " %02x", c); });
return buffer; return buffer;
} }
static void mqtt_event_handler(void* handler_args, esp_event_base_t base, int32_t event_id, void* event_data) { static void mqtt_event_handler(void* handler_args, esp_event_base_t base, int32_t event_id, void* event_data) {
ESP_LOGD(TAG, "Event dispatched from event loop base=%s, event_id=%" PRIi32 "", base, event_id); ESP_LOGD(MQTT_TAG, "Event dispatched from event loop base=%s, event_id=%" PRIi32 "", base, event_id);
esp_mqtt_event_handle_t event = (esp_mqtt_event_handle_t) event_data; esp_mqtt_event_handle_t event = (esp_mqtt_event_handle_t) event_data;
esp_mqtt_client_handle_t client = event->client; esp_mqtt_client_handle_t client = event->client;
// int msg_id; // int msg_id;
switch ((esp_mqtt_event_id_t) event_id) { switch ((esp_mqtt_event_id_t) event_id) {
case MQTT_EVENT_CONNECTED: case MQTT_EVENT_CONNECTED:
ESP_LOGI(TAG, "MQTT_EVENT_CONNECTED"); ESP_LOGI(MQTT_TAG, "MQTT_EVENT_CONNECTED");
// msg_id = esp_mqtt_client_publish(client, "/topic/qos1", "data_3", 0, 1, 0); // msg_id = esp_mqtt_client_publish(client, "/topic/qos1", "data_3", 0, 1, 0);
// ESP_LOGI(TAG, "sent publish successful, msg_id=%d", msg_id); // ESP_LOGI(TAG, "sent publish successful, msg_id=%d", msg_id);
...@@ -104,6 +104,8 @@ static void mqtt_event_handler(void* handler_args, esp_event_base_t base, int32_ ...@@ -104,6 +104,8 @@ static void mqtt_event_handler(void* handler_args, esp_event_base_t base, int32_
esp_mqtt_client_subscribe(client, "GeaVision/data/char", 0); esp_mqtt_client_subscribe(client, "GeaVision/data/char", 0);
esp_mqtt_client_publish(client, "GeaVision/status", "online", 0, 0, 0);
break; break;
case MQTT_EVENT_DISCONNECTED: case MQTT_EVENT_DISCONNECTED:
ESP_LOGI(TAG, "MQTT_EVENT_DISCONNECTED"); ESP_LOGI(TAG, "MQTT_EVENT_DISCONNECTED");
...@@ -134,8 +136,8 @@ static void mqtt_event_handler(void* handler_args, esp_event_base_t base, int32_ ...@@ -134,8 +136,8 @@ static void mqtt_event_handler(void* handler_args, esp_event_base_t base, int32_
for (uint i = 0; i < lcd_data_len; i++) { for (uint i = 0; i < lcd_data_len; i++) {
lcd_data->push_back((uint8_t) (event->data[i])); lcd_data->push_back((uint8_t) (event->data[i]));
} }
ESP_LOGD(DISPLAY_TAG, "LCD data size: %d", lcd_data->size()); ESP_LOGD(DISPLAY_TAG, "LCD data size: %d", lcd_data_len);
ESP_LOGD(DISPLAY_TAG, "%s", bin2str(event->data, event->data_len)); ESP_LOGD(DISPLAY_TAG, "%s", bin2str(event->data, lcd_data_len));
} else if (topic == "GeaVision/data/char") { } else if (topic == "GeaVision/data/char") {
ESP_LOGD(DISPLAY_TAG, "Received char data: %.*s", 1, event->data); ESP_LOGD(DISPLAY_TAG, "Received char data: %.*s", 1, event->data);
} else if (topic == "GeaVision/data/string") { } else if (topic == "GeaVision/data/string") {
...@@ -274,6 +276,7 @@ void app_main(void) { ...@@ -274,6 +276,7 @@ void app_main(void) {
esp_log_level_set("wifi", ESP_LOG_WARN); esp_log_level_set("wifi", ESP_LOG_WARN);
esp_log_level_set("wifi_init", ESP_LOG_WARN); esp_log_level_set("wifi_init", ESP_LOG_WARN);
esp_log_level_set(DISPLAY_TAG, ESP_LOG_DEBUG); esp_log_level_set(DISPLAY_TAG, ESP_LOG_DEBUG);
esp_log_level_set(TAG, ESP_LOG_DEBUG);
// app_desc = esp_app_get_description(); // app_desc = esp_app_get_description();
...@@ -347,6 +350,13 @@ void app_main(void) { ...@@ -347,6 +350,13 @@ void app_main(void) {
esp_mqtt_client_config_t mqtt_cfg = {}; esp_mqtt_client_config_t mqtt_cfg = {};
mqtt_cfg.broker.address.uri = mqtt_url.c_str(); mqtt_cfg.broker.address.uri = mqtt_url.c_str();
mqtt_cfg.session.last_will.topic = "GeaVision/status";
mqtt_cfg.session.last_will.msg = "offline";
mqtt_cfg.session.last_will.msg_len = 7;
mqtt_cfg.session.last_will.qos = 1;
mqtt_cfg.session.last_will.retain = true;
mqtt_cfg.session.disable_clean_session = false;
mqtt_cfg.session.keepalive = 30;
client = esp_mqtt_client_init(&mqtt_cfg); client = esp_mqtt_client_init(&mqtt_cfg);
esp_mqtt_client_register_event(client, MQTT_EVENT_ANY, mqtt_event_handler, client); esp_mqtt_client_register_event(client, MQTT_EVENT_ANY, mqtt_event_handler, client);
...@@ -359,7 +369,6 @@ void app_main(void) { ...@@ -359,7 +369,6 @@ void app_main(void) {
lcd_data->reserve(CONFIG_GEA_DISPLAY_CHARACTERS * 5); lcd_data->reserve(CONFIG_GEA_DISPLAY_CHARACTERS * 5);
while (1) { while (1) {
ESP_LOGD(DISPLAY_TAG, "%d", lcd_data->size());
lcd_write(spi, lcd_data->data(), lcd_data->size()); lcd_write(spi, lcd_data->data(), lcd_data->size());
vTaskDelay(200 / portTICK_PERIOD_MS); vTaskDelay(200 / portTICK_PERIOD_MS);
} }
......