Skip to content

Commit

Permalink
Improve car manufacturer detection for Tesla
Browse files Browse the repository at this point in the history
Tesla has acquired multiple OUIs according to offical OUI list from IEEE.
Additionally, Tesla has a /28 sub-range.

While at, update coding style.

Signed-off-by: Michael Heimpold <michael.heimpold@chargebyte.com>
  • Loading branch information
mhei authored and corneliusclaussen committed Jan 30, 2024
1 parent c1c8a12 commit 76f6671
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
27 changes: 24 additions & 3 deletions modules/EvseManager/CarManufacturer.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,37 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2020 - 2022 Pionix GmbH and Contributors to EVerest
#include "CarManufacturer.hpp"
#include <set>

namespace module {

types::evse_manager::CarManufacturer get_manufacturer_from_mac(const std::string& mac) {
if (mac.size() < 8)
// Tesla OUIs according to http://standards-oui.ieee.org/oui.txt
const std::set<std::string> tesla = {
"0C:29:8F",
"4C:FC:AA",
"54:F8:F0",
"98:ED:5C",
};

if (mac.size() < 8) {
return types::evse_manager::CarManufacturer::Unknown;
if (mac.substr(0, 8) == "00:7D:FA")
}

if (mac.substr(0, 8) == "00:7D:FA") {
return types::evse_manager::CarManufacturer::VolkswagenGroup;
if (mac.substr(0, 8) == "98:ED:5C")
}

if (tesla.count(mac.substr(0, 8)) > 0) {
return types::evse_manager::CarManufacturer::Tesla;
}

// Tesla also acquired a /28 sub-range, let's have a dedicated check for this
// https://mac.lc/address/DC:44:27
if (mac.substr(0, 10) == "DC:44:27:1") {
return types::evse_manager::CarManufacturer::Tesla;
}

return types::evse_manager::CarManufacturer::Unknown;
}

Expand Down
3 changes: 2 additions & 1 deletion modules/EvseManager/CarManufacturer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
used for mapping:
Tesla: 98:ED:5C
Tesla: 0C:29:8F, 4C:FC:AA, 54:F8:F0, 98:ED:5C,
DC:44:27:1x:xx:xx/28
VW: 00:7D:FA (used for all brands such as Skoda as well)
not used here since they might be in use in multiple cars:
Expand Down

0 comments on commit 76f6671

Please sign in to comment.