mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	Added response for Tuya RSSI command (#4549)
* Added wifi rssi util Added tuya mcu response to wifi rssi command * Cleanup * PR Comments * PR Comments
This commit is contained in:
		
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							a44e38300b
						
					
				
				
					commit
					ee7102fcd1
				
			| @@ -5,6 +5,10 @@ | |||||||
| #include "esphome/core/util.h" | #include "esphome/core/util.h" | ||||||
| #include "esphome/core/gpio.h" | #include "esphome/core/gpio.h" | ||||||
|  |  | ||||||
|  | #ifdef USE_WIFI | ||||||
|  | #include "esphome/components/wifi/wifi_component.h" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #ifdef USE_CAPTIVE_PORTAL | #ifdef USE_CAPTIVE_PORTAL | ||||||
| #include "esphome/components/captive_portal/captive_portal.h" | #include "esphome/components/captive_portal/captive_portal.h" | ||||||
| #endif | #endif | ||||||
| @@ -234,6 +238,10 @@ void Tuya::handle_command_(uint8_t command, uint8_t version, const uint8_t *buff | |||||||
|     case TuyaCommandType::WIFI_TEST: |     case TuyaCommandType::WIFI_TEST: | ||||||
|       this->send_command_(TuyaCommand{.cmd = TuyaCommandType::WIFI_TEST, .payload = std::vector<uint8_t>{0x00, 0x00}}); |       this->send_command_(TuyaCommand{.cmd = TuyaCommandType::WIFI_TEST, .payload = std::vector<uint8_t>{0x00, 0x00}}); | ||||||
|       break; |       break; | ||||||
|  |     case TuyaCommandType::WIFI_RSSI: | ||||||
|  |       this->send_command_( | ||||||
|  |           TuyaCommand{.cmd = TuyaCommandType::WIFI_RSSI, .payload = std::vector<uint8_t>{get_wifi_rssi_()}}); | ||||||
|  |       break; | ||||||
|     case TuyaCommandType::LOCAL_TIME_QUERY: |     case TuyaCommandType::LOCAL_TIME_QUERY: | ||||||
| #ifdef USE_TIME | #ifdef USE_TIME | ||||||
|       if (this->time_id_.has_value()) { |       if (this->time_id_.has_value()) { | ||||||
| @@ -475,6 +483,15 @@ uint8_t Tuya::get_wifi_status_code_() { | |||||||
|   return status; |   return status; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | uint8_t Tuya::get_wifi_rssi_() { | ||||||
|  | #ifdef USE_WIFI | ||||||
|  |   if (wifi::global_wifi_component != nullptr) | ||||||
|  |     return wifi::global_wifi_component->wifi_rssi(); | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  |   return 0; | ||||||
|  | } | ||||||
|  |  | ||||||
| void Tuya::send_wifi_status_() { | void Tuya::send_wifi_status_() { | ||||||
|   uint8_t status = this->get_wifi_status_code_(); |   uint8_t status = this->get_wifi_status_code_(); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -55,6 +55,7 @@ enum class TuyaCommandType : uint8_t { | |||||||
|   DATAPOINT_QUERY = 0x08, |   DATAPOINT_QUERY = 0x08, | ||||||
|   WIFI_TEST = 0x0E, |   WIFI_TEST = 0x0E, | ||||||
|   LOCAL_TIME_QUERY = 0x1C, |   LOCAL_TIME_QUERY = 0x1C, | ||||||
|  |   WIFI_RSSI = 0x24, | ||||||
|   VACUUM_MAP_UPLOAD = 0x28, |   VACUUM_MAP_UPLOAD = 0x28, | ||||||
|   GET_NETWORK_STATUS = 0x2B, |   GET_NETWORK_STATUS = 0x2B, | ||||||
| }; | }; | ||||||
| @@ -123,6 +124,7 @@ class Tuya : public Component, public uart::UARTDevice { | |||||||
|   void set_status_pin_(); |   void set_status_pin_(); | ||||||
|   void send_wifi_status_(); |   void send_wifi_status_(); | ||||||
|   uint8_t get_wifi_status_code_(); |   uint8_t get_wifi_status_code_(); | ||||||
|  |   uint8_t get_wifi_rssi_(); | ||||||
|  |  | ||||||
| #ifdef USE_TIME | #ifdef USE_TIME | ||||||
|   void send_local_time_(); |   void send_local_time_(); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user