From 6fcde7962909577a8ad8032ac3cb9372bb0df0de Mon Sep 17 00:00:00 2001 From: technyon Date: Mon, 27 Jun 2022 21:44:48 +0200 Subject: [PATCH] rename Network to NetworkLock --- CMakeLists.txt | 2 +- Network.cpp => NetworkLock.cpp | 76 +++++++++---------- Network.h => NetworkLock.h | 6 +- NetworkOpener.cpp | 2 +- NetworkOpener.h | 6 +- NukiWrapper.cpp | 2 +- NukiWrapper.h | 6 +- PresenceDetection.cpp | 2 +- PresenceDetection.h | 6 +- WebCfgServer.cpp | 6 +- WebCfgServer.h | 6 +- .../nimble/host/mesh/include/mesh/cfg.h | 48 ++++++------ .../nimble/host/mesh/include/mesh/heartbeat.h | 2 +- .../nimble/host/mesh/include/mesh/main.h | 8 +- .../src/nimble/nimble/host/mesh/src/beacon.c | 2 +- .../src/nimble/nimble/host/mesh/src/net.c | 10 +-- .../src/nimble/nimble/host/mesh/src/net.h | 12 +-- .../src/nimble/nimble/host/mesh/src/shell.c | 4 +- .../src/nimble/nimble/host/mesh/src/subnet.h | 14 ++-- main.cpp | 6 +- 20 files changed, 113 insertions(+), 113 deletions(-) rename Network.cpp => NetworkLock.cpp (83%) rename Network.h => NetworkLock.h (95%) diff --git a/CMakeLists.txt b/CMakeLists.txt index c0c14e7..b7204b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,7 @@ include_directories(${PROJECT_NAME} file(GLOB SRCFILES Pins.h - Network.cpp + NetworkLock.cpp NetworkOpener.cpp networkDevices/NetworkDevice.h networkDevices/WifiDevice.cpp diff --git a/Network.cpp b/NetworkLock.cpp similarity index 83% rename from Network.cpp rename to NetworkLock.cpp index a51776f..1dbd13a 100644 --- a/Network.cpp +++ b/NetworkLock.cpp @@ -1,13 +1,13 @@ -#include "Network.h" +#include "NetworkLock.h" #include // https://github.com/tzapu/WiFiManager #include "Arduino.h" #include "MqttTopics.h" #include "PreferencesKeys.h" #include "Pins.h" -Network* nwInst; +NetworkLock* nwInst; -Network::Network(const NetworkDeviceType networkDevice, Preferences* preferences) +NetworkLock::NetworkLock(const NetworkDeviceType networkDevice, Preferences* preferences) : _preferences(preferences) { nwInst = this; @@ -23,7 +23,7 @@ Network::Network(const NetworkDeviceType networkDevice, Preferences* preferences _configTopics.push_back(mqtt_topic_config_auto_lock); } -Network::~Network() +NetworkLock::~NetworkLock() { if(_device != nullptr) { @@ -32,16 +32,16 @@ Network::~Network() } } -void Network::setupDevice(const NetworkDeviceType hardware) +void NetworkLock::setupDevice(const NetworkDeviceType hardware) { switch(hardware) { case NetworkDeviceType::W5500: - Serial.println(F("Network device: W5500")); + Serial.println(F("NetworkLock device: W5500")); _device = new W5500Device(_hostname, _preferences); break; case NetworkDeviceType::WiFi: - Serial.println(F("Network device: Builtin WiFi")); + Serial.println(F("NetworkLock device: Builtin WiFi")); _device = new WifiDevice(_hostname, _preferences); break; default: @@ -51,7 +51,7 @@ void Network::setupDevice(const NetworkDeviceType hardware) } } -void Network::initialize() +void NetworkLock::initialize() { if(_hostname == "") { @@ -115,7 +115,7 @@ void Network::initialize() Serial.println(port); _device->mqttClient()->setServer(_mqttBrokerAddr, port); - _device->mqttClient()->setCallback(Network::onMqttDataReceivedCallback); + _device->mqttClient()->setCallback(NetworkLock::onMqttDataReceivedCallback); _networkTimeout = _preferences->getInt(preference_network_timeout); if(_networkTimeout == 0) @@ -125,7 +125,7 @@ void Network::initialize() } } -bool Network::reconnect() +bool NetworkLock::reconnect() { _mqttConnected = false; @@ -170,7 +170,7 @@ bool Network::reconnect() return _mqttConnected; } -void Network::update() +void NetworkLock::update() { long ts = millis(); @@ -178,7 +178,7 @@ void Network::update() if(!_device->isConnected()) { - Serial.println(F("Network not connected. Trying reconnect.")); + Serial.println(F("NetworkLock not connected. Trying reconnect.")); bool success = _device->reconnect(); Serial.println(success ? F("Reconnect successful") : F("Reconnect failed")); } @@ -187,7 +187,7 @@ void Network::update() { if(_networkTimeout > 0 && (ts - _lastConnectedTs > _networkTimeout * 1000)) { - Serial.println("Network timeout has been reached, restarting ..."); + Serial.println("NetworkLock timeout has been reached, restarting ..."); delay(200); ESP.restart(); } @@ -219,12 +219,12 @@ void Network::update() _device->mqttClient()->loop(); } -void Network::onMqttDataReceivedCallback(char *topic, byte *payload, unsigned int length) +void NetworkLock::onMqttDataReceivedCallback(char *topic, byte *payload, unsigned int length) { nwInst->onMqttDataReceived(topic, payload, length); } -void Network::onMqttDataReceived(char *&topic, byte *&payload, unsigned int &length) +void NetworkLock::onMqttDataReceived(char *&topic, byte *&payload, unsigned int &length) { char value[50] = {0}; size_t l = min(length, sizeof(value)-1); @@ -265,7 +265,7 @@ void Network::onMqttDataReceived(char *&topic, byte *&payload, unsigned int &len } } -void Network::publishKeyTurnerState(const NukiLock::KeyTurnerState& keyTurnerState, const NukiLock::KeyTurnerState& lastKeyTurnerState) +void NetworkLock::publishKeyTurnerState(const NukiLock::KeyTurnerState& keyTurnerState, const NukiLock::KeyTurnerState& lastKeyTurnerState) { char str[50]; @@ -306,18 +306,18 @@ void Network::publishKeyTurnerState(const NukiLock::KeyTurnerState& keyTurnerSta _firstTunerStatePublish = false; } -void Network::publishAuthorizationInfo(const uint32_t authId, const char *authName) +void NetworkLock::publishAuthorizationInfo(const uint32_t authId, const char *authName) { publishUInt(mqtt_topic_lock_auth_id, authId); publishString(mqtt_topic_lock_auth_name, authName); } -void Network::publishCommandResult(const char *resultStr) +void NetworkLock::publishCommandResult(const char *resultStr) { publishString(mqtt_topic_lock_action_command_result, resultStr); } -void Network::publishBatteryReport(const NukiLock::BatteryReport& batteryReport) +void NetworkLock::publishBatteryReport(const NukiLock::BatteryReport& batteryReport) { publishFloat(mqtt_topic_battery_voltage, (float)batteryReport.batteryVoltage / 1000.0); publishInt(mqtt_topic_battery_drain, batteryReport.batteryDrain); // milliwatt seconds @@ -325,25 +325,25 @@ void Network::publishBatteryReport(const NukiLock::BatteryReport& batteryReport) publishInt(mqtt_topic_battery_lock_distance, batteryReport.lockDistance); // degrees } -void Network::publishConfig(const NukiLock::Config &config) +void NetworkLock::publishConfig(const NukiLock::Config &config) { publishBool(mqtt_topic_config_button_enabled, config.buttonEnabled == 1); publishBool(mqtt_topic_config_led_enabled, config.ledEnabled == 1); publishInt(mqtt_topic_config_led_brightness, config.ledBrightness); } -void Network::publishAdvancedConfig(const NukiLock::AdvancedConfig &config) +void NetworkLock::publishAdvancedConfig(const NukiLock::AdvancedConfig &config) { publishBool(mqtt_topic_config_auto_unlock, config.autoUnLockDisabled == 0); publishBool(mqtt_topic_config_auto_lock, config.autoLockEnabled == 1); } -void Network::publishPresenceDetection(char *csv) +void NetworkLock::publishPresenceDetection(char *csv) { _presenceCsv = csv; } -void Network::publishHASSConfig(char* deviceType, const char* baseTopic, char* name, char* uidString, char* lockAction, char* unlockAction, char* openAction, char* lockedState, char* unlockedState) +void NetworkLock::publishHASSConfig(char* deviceType, const char* baseTopic, char* name, char* uidString, char* lockAction, char* unlockAction, char* openAction, char* lockedState, char* unlockedState) { String discoveryTopic = _preferences->getString(preference_mqtt_hass_discovery); @@ -412,7 +412,7 @@ void Network::publishHASSConfig(char* deviceType, const char* baseTopic, char* n } } -void Network::removeHASSConfig(char* uidString) +void NetworkLock::removeHASSConfig(char* uidString) { String discoveryTopic = _preferences->getString(preference_mqtt_hass_discovery); @@ -434,22 +434,22 @@ void Network::removeHASSConfig(char* uidString) } } -void Network::setLockActionReceivedCallback(bool (*lockActionReceivedCallback)(const char *)) +void NetworkLock::setLockActionReceivedCallback(bool (*lockActionReceivedCallback)(const char *)) { _lockActionReceivedCallback = lockActionReceivedCallback; } -void Network::setConfigUpdateReceivedCallback(void (*configUpdateReceivedCallback)(const char *, const char *)) +void NetworkLock::setConfigUpdateReceivedCallback(void (*configUpdateReceivedCallback)(const char *, const char *)) { _configUpdateReceivedCallback = configUpdateReceivedCallback; } -void Network::setMqttDataReceivedForwardCallback(void (*callback)(char *, uint8_t *, unsigned int)) +void NetworkLock::setMqttDataReceivedForwardCallback(void (*callback)(char *, uint8_t *, unsigned int)) { _mqttTopicReceivedForwardCallback = callback; } -void Network::publishFloat(const char* topic, const float value, const uint8_t precision) +void NetworkLock::publishFloat(const char* topic, const float value, const uint8_t precision) { char str[30]; dtostrf(value, 0, precision, str); @@ -458,7 +458,7 @@ void Network::publishFloat(const char* topic, const float value, const uint8_t p _device->mqttClient()->publish(path, str); } -void Network::publishInt(const char *topic, const int value) +void NetworkLock::publishInt(const char *topic, const int value) { char str[30]; itoa(value, str, 10); @@ -467,7 +467,7 @@ void Network::publishInt(const char *topic, const int value) _device->mqttClient()->publish(path, str); } -void Network::publishUInt(const char *topic, const unsigned int value) +void NetworkLock::publishUInt(const char *topic, const unsigned int value) { char str[30]; utoa(value, str, 10); @@ -476,7 +476,7 @@ void Network::publishUInt(const char *topic, const unsigned int value) _device->mqttClient()->publish(path, str); } -void Network::publishBool(const char *topic, const bool value) +void NetworkLock::publishBool(const char *topic, const bool value) { char str[2] = {0}; str[0] = value ? '1' : '0'; @@ -485,19 +485,19 @@ void Network::publishBool(const char *topic, const bool value) _device->mqttClient()->publish(path, str); } -bool Network::publishString(const char *topic, const char *value) +bool NetworkLock::publishString(const char *topic, const char *value) { char path[200] = {0}; buildMqttPath(topic, path); return _device->mqttClient()->publish(path, value); } -bool Network::isMqttConnected() +bool NetworkLock::isMqttConnected() { return _mqttConnected; } -void Network::buildMqttPath(const char* path, char* outPath) +void NetworkLock::buildMqttPath(const char* path, char* outPath) { int offset = 0; for(const char& c : _mqttPath) @@ -519,26 +519,26 @@ void Network::buildMqttPath(const char* path, char* outPath) outPath[i+1] = 0x00; } -void Network::subscribe(const char *path) +void NetworkLock::subscribe(const char *path) { char prefixedPath[500]; buildMqttPath(path, prefixedPath); _device->mqttClient()->subscribe(prefixedPath); } -void Network::restartAndConfigureWifi() +void NetworkLock::restartAndConfigureWifi() { _device->reconfigure(); } -bool Network::comparePrefixedPath(const char *fullPath, const char *subPath) +bool NetworkLock::comparePrefixedPath(const char *fullPath, const char *subPath) { char prefixedPath[500]; buildMqttPath(subPath, prefixedPath); return strcmp(fullPath, prefixedPath) == 0; } -NetworkDevice *Network::device() +NetworkDevice *NetworkLock::device() { return _device; } diff --git a/Network.h b/NetworkLock.h similarity index 95% rename from Network.h rename to NetworkLock.h index 3703e93..09328b2 100644 --- a/Network.h +++ b/NetworkLock.h @@ -16,11 +16,11 @@ enum class NetworkDeviceType W5500 }; -class Network +class NetworkLock { public: - explicit Network(const NetworkDeviceType networkDevice, Preferences* preferences); - virtual ~Network(); + explicit NetworkLock(const NetworkDeviceType networkDevice, Preferences* preferences); + virtual ~NetworkLock(); void initialize(); void update(); diff --git a/NetworkOpener.cpp b/NetworkOpener.cpp index 6de71c1..3c3b147 100644 --- a/NetworkOpener.cpp +++ b/NetworkOpener.cpp @@ -7,7 +7,7 @@ NetworkOpener* nwInstOpener; -NetworkOpener::NetworkOpener(Network* network, Preferences* preferences) +NetworkOpener::NetworkOpener(NetworkLock* network, Preferences* preferences) : _preferences(preferences), _network(network) { diff --git a/NetworkOpener.h b/NetworkOpener.h index ee15822..e4e03ba 100644 --- a/NetworkOpener.h +++ b/NetworkOpener.h @@ -9,12 +9,12 @@ #include "NukiConstants.h" #include "SpiffsCookie.h" #include "NukiOpenerConstants.h" -#include "Network.h" +#include "NetworkLock.h" class NetworkOpener { public: - explicit NetworkOpener(Network* network, Preferences* preferences); + explicit NetworkOpener(NetworkLock* network, Preferences* preferences); virtual ~NetworkOpener() = default; void initialize(); @@ -48,7 +48,7 @@ private: Preferences* _preferences; - Network* _network = nullptr; + NetworkLock* _network = nullptr; char _mqttPath[181] = {0}; bool _isConnected = false; diff --git a/NukiWrapper.cpp b/NukiWrapper.cpp index 32fec91..bc74cfa 100644 --- a/NukiWrapper.cpp +++ b/NukiWrapper.cpp @@ -6,7 +6,7 @@ NukiWrapper* nukiInst; -NukiWrapper::NukiWrapper(const std::string& deviceName, uint32_t id, BleScanner::Scanner* scanner, Network* network, Preferences* preferences) +NukiWrapper::NukiWrapper(const std::string& deviceName, uint32_t id, BleScanner::Scanner* scanner, NetworkLock* network, Preferences* preferences) : _deviceName(deviceName), _bleScanner(scanner), _nukiLock(deviceName, id), diff --git a/NukiWrapper.h b/NukiWrapper.h index 5133db2..00155d4 100644 --- a/NukiWrapper.h +++ b/NukiWrapper.h @@ -1,6 +1,6 @@ #pragma once -#include "Network.h" +#include "NetworkLock.h" #include "NukiConstants.h" #include "NukiDataTypes.h" #include "BleScanner.h" @@ -9,7 +9,7 @@ class NukiWrapper : public Nuki::SmartlockEventHandler { public: - NukiWrapper(const std::string& deviceName, uint32_t id, BleScanner::Scanner* scanner, Network* network, Preferences* preferences); + NukiWrapper(const std::string& deviceName, uint32_t id, BleScanner::Scanner* scanner, NetworkLock* network, Preferences* preferences); virtual ~NukiWrapper(); void initialize(); @@ -46,7 +46,7 @@ private: std::string _deviceName; NukiLock::NukiLock _nukiLock; BleScanner::Scanner* _bleScanner; - Network* _network; + NetworkLock* _network; Preferences* _preferences; int _intervalLockstate = 0; // seconds int _intervalBattery = 0; // seconds diff --git a/PresenceDetection.cpp b/PresenceDetection.cpp index 681bcc0..1b95e4e 100644 --- a/PresenceDetection.cpp +++ b/PresenceDetection.cpp @@ -1,7 +1,7 @@ #include "PresenceDetection.h" #include "PreferencesKeys.h" -PresenceDetection::PresenceDetection(Preferences* preferences, BleScanner::Scanner *bleScanner, Network* network) +PresenceDetection::PresenceDetection(Preferences* preferences, BleScanner::Scanner *bleScanner, NetworkLock* network) : _preferences(preferences), _bleScanner(bleScanner), _network(network) diff --git a/PresenceDetection.h b/PresenceDetection.h index 6cc210c..8dc82a0 100644 --- a/PresenceDetection.h +++ b/PresenceDetection.h @@ -2,7 +2,7 @@ #include "BleScanner.h" #include "BleInterfaces.h" -#include "Network.h" +#include "NetworkLock.h" struct PdDevice { @@ -18,7 +18,7 @@ struct PdDevice class PresenceDetection : public BleScanner::Subscriber { public: - PresenceDetection(Preferences* preferences, BleScanner::Scanner* bleScanner, Network* network); + PresenceDetection(Preferences* preferences, BleScanner::Scanner* bleScanner, NetworkLock* network); virtual ~PresenceDetection(); void initialize(); @@ -31,7 +31,7 @@ private: Preferences* _preferences; BleScanner::Scanner* _bleScanner; - Network* _network; + NetworkLock* _network; char* _csv = {0}; std::map _devices; int _timeout = 20000; diff --git a/WebCfgServer.cpp b/WebCfgServer.cpp index 3cf6224..ea90aad 100644 --- a/WebCfgServer.cpp +++ b/WebCfgServer.cpp @@ -4,7 +4,7 @@ #include "hardware/WifiEthServer.h" #include -WebCfgServer::WebCfgServer(NukiWrapper* nuki, NukiOpenerWrapper* nukiOpener, Network* network, EthServer* ethServer, Preferences* preferences, bool allowRestartToPortal) +WebCfgServer::WebCfgServer(NukiWrapper* nuki, NukiOpenerWrapper* nukiOpener, NetworkLock* network, EthServer* ethServer, Preferences* preferences, bool allowRestartToPortal) : _server(ethServer), _nuki(nuki), _nukiOpener(nukiOpener), @@ -383,7 +383,7 @@ void WebCfgServer::buildHtml(String& response) printParameter(response, "Firmware", version.c_str()); response.concat("

"); - response.concat("

MQTT and Network Configuration

"); + response.concat("

MQTT and NetworkLock Configuration

"); buildNavigationButton(response, "Edit", "/mqttconfig"); response.concat("

NUKI Configuration

"); @@ -508,7 +508,7 @@ void WebCfgServer::buildMqttConfigHtml(String &response) printTextarea(response, "MQTTCRT", "MQTT SSL Client Certificate (*, optional)", _preferences->getString(preference_mqtt_crt).c_str(), TLS_CERT_MAX_SIZE); printTextarea(response, "MQTTKEY", "MQTT SSL Client Key (*, optional)", _preferences->getString(preference_mqtt_key).c_str(), TLS_KEY_MAX_SIZE); printInputField(response, "HASSDISCOVERY", "Home Assistant discovery topic (empty to disable)", _preferences->getString(preference_mqtt_hass_discovery).c_str(), 30); - printInputField(response, "NETTIMEOUT", "Network Timeout until restart (seconds; -1 to disable)", _preferences->getInt(preference_network_timeout), 5); + printInputField(response, "NETTIMEOUT", "NetworkLock Timeout until restart (seconds; -1 to disable)", _preferences->getInt(preference_network_timeout), 5); response.concat(""); response.concat("* If no encryption is configured for the MQTT broker, leave empty.
"); diff --git a/WebCfgServer.h b/WebCfgServer.h index defacdf..62861b0 100644 --- a/WebCfgServer.h +++ b/WebCfgServer.h @@ -3,7 +3,7 @@ #include #include #include "NukiWrapper.h" -#include "Network.h" +#include "NetworkLock.h" #include "NukiOpenerWrapper.h" #include "Ota.h" @@ -22,7 +22,7 @@ enum class TokenType class WebCfgServer { public: - WebCfgServer(NukiWrapper* nuki, NukiOpenerWrapper* nukiOpener, Network* network, EthServer* ethServer, Preferences* preferences, bool allowRestartToPortal); + WebCfgServer(NukiWrapper* nuki, NukiOpenerWrapper* nukiOpener, NetworkLock* network, EthServer* ethServer, Preferences* preferences, bool allowRestartToPortal); ~WebCfgServer() = default; void initialize(); @@ -58,7 +58,7 @@ private: WebServer _server; NukiWrapper* _nuki; NukiOpenerWrapper* _nukiOpener; - Network* _network; + NetworkLock* _network; Preferences* _preferences; Ota _ota; diff --git a/lib/NimBLE-Arduino/src/nimble/nimble/host/mesh/include/mesh/cfg.h b/lib/NimBLE-Arduino/src/nimble/nimble/host/mesh/include/mesh/cfg.h index 378f0a0..68eb949 100644 --- a/lib/NimBLE-Arduino/src/nimble/nimble/host/mesh/include/mesh/cfg.h +++ b/lib/NimBLE-Arduino/src/nimble/nimble/host/mesh/include/mesh/cfg.h @@ -55,15 +55,15 @@ enum bt_mesh_feat_state { #define BT_MESH_NODE_IDENTITY_RUNNING BT_MESH_FEATURE_ENABLED #define BT_MESH_NODE_IDENTITY_NOT_SUPPORTED BT_MESH_FEATURE_NOT_SUPPORTED -/** @brief Enable or disable sending of the Secure Network Beacon. +/** @brief Enable or disable sending of the Secure NetworkLock Beacon. * - * @param beacon New Secure Network Beacon state. + * @param beacon New Secure NetworkLock Beacon state. */ void bt_mesh_beacon_set(bool beacon); -/** @brief Get the current Secure Network Beacon state. +/** @brief Get the current Secure NetworkLock Beacon state. * - * @returns Whether the Secure Network Beacon feature is enabled. + * @returns Whether the Secure NetworkLock Beacon feature is enabled. */ bool bt_mesh_beacon_enabled(void); @@ -87,24 +87,24 @@ int bt_mesh_default_ttl_set(uint8_t default_ttl); */ uint8_t bt_mesh_default_ttl_get(void); -/** @brief Set the Network Transmit parameters. +/** @brief Set the NetworkLock Transmit parameters. * - * The Network Transmit parameters determine the parameters local messages are + * The NetworkLock Transmit parameters determine the parameters local messages are * transmitted with. * * @see BT_MESH_TRANSMIT * - * @param xmit New Network Transmit parameters. Use @ref BT_MESH_TRANSMIT for + * @param xmit New NetworkLock Transmit parameters. Use @ref BT_MESH_TRANSMIT for * encoding. */ void bt_mesh_net_transmit_set(uint8_t xmit); -/** @brief Get the current Network Transmit parameters. +/** @brief Get the current NetworkLock Transmit parameters. * * The @ref BT_MESH_TRANSMIT_COUNT and @ref BT_MESH_TRANSMIT_INT macros can be - * used to decode the Network Transmit parameters. + * used to decode the NetworkLock Transmit parameters. * - * @return The current Network Transmit parameters. + * @return The current NetworkLock Transmit parameters. */ uint8_t bt_mesh_net_transmit_get(void); @@ -210,10 +210,10 @@ enum bt_mesh_feat_state bt_mesh_friend_get(void); * * Adds a subnet with the given network index and network key to the list of * known Subnets. All messages sent on the given Subnet will be processed by - * this node, and the node may send and receive Network Beacons on the given + * this node, and the node may send and receive NetworkLock Beacons on the given * Subnet. * - * @param net_idx Network index. + * @param net_idx NetworkLock index. * @param key Root network key of the Subnet. All other keys are derived * from this. * @@ -233,7 +233,7 @@ uint8_t bt_mesh_subnet_add(uint16_t net_idx, const uint8_t key[16]); * keys for the entire network, effectively removing access for all nodes that * aren't given the new keys. * - * @param net_idx Network index. + * @param net_idx NetworkLock index. * @param key New root network key of the Subnet. * * @retval STATUS_SUCCESS The Subnet was updated with a second key. @@ -247,12 +247,12 @@ uint8_t bt_mesh_subnet_update(uint16_t net_idx, const uint8_t key[16]); /** @brief Delete a Subnet. * * Removes the Subnet with the given network index from the node. The node will - * stop sending Network Beacons with the given Subnet, and can no longer + * stop sending NetworkLock Beacons with the given Subnet, and can no longer * process messages on this Subnet. * * All Applications bound to this Subnet are also deleted. * - * @param net_idx Network index. + * @param net_idx NetworkLock index. * * @retval STATUS_SUCCESS The Subnet was deleted. * @retval STATUS_INVALID_NETKEY The NetIdx is unknown. @@ -261,7 +261,7 @@ uint8_t bt_mesh_subnet_del(uint16_t net_idx); /** @brief Check whether a Subnet is known. * - * @param net_idx Network index + * @param net_idx NetworkLock index * * @return true if a Subnet with the given index exists, false otherwise. */ @@ -277,7 +277,7 @@ bool bt_mesh_subnet_exists(uint16_t net_idx); * removes the old keys from the node, and returns the Subnet back to normal * single-key operation with the new key set. * - * @param net_idx Network index. + * @param net_idx NetworkLock index. * @param phase Pointer to the new Key Refresh phase. Will return the actual * Key Refresh phase after updating. * @@ -290,7 +290,7 @@ uint8_t bt_mesh_subnet_kr_phase_set(uint16_t net_idx, uint8_t *phase); /** @brief Get the Subnet's Key Refresh phase. * - * @param net_idx Network index. + * @param net_idx NetworkLock index. * @param phase Pointer to the Key Refresh variable to fill. * * @retval STATUS_SUCCESS Successfully populated the @c phase variable. @@ -311,7 +311,7 @@ uint8_t bt_mesh_subnet_kr_phase_get(uint16_t net_idx, uint8_t *phase); * GATT Proxy support must be enabled through * @option{CONFIG_BT_MESH_GATT_PROXY}. * - * @param net_idx Network index. + * @param net_idx NetworkLock index. * @param node_id New Node Identity state, must be either @ref * BT_MESH_FEATURE_ENABLED or @ref BT_MESH_FEATURE_DISABLED. * @@ -326,7 +326,7 @@ uint8_t bt_mesh_subnet_node_id_set(uint16_t net_idx, /** @brief Get the Node Identity state of the Subnet. * - * @param net_idx Network index. + * @param net_idx NetworkLock index. * @param node_id Node Identity variable to fill. * * @retval STATUS_SUCCESS Successfully populated the @c node_id variable. @@ -378,7 +378,7 @@ ssize_t bt_mesh_subnets_get(uint16_t net_idxs[], size_t max, off_t skip); * Subnet the Application is bound to before it can add the Application. * * @param app_idx Application index. - * @param net_idx Network index the Application is bound to. + * @param net_idx NetworkLock index the Application is bound to. * @param key Application key value. * * @retval STATUS_SUCCESS The Application was successfully added. @@ -406,7 +406,7 @@ uint8_t bt_mesh_app_key_add(uint16_t app_idx, uint16_t net_idx, * Refresh phase 1. * * @param app_idx Application index. - * @param net_idx Network index the Application is bound to, or + * @param net_idx NetworkLock index the Application is bound to, or * @ref BT_MESH_KEY_ANY to skip the binding check. * @param key New key value. * @@ -427,7 +427,7 @@ uint8_t bt_mesh_app_key_update(uint16_t app_idx, uint16_t net_idx, * All models publishing with this application will stop publishing. * * @param app_idx Application index. - * @param net_idx Network index. + * @param net_idx NetworkLock index. * * @retval STATUS_SUCCESS The Application key was successfully deleted. * @retval STATUS_INVALID_NETKEY The NetIdx is unknown. @@ -457,7 +457,7 @@ bool bt_mesh_app_key_exists(uint16_t app_idx); * Note that any changes to the Application key list between calls to this * function could change the order and number of entries in the list. * - * @param net_idx Network Index to get the Applications of, or @ref + * @param net_idx NetworkLock Index to get the Applications of, or @ref * BT_MESH_KEY_ANY to get all Applications. * @param app_idxs Array to fill. * @param max Max number of indexes to return. diff --git a/lib/NimBLE-Arduino/src/nimble/nimble/host/mesh/include/mesh/heartbeat.h b/lib/NimBLE-Arduino/src/nimble/nimble/host/mesh/include/mesh/heartbeat.h index b9990f6..0cfa1fe 100644 --- a/lib/NimBLE-Arduino/src/nimble/nimble/host/mesh/include/mesh/heartbeat.h +++ b/lib/NimBLE-Arduino/src/nimble/nimble/host/mesh/include/mesh/heartbeat.h @@ -36,7 +36,7 @@ struct bt_mesh_hb_pub { * @ref BT_MESH_FEAT_LOW_POWER. */ uint16_t feat; - /** Network index used for publishing. */ + /** NetworkLock index used for publishing. */ uint16_t net_idx; /** Publication period in seconds. */ uint32_t period; diff --git a/lib/NimBLE-Arduino/src/nimble/nimble/host/mesh/include/mesh/main.h b/lib/NimBLE-Arduino/src/nimble/nimble/host/mesh/include/mesh/main.h index 2bcb05c..d838329 100644 --- a/lib/NimBLE-Arduino/src/nimble/nimble/host/mesh/include/mesh/main.h +++ b/lib/NimBLE-Arduino/src/nimble/nimble/host/mesh/include/mesh/main.h @@ -382,7 +382,7 @@ int bt_mesh_prov_disable(bt_mesh_prov_bearer_t bearers); * @{ */ -/* Primary Network Key index */ +/* Primary NetworkLock Key index */ #define BT_MESH_NET_PRIMARY 0x000 /* Features */ @@ -450,8 +450,8 @@ int bt_mesh_resume(void); * only exception is for testing purposes where manual provisioning is * desired without an actual external provisioner. * - * @param net_key Network Key - * @param net_idx Network Key Index + * @param net_key NetworkLock Key + * @param net_idx NetworkLock Key Index * @param flags Provisioning Flags * @param iv_index IV Index * @param addr Primary element address @@ -466,7 +466,7 @@ int bt_mesh_provision(const uint8_t net_key[16], uint16_t net_idx, /** @brief Provision a Mesh Node using PB-ADV * * @param uuid UUID - * @param net_idx Network Key Index + * @param net_idx NetworkLock Key Index * @param addr Address to assign to remote device. If addr is 0, the lowest * available address will be chosen. * @param attention_duration The attention duration to be send to remote device diff --git a/lib/NimBLE-Arduino/src/nimble/nimble/host/mesh/src/beacon.c b/lib/NimBLE-Arduino/src/nimble/nimble/host/mesh/src/beacon.c index b7115c6..da8d4a7 100644 --- a/lib/NimBLE-Arduino/src/nimble/nimble/host/mesh/src/beacon.c +++ b/lib/NimBLE-Arduino/src/nimble/nimble/host/mesh/src/beacon.c @@ -69,7 +69,7 @@ void bt_mesh_beacon_create(struct bt_mesh_subnet *sub, net_buf_simple_add_u8(buf, flags); - /* Network ID */ + /* NetworkLock ID */ net_buf_simple_add_mem(buf, keys->net_id, 8); /* IV Index */ diff --git a/lib/NimBLE-Arduino/src/nimble/nimble/host/mesh/src/net.c b/lib/NimBLE-Arduino/src/nimble/nimble/host/mesh/src/net.c index 11728cf..429d27f 100644 --- a/lib/NimBLE-Arduino/src/nimble/nimble/host/mesh/src/net.c +++ b/lib/NimBLE-Arduino/src/nimble/nimble/host/mesh/src/net.c @@ -36,7 +36,7 @@ #include "../include/mesh/glue.h" #include "../include/mesh/slist.h" -/* Minimum valid Mesh Network PDU length. The Network headers +/* Minimum valid Mesh NetworkLock PDU length. The NetworkLock headers * themselves take up 9 bytes. After that there is a minumum of 1 byte * payload for both CTL=1 and CTL=0 PDUs (smallest OpCode is 1 byte). CTL=1 * PDUs must use a 64-bit (8 byte) NetMIC, whereas CTL=0 PDUs have at least @@ -575,7 +575,7 @@ static bool net_decrypt(struct bt_mesh_net_rx *rx, struct os_mbuf *in, } if (rx->net_if == BT_MESH_NET_IF_ADV && msg_cache_match(out)) { - BT_DBG("Duplicate found in Network Message Cache"); + BT_DBG("Duplicate found in NetworkLock Message Cache"); return false; } @@ -624,7 +624,7 @@ static void bt_mesh_net_relay(struct os_mbuf *sbuf, /* The Relay Retransmit state is only applied to adv-adv relaying. * Anything else (like GATT to adv, or locally originated packets) - * use the Network Transmit state. + * use the NetworkLock Transmit state. */ if (rx->net_if == BT_MESH_NET_IF_ADV && !rx->friend_cred) { transmit = bt_mesh_relay_retransmit_get(); @@ -668,7 +668,7 @@ static void bt_mesh_net_relay(struct os_mbuf *sbuf, /* When the Friend node relays message for lpn, the message will be * retransmitted using the managed master security credentials and - * the Network PDU shall be retransmitted to all network interfaces. + * the NetworkLock PDU shall be retransmitted to all network interfaces. */ if (IS_ENABLED(CONFIG_BT_MESH_GATT_PROXY) && (rx->friend_cred || @@ -796,7 +796,7 @@ void bt_mesh_net_recv(struct os_mbuf *data, int8_t rssi, * it again in the future. */ if (bt_mesh_trans_recv(buf, &rx) == -EAGAIN) { - BT_WARN("Removing rejected message from Network Message Cache"); + BT_WARN("Removing rejected message from NetworkLock Message Cache"); msg_cache[rx.msg_cache_idx].src = BT_MESH_ADDR_UNASSIGNED; /* Rewind the next index now that we're not using this entry */ msg_cache_next = rx.msg_cache_idx; diff --git a/lib/NimBLE-Arduino/src/nimble/nimble/host/mesh/src/net.h b/lib/NimBLE-Arduino/src/nimble/nimble/host/mesh/src/net.h index 91656f6..07b71bf 100644 --- a/lib/NimBLE-Arduino/src/nimble/nimble/host/mesh/src/net.h +++ b/lib/NimBLE-Arduino/src/nimble/nimble/host/mesh/src/net.h @@ -165,7 +165,7 @@ struct bt_mesh_lpn { /* bt_mesh_net.flags */ enum { BT_MESH_VALID, /* We have been provisioned */ - BT_MESH_SUSPENDED, /* Network is temporarily suspended */ + BT_MESH_SUSPENDED, /* NetworkLock is temporarily suspended */ BT_MESH_IVU_IN_PROGRESS, /* IV Update in Progress */ BT_MESH_IVU_INITIATOR, /* IV Update initiated by us */ BT_MESH_IVU_TEST, /* IV Update test mode */ @@ -224,7 +224,7 @@ struct bt_mesh_net { uint8_t dev_key[16]; }; -/* Network interface */ +/* NetworkLock interface */ enum bt_mesh_net_if { BT_MESH_NET_IF_ADV, BT_MESH_NET_IF_LOCAL, @@ -232,7 +232,7 @@ enum bt_mesh_net_if { BT_MESH_NET_IF_PROXY_CFG, }; -/* Decoding context for Network/Transport data */ +/* Decoding context for NetworkLock/Transport data */ struct bt_mesh_net_rx { struct bt_mesh_subnet *sub; struct bt_mesh_msg_ctx ctx; @@ -240,14 +240,14 @@ struct bt_mesh_net_rx { uint8_t old_iv:1, /* iv_index - 1 was used */ new_key:1, /* Data was encrypted with updated key */ friend_cred:1, /* Data was encrypted with friend cred */ - ctl:1, /* Network Control */ - net_if:2, /* Network interface */ + ctl:1, /* NetworkLock Control */ + net_if:2, /* NetworkLock interface */ local_match:1, /* Matched a local element */ friend_match:1; /* Matched an LPN we're friends for */ uint16_t msg_cache_idx; /* Index of entry in message cache */ }; -/* Encoding context for Network/Transport data */ +/* Encoding context for NetworkLock/Transport data */ struct bt_mesh_net_tx { struct bt_mesh_subnet *sub; struct bt_mesh_msg_ctx *ctx; diff --git a/lib/NimBLE-Arduino/src/nimble/nimble/host/mesh/src/shell.c b/lib/NimBLE-Arduino/src/nimble/nimble/host/mesh/src/shell.c index f8951b8..33f885f 100644 --- a/lib/NimBLE-Arduino/src/nimble/nimble/host/mesh/src/shell.c +++ b/lib/NimBLE-Arduino/src/nimble/nimble/host/mesh/src/shell.c @@ -24,7 +24,7 @@ #include "mesh/glue.h" #include "mesh/testing.h" -/* Private includes for raw Network & Transport layer access */ +/* Private includes for raw NetworkLock & Transport layer access */ #include "net.h" #include "rpl.h" #include "access.h" @@ -2863,7 +2863,7 @@ static int cmd_cdb_show(int argc, char *argv[]) return 0; } - printk("Mesh Network Information"); + printk("Mesh NetworkLock Information"); printk("========================"); cdb_print_nodes(); diff --git a/lib/NimBLE-Arduino/src/nimble/nimble/host/mesh/src/subnet.h b/lib/NimBLE-Arduino/src/nimble/nimble/host/mesh/src/subnet.h index e4a193b..d47f622 100644 --- a/lib/NimBLE-Arduino/src/nimble/nimble/host/mesh/src/subnet.h +++ b/lib/NimBLE-Arduino/src/nimble/nimble/host/mesh/src/subnet.h @@ -24,7 +24,7 @@ struct bt_mesh_net_rx; enum bt_mesh_key_evt; -/** Network message encryption credentials */ +/** NetworkLock message encryption credentials */ struct bt_mesh_net_cred { uint8_t nid; /* NID */ uint8_t enc[16]; /* EncKey */ @@ -56,7 +56,7 @@ struct bt_mesh_subnet { bool valid; uint8_t net[16]; /* NetKey */ struct bt_mesh_net_cred msg; - uint8_t net_id[8]; /* Network ID */ + uint8_t net_id[8]; /* NetworkLock ID */ #if defined(CONFIG_BT_MESH_GATT_PROXY) uint8_t identity[16]; /* IdentityKey */ #endif @@ -78,7 +78,7 @@ struct bt_mesh_subnet_cb { enum bt_mesh_key_evt evt); }; -/** @brief Reset all Network keys. */ +/** @brief Reset all NetworkLock keys. */ void bt_mesh_net_keys_reset(void); /** @brief Call cb on every valid Subnet until it returns a non-zero value. @@ -113,7 +113,7 @@ struct bt_mesh_subnet *bt_mesh_subnet_next(struct bt_mesh_subnet *sub); /** @brief Get a pointer to the Subnet with the given index. * - * @param net_idx Network index to look for. + * @param net_idx NetworkLock index to look for. * * @returns Subnet with index @c net_idx, or NULL if no such Subnet is known. */ @@ -121,7 +121,7 @@ struct bt_mesh_subnet *bt_mesh_subnet_get(uint16_t net_idx); /** @brief Initialize a new Subnet. * - * @param net_idx Network index of the Subnet. + * @param net_idx NetworkLock index of the Subnet. * @param kr_phase Key refresh phase the Subnet should be in. * @param key The current network key for the Subnet. * @param new_key New network key, if available. @@ -138,7 +138,7 @@ int bt_mesh_subnet_set(uint16_t net_idx, uint8_t kr_phase, * @param frnd_addr Address of the Friend node in the friendship. * @param lpn_counter The LPN's counter parameter. * @param frnd_counter The Friend node's counter parameter. - * @param key Network key to create the Friendship credentials for. + * @param key NetworkLock key to create the Friendship credentials for. * * @returns 0 on success, or (negative) error code on failure. */ @@ -149,7 +149,7 @@ int bt_mesh_friend_cred_create(struct bt_mesh_net_cred *cred, /** @brief Iterate through all valid network credentials to decrypt a message. * - * @param rx Network RX parameters, passed to the callback. + * @param rx NetworkLock RX parameters, passed to the callback. * @param in Input message buffer, passed to the callback. * @param out Output message buffer, passed to the callback. * @param cb Callback to call for each known network credential. Iteration diff --git a/main.cpp b/main.cpp index 94d1cfd..ffe6d52 100644 --- a/main.cpp +++ b/main.cpp @@ -1,7 +1,7 @@ #include "Arduino.h" #include "Pins.h" #include "NukiWrapper.h" -#include "Network.h" +#include "NetworkLock.h" #include "WebCfgServer.h" #include #include "PreferencesKeys.h" @@ -10,7 +10,7 @@ #include "hardware/WifiEthServer.h" #include "NukiOpenerWrapper.h" -Network* network = nullptr; +NetworkLock* network = nullptr; NetworkOpener* networkOpener = nullptr; WebCfgServer* webCfgServer = nullptr; BleScanner::Scanner* bleScanner = nullptr; @@ -146,7 +146,7 @@ void setup() // const NetworkDeviceType networkDevice = NetworkDeviceType::WiFi; const NetworkDeviceType networkDevice = digitalRead(NETWORK_SELECT) == HIGH ? NetworkDeviceType::WiFi : NetworkDeviceType::W5500; - network = new Network(networkDevice, preferences); + network = new NetworkLock(networkDevice, preferences); network->initialize(); networkOpener = new NetworkOpener(network, preferences); networkOpener->initialize();