forked from tbnobody/OpenDTU
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'tbnobody/OpenDTU/master'
- Loading branch information
Showing
55 changed files
with
1,191 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Device Profiles | ||
|
||
It is possible to change hardware settings like pin assignments or ethernet support using a json file. The json file can be uploaded using the configuration management in the web interface. Just select "Pin Mapping (pin_mapping.json)" in the recovery section. | ||
|
||
When the file is uploaded the ESP performs a reboot. This is required as the pin settings could have changed within the file. By default all the pin assignments are used as compiled into the firmware. | ||
|
||
To change the device profile, navigate to the "Device Manager" and selected the appropriate profile. You can see the current (Active) and the new (Selected) in assignment in the table below the combobox. | ||
|
||
## Structure of the json file | ||
|
||
```json | ||
[ | ||
{ | ||
"name": "Generic NodeMCU 38 pin", | ||
"nrf24": { | ||
"miso": 19, | ||
"mosi": 23, | ||
"clk": 18, | ||
"irq": 16, | ||
"en": 4, | ||
"cs": 5 | ||
}, | ||
"eth": { | ||
"enabled": false, | ||
"phy_addr": -1, | ||
"power": -1, | ||
"mdc": -1, | ||
"mdio": -1, | ||
"type": -1, | ||
"clk_mode": -1 | ||
} | ||
}, | ||
{ | ||
"name": "Olimex ESP32-POE", | ||
"nrf24": { | ||
"miso": 15, | ||
"mosi": 2, | ||
"clk": 14, | ||
"irq": 13, | ||
"en": 16, | ||
"cs": 5 | ||
}, | ||
"eth": { | ||
"enabled": true, | ||
"phy_addr": 0, | ||
"power": 12, | ||
"mdc": 23, | ||
"mdio": 18, | ||
"type": 0, | ||
"clk_mode": 3 | ||
} | ||
} | ||
] | ||
``` | ||
|
||
The json file can contain multiple profiles. Each profile requires a name and different parameters. If one parameter is not set, the default value, as compiled into the firmware is used. The example above shows all the currently supported values. Others may follow. A sample file with a lot of boards can be found [here](pin_mapping.json). This means you can just flash the generic bin file and upload the pin_mapping.json file. Then you select your board and everything works hopyfully as expected. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
[ | ||
{ | ||
"name": "Generic NodeMCU 38 pin", | ||
"nrf24": { | ||
"miso": 19, | ||
"mosi": 23, | ||
"clk": 18, | ||
"irq": 16, | ||
"en": 4, | ||
"cs": 5 | ||
}, | ||
"eth": { | ||
"enabled": false, | ||
"phy_addr": -1, | ||
"power": -1, | ||
"mdc": -1, | ||
"mdio": -1, | ||
"type": -1, | ||
"clk_mode": -1 | ||
} | ||
}, | ||
{ | ||
"name": "Olimex ESP32-POE", | ||
"nrf24": { | ||
"miso": 15, | ||
"mosi": 2, | ||
"clk": 14, | ||
"irq": 13, | ||
"en": 16, | ||
"cs": 5 | ||
}, | ||
"eth": { | ||
"enabled": true, | ||
"phy_addr": 0, | ||
"power": 12, | ||
"mdc": 23, | ||
"mdio": 18, | ||
"type": 0, | ||
"clk_mode": 3 | ||
} | ||
}, | ||
{ | ||
"name": "Olimex ESP32-EVB", | ||
"nrf24": { | ||
"miso": 15, | ||
"mosi": 2, | ||
"clk": 14, | ||
"irq": 13, | ||
"en": 16, | ||
"cs": 17 | ||
}, | ||
"eth": { | ||
"enabled": true, | ||
"phy_addr": 0, | ||
"power": 12, | ||
"mdc": 23, | ||
"mdio": 18, | ||
"type": 0, | ||
"clk_mode": 0 | ||
} | ||
}, | ||
{ | ||
"name": "Generic NodeMCU 30 pin", | ||
"nrf24": { | ||
"miso": 19, | ||
"mosi": 23, | ||
"clk": 18, | ||
"irq": 16, | ||
"en": 17, | ||
"cs": 5 | ||
}, | ||
"eth": { | ||
"enabled": false, | ||
"phy_addr": -1, | ||
"power": -1, | ||
"mdc": -1, | ||
"mdio": -1, | ||
"type": -1, | ||
"clk_mode": -1 | ||
} | ||
}, | ||
{ | ||
"name": "WT32-ETH01", | ||
"nrf24": { | ||
"miso": 4, | ||
"mosi": 2, | ||
"clk": 32, | ||
"irq": 33, | ||
"en": 14, | ||
"cs": 15 | ||
}, | ||
"eth": { | ||
"enabled": true, | ||
"phy_addr": 1, | ||
"power": 16, | ||
"mdc": 23, | ||
"mdio": 18, | ||
"type": 0, | ||
"clk_mode": 3 | ||
} | ||
}, | ||
{ | ||
"name": "LILYGO TTGO T-Internet-POE", | ||
"nrf24": { | ||
"miso": 2, | ||
"mosi": 15, | ||
"clk": 14, | ||
"irq": 34, | ||
"en": 12, | ||
"cs": 4 | ||
}, | ||
"eth": { | ||
"enabled": true, | ||
"phy_addr": 0, | ||
"power": -1, | ||
"mdc": 23, | ||
"mdio": 18, | ||
"type": 0, | ||
"clk_mode": 3 | ||
} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
#pragma once | ||
|
||
#include <Arduino.h> | ||
#include <stdint.h> | ||
#include <ETH.h> | ||
|
||
#define PINMAPPING_FILENAME "/pin_mapping.json" | ||
|
||
#define MAPPING_NAME_STRLEN 31 | ||
|
||
struct PinMapping_t { | ||
char name[MAPPING_NAME_STRLEN + 1]; | ||
int8_t nrf24_miso; | ||
int8_t nrf24_mosi; | ||
int8_t nrf24_clk; | ||
int8_t nrf24_irq; | ||
int8_t nrf24_en; | ||
int8_t nrf24_cs; | ||
int8_t eth_phy_addr; | ||
bool eth_enabled; | ||
int eth_power; | ||
int eth_mdc; | ||
int eth_mdio; | ||
eth_phy_type_t eth_type; | ||
eth_clock_mode_t eth_clk_mode; | ||
}; | ||
|
||
class PinMappingClass { | ||
public: | ||
PinMappingClass(); | ||
bool init(const String& deviceMapping); | ||
PinMapping_t& get(); | ||
|
||
bool isValidNrf24Config(); | ||
bool isValidEthConfig(); | ||
|
||
private: | ||
PinMapping_t _pinMapping; | ||
}; | ||
|
||
extern PinMappingClass PinMapping; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
#pragma once | ||
|
||
#include <ESPAsyncWebServer.h> | ||
|
||
class WebApiDeviceClass { | ||
public: | ||
void init(AsyncWebServer* server); | ||
void loop(); | ||
|
||
private: | ||
void onDeviceAdminGet(AsyncWebServerRequest* request); | ||
void onDeviceAdminPost(AsyncWebServerRequest* request); | ||
|
||
AsyncWebServer* _server; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.