Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
AzonInc committed Oct 10, 2024
1 parent 27910c1 commit 891c469
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 184 deletions.
22 changes: 0 additions & 22 deletions components/tc_bus/memory.cpp

This file was deleted.

30 changes: 0 additions & 30 deletions components/tc_bus/memory.h

This file was deleted.

39 changes: 34 additions & 5 deletions components/tc_bus/protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,16 +341,23 @@ namespace esphome
return data;
}

Model string_to_model(std::string str)
Model string_to_model(char* str)
{
if (str == "ISH_3030") return MODEL_ISH_3030;
//if (str == "ISH_3030") return MODEL_ISH_3030;

return MODEL_GENERIC;
}

CommandType string_to_command_type(std::string str)
SettingType string_to_setting_type(char* str)
{
if (str == "DOOR_CALL") return COMMAND_TYPE_DOOR_CALL;
//if (str == "ringtone_door_call") return SETTING_RINGTONE_DOOR_CALL;

return SETTING_RINGTONE_DOOR_CALL;
}

CommandType string_to_command_type(char* str)
{
/*if (str == "DOOR_CALL") return COMMAND_TYPE_DOOR_CALL;
if (str == "FLOOR_CALL") return COMMAND_TYPE_FLOOR_CALL;
if (str == "INTERNAL_CALL") return COMMAND_TYPE_INTERNAL_CALL;
if (str == "CONTROL_FUNCTION") return COMMAND_TYPE_CONTROL_FUNCTION;
Expand All @@ -374,7 +381,7 @@ namespace esphome
if (str == "PROGRAMMING_MODE") return COMMAND_TYPE_PROGRAMMING_MODE;
if (str == "READ_MEMORY_BLOCK") return COMMAND_TYPE_READ_MEMORY_BLOCK;
if (str == "SELECT_MEMORY_PAGE") return COMMAND_TYPE_SELECT_MEMORY_PAGE;
if (str == "WRITE_MEMORY") return COMMAND_TYPE_WRITE_MEMORY;
if (str == "WRITE_MEMORY") return COMMAND_TYPE_WRITE_MEMORY;*/

return COMMAND_TYPE_UNKNOWN;
}
Expand Down Expand Up @@ -412,5 +419,27 @@ namespace esphome
default: return "UNKNOWN";
}
}

const char* setting_type_to_string(SettingType type)
{
switch (type)
{
case SETTING_RINGTONE_FLOOR_CALL: return "ringtone_floor_call";
case SETTING_RINGTONE_DOOR_CALL: return "ringtone_door_call";
case SETTING_RINGTONE_INTERNAL_CALL: return "ringtone_internal_call";
case SETTING_VOLUME_RINGTONE: return "volume_ringtone";
case SETTING_VOLUME_HANDSET: return "volume_handset";
default: return "UNKNOWN";
}
}

const char* model_to_string(Model model)
{
switch (model)
{
case COMMAND_TYPE_ISH_3030: return "ISH_3030";
default: return "GENERIC";
}
}
} // namespace tc_bus
} // namespace esphome
20 changes: 19 additions & 1 deletion components/tc_bus/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ namespace esphome
MODEL_ISH_3030
};

enum SettingType {
SETTING_RINGTONE_FLOOR_CALL,
SETTING_RINGTONE_DOOR_CALL,
SETTING_RINGTONE_INTERNAL_CALL,
SETTING_VOLUME_RINGTONE,
SETTING_VOLUME_HANDSET
};

enum CommandType {
COMMAND_TYPE_UNKNOWN,
COMMAND_TYPE_DOOR_CALL,
Expand Down Expand Up @@ -50,13 +58,23 @@ namespace esphome
uint8_t length;
};

struct SettingCellData {
uint8_t index = 0;
bool left_nibble = false;
};


uint32_t buildCommand(CommandType type, uint8_t address = 0, uint32_t payload = 0, uint32_t serial_number = 0);
CommandData parseCommand(uint32_t command);

const char* command_type_to_string(CommandType type);
CommandType string_to_command_type(std::string str);
CommandType string_to_command_type(char* str);

const char* setting_type_to_string(SettingType type);
SettingType string_to_setting_type(char* str);

const char* model_to_string(Model model);
Model string_to_model(char* str);

} // namespace tc_bus
} // namespace esphome
Loading

0 comments on commit 891c469

Please sign in to comment.