Skip to content

Commit

Permalink
Merge pull request fsaris#23 from mkavalecz/main
Browse files Browse the repository at this point in the history
Add address_prefix config
  • Loading branch information
fsaris authored Jul 6, 2023
2 parents 0381cb6 + f0fc34f commit 586989e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
# You can modify this file to suit your needs.
/.esphome/
/secrets.yaml
.vscode
1 change: 1 addition & 0 deletions awox-ble-mesh-hub.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ esp32_ble_tracker:
awox_mesh:
mesh_name: !secret mesh_name
mesh_password: !secret mesh_password
address_prefix: A4:C1
device_info:
# Example device type, see device info in HomeAssistant or MQTT message to find the 'product_id'
- product_id: 0x32
Expand Down
2 changes: 2 additions & 0 deletions components/awox_mesh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
cv.GenerateID(): cv.declare_id(Awox),
cv.Required("mesh_name"): cv.string_strict,
cv.Required("mesh_password"): cv.string_strict,
cv.Required("address_prefix"): cv.string_strict,
cv.Optional("connection", {}): CONNECTION_SCHEMA,
cv.Optional("device_info", default=[]): cv.ensure_list(
cv.Schema(
Expand Down Expand Up @@ -74,6 +75,7 @@ async def to_code(config):

await cg.register_component(connection_var, config["connection"])
cg.add(var.register_connection(connection_var))
cg.add(var.set_address_prefix(config["address_prefix"]))
await esp32_ble_tracker.register_client(connection_var, config["connection"])

# Crypto
Expand Down
2 changes: 1 addition & 1 deletion components/awox_mesh/awox_mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ FoundDevice AwoxMesh::add_to_devices(const esp32_ble_tracker::ESPBTDevice &devic
}

bool AwoxMesh::parse_device(const esp32_ble_tracker::ESPBTDevice &device) {
if (device.address_str().rfind("A4:C1", 0) != 0) {
if (device.address_str().rfind(this->address_prefix, 0) != 0) {
return false;
}

Expand Down
6 changes: 6 additions & 0 deletions components/awox_mesh/awox_mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,17 @@ class AwoxMesh : public esp32_ble_tracker::ESPBTDeviceListener, public Component
ESP_LOGD("AwoxMesh", "register_connection");
this->connection = connection;
}
void set_address_prefix(const std::string &address_prefix) {
ESP_LOGI("AwoxMesh", "address_prefix: %s", address_prefix.c_str());
this->address_prefix = address_prefix;
}

void loop() override;

protected:
MeshDevice *connection;
std::vector<FoundDevice> devices_{};
std::string address_prefix = "A4:C1";
};

} // namespace awox_mesh
Expand Down

0 comments on commit 586989e

Please sign in to comment.