|
8 | 8 | #include "log_tags.h" |
9 | 9 | #include "pgp_autobutton.h" |
10 | 10 | #include "settings.h" |
| 11 | +#include "uart.h" |
| 12 | + |
| 13 | +const int retoggle_delay = 300000; |
11 | 14 |
|
12 | 15 | void handle_led_notify_from_app(esp_gatt_if_t gatts_if, uint16_t conn_id, const uint8_t* buffer) { |
13 | 16 | int number_of_patterns = buffer[3] & 0x1f; |
@@ -92,27 +95,54 @@ void handle_led_notify_from_app(esp_gatt_if_t gatts_if, uint16_t conn_id, const |
92 | 95 | ESP_LOGD(LEDHANDLER_TAG, "[%d] Turn LEDs off.", conn_id); |
93 | 96 | } else if (count_white && count_white == count_notoff) { |
94 | 97 | // only white |
95 | | - ESP_LOGW(LEDHANDLER_TAG, "[%d] Can't spin Pokestop. Bag is full.", conn_id); |
| 98 | + process_char('s'); |
| 99 | + |
| 100 | + ESP_LOGW(LEDHANDLER_TAG, |
| 101 | + "[%d] Bag is full: press button %s - re-enabling autospin after %d ms", |
| 102 | + conn_id, |
| 103 | + get_setting_log_value(&settings.autospin), |
| 104 | + retoggle_delay); |
| 105 | + |
| 106 | + settings_queue_item_t item; |
| 107 | + item.gatts_if = gatts_if; |
| 108 | + item.conn_id = conn_id; |
| 109 | + item.delay = retoggle_delay; |
| 110 | + xQueueSend(settings_queue, &item, portMAX_DELAY); |
96 | 111 | } else if (count_red && count_off && count_red == count_notoff) { |
97 | 112 | // blinking just red |
98 | 113 | ESP_LOGW( |
99 | 114 | LEDHANDLER_TAG, "[%d] Pokeballs are empty or Pokestop went out of range.", conn_id); |
100 | 115 | } else if (count_red && !count_off && count_red == count_notoff) { |
101 | 116 | // only red |
102 | | - ESP_LOGW(LEDHANDLER_TAG, "[%d] Can't catch Pokemon. Box is full.", conn_id); |
| 117 | + process_char('c'); |
| 118 | + ESP_LOGW(LEDHANDLER_TAG, |
| 119 | + "[%d] Box is full: press button %s", |
| 120 | + conn_id, |
| 121 | + get_setting_log_value(&settings.autospin)); |
103 | 122 | } else if (count_green && count_green == count_notoff) { |
104 | 123 | // blinking green |
105 | | - ESP_LOGI(LEDHANDLER_TAG, "[%d] Pokemon in range!", conn_id); |
| 124 | + ESP_LOGI(LEDHANDLER_TAG, |
| 125 | + "[%d] Pokemon in range: press button %s", |
| 126 | + conn_id, |
| 127 | + get_setting_log_value(&settings.autocatch)); |
106 | 128 | if (get_setting(&settings.autocatch)) { |
107 | 129 | press_button = true; |
108 | 130 | } |
109 | 131 | } else if (count_yellow && count_yellow == count_notoff) { |
110 | 132 | // blinking yellow |
111 | | - ESP_LOGI(LEDHANDLER_TAG, "[%d] New Pokemon in range!", conn_id); |
112 | | - press_button = true; |
| 133 | + ESP_LOGI(LEDHANDLER_TAG, |
| 134 | + "[%d] New pokemon in range: press button %s", |
| 135 | + conn_id, |
| 136 | + get_setting_log_value(&settings.autocatch)); |
| 137 | + if (get_setting(&settings.autocatch)) { |
| 138 | + press_button = true; |
| 139 | + } |
113 | 140 | } else if (count_blue && count_blue == count_notoff) { |
114 | 141 | // blinking blue |
115 | | - ESP_LOGI(LEDHANDLER_TAG, "[%d] Pokestop in range!", conn_id); |
| 142 | + ESP_LOGI(LEDHANDLER_TAG, |
| 143 | + "[%d] Pokestop in range: press button %s", |
| 144 | + conn_id, |
| 145 | + get_setting_log_value(&settings.autospin)); |
116 | 146 | if (get_setting(&settings.autospin)) { |
117 | 147 | press_button = true; |
118 | 148 | } |
|
0 commit comments