Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
AzonInc committed Sep 23, 2024
1 parent fb95c74 commit 4cb7178
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
2 changes: 2 additions & 0 deletions components/tc_bus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
"found_device": CommandType.COMMAND_TYPE_FOUND_DEVICE,
"found_device_subsystem": CommandType.COMMAND_TYPE_FOUND_DEVICE_SUBSYSTEM,
"programming_mode": CommandType.COMMAND_TYPE_PROGRAMMING_MODE,
"read_eeprom_block": CommandType.COMMAND_TYPE_READ_EEPROM_BLOCK,
"select_eeprom_page": CommandType.COMMAND_TYPE_SELECT_EEPROM_PAGE,
}

CONF_TC_ID = "tc_bus"
Expand Down
26 changes: 26 additions & 0 deletions components/tc_bus/protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ namespace esphome
// request type and version
// request versions of subdevices
// Not implemented

// 5 12345 C0
break;

default:
Expand All @@ -186,6 +188,18 @@ namespace esphome
data.type = COMMAND_TYPE_CONTROL_FUNCTION;
data.address = (command & 0xFF); // Function number
break;

case 8:
// 81 0 00000
// select eeprom page of serial number

if(command & 0x800000) // 1
{
data.type = COMMAND_TYPE_SELECT_EEPROM_PAGE;
// data.address = (command & 0xF); // page todo
data.serial_number = command & 0xFFFFF;
}
break;
}
}
else
Expand Down Expand Up @@ -251,6 +265,16 @@ namespace esphome
break;
}
}
else if (first == 8)
{
switch(second)
{
case 4:
data.type = COMMAND_TYPE_READ_EEPROM_BLOCK;
data.address = (command & 0xFF);
break;
}
}
}

return data;
Expand Down Expand Up @@ -283,6 +307,8 @@ namespace esphome
case COMMAND_TYPE_FOUND_DEVICE: return "FOUND_DEVICE";
case COMMAND_TYPE_FOUND_DEVICE_SUBSYSTEM: return "FOUND_DEVICE_SUBSYSTEM";
case COMMAND_TYPE_PROGRAMMING_MODE: return "PROGRAMMING_MODE";
case COMMAND_TYPE_READ_EEPROM_BLOCK: return "READ_EEPROM_BLOCK";
case COMMAND_TYPE_SELECT_EEPROM_PAGE: return "SELECT_EEPROM_PAGE";
default: return "UNKNOWN";
}
}
Expand Down
4 changes: 3 additions & 1 deletion components/tc_bus/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ namespace esphome
COMMAND_TYPE_SEARCH_DEVICES,
COMMAND_TYPE_FOUND_DEVICE,
COMMAND_TYPE_FOUND_DEVICE_SUBSYSTEM,
COMMAND_TYPE_PROGRAMMING_MODE
COMMAND_TYPE_PROGRAMMING_MODE,
COMMAND_TYPE_READ_EEPROM_BLOCK,
COMMAND_TYPE_SELECT_EEPROM_PAGE
};

struct CommandData {
Expand Down
2 changes: 1 addition & 1 deletion components/tc_bus/tc_bus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ namespace esphome
delay(50);

ESP_LOGD(TAG, "Select Serial Number: %i", serial_number);
uint32_t select_cmd = 0x81000000;
uint32_t select_cmd = 0x81000000; // Select Page 0 of SN
select_cmd |= ((serial_number & 0xFFFFF) << 0); // C30BA
send_command(select_cmd); // select serial number
delay(50);
Expand Down

0 comments on commit 4cb7178

Please sign in to comment.