Skip to content

Commit

Permalink
added group checking
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadhyGit committed Oct 1, 2023
1 parent 09411a8 commit 5905cb3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
22 changes: 22 additions & 0 deletions components/awox_mesh/mesh_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,22 @@ void MeshDevice::handle_packet(std::string &packet) {
this->send_discovery(device);
return;

} else if (static_cast<unsigned char>(packet[7]) == COMMAND_GROUP_INFO_RESP) {
mesh_id = (static_cast<unsigned char>(packet[10]) | 0x8000);

Device *device = this->get_device(mesh_id);
ESP_LOGD(TAG, "Checking if discovered");
if (!device->send_discovery)
{
ESP_LOGD(TAG, "Sending discovery!");
device->mac = "A4:C1:38:90:49:8A";
// Hardcoding to product_id: 0x32 (50 in DEC)
device->device_info = this->device_info_resolver->get_by_product_id(50);
this->send_discovery(device);
}

ESP_LOGD(TAG, "group info report: mesh: %d", mesh_id);

} else {
// ESP_LOGW(TAG, "Unknown report, dev [%d]: command %02X => %s", mesh_id, static_cast<unsigned char>(packet[7]),
// TextToBinaryString(packet).c_str());
Expand Down Expand Up @@ -820,6 +836,7 @@ Device *MeshDevice::get_device(int mesh_id) {
ESP_LOGI(TAG, "Added mesh_id: %d, Number of found mesh devices = %d", device->mesh_id, this->devices_.size());

this->request_device_info(device);
this->request_device_group(mesh_id);
// this->request_device_version(device->mesh_id);

return device;
Expand Down Expand Up @@ -861,5 +878,10 @@ bool MeshDevice::request_device_version(int dest) {
return true;
}

bool MeshDevice::request_device_group(int dest) {
this->queue_command(COMMAND_GROUP_INFO, {0x10, 0x01}, dest);
return true;
}

} // namespace awox_mesh
} // namespace esphome
2 changes: 2 additions & 0 deletions components/awox_mesh/mesh_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ static std::string uuid_pair_char = "00010203-0405-0607-0809-0a0b0c0d1914";
#define COMMAND_ADDRESS_REPORT 0xE1
#define COMMAND_DEVICE_INFO_QUERY 0xEA
#define COMMAND_DEVICE_INFO_REPORT 0xEB
#define COMMAND_GROUP_INFO 0xDD
#define COMMAND_GROUP_INFO_RESP 0xD4

static std::string TextToBinaryString(std::string words) {
std::string binaryString = "";
Expand Down

0 comments on commit 5905cb3

Please sign in to comment.