forked from hoylabs/OpenDTU-OnBattery
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'pr/MalteSchm/144' into development
- Loading branch information
Showing
33 changed files
with
1,555 additions
and
6 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
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,95 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
#pragma once | ||
|
||
#include <cstdint> | ||
#include "SPI.h" | ||
#include <mcp_can.h> | ||
|
||
#ifndef HUAWEI_PIN_MISO | ||
#define HUAWEI_PIN_MISO 12 | ||
#endif | ||
|
||
#ifndef HUAWEI_PIN_MOSI | ||
#define HUAWEI_PIN_MOSI 13 | ||
#endif | ||
|
||
#ifndef HUAWEI_PIN_SCLK | ||
#define HUAWEI_PIN_SCLK 26 | ||
#endif | ||
|
||
#ifndef HUAWEI_PIN_IRQ | ||
#define HUAWEI_PIN_IRQ 25 | ||
#endif | ||
|
||
#ifndef HUAWEI_PIN_CS | ||
#define HUAWEI_PIN_CS 15 | ||
#endif | ||
|
||
#ifndef HUAWEI_PIN_POWER | ||
#define HUAWEI_PIN_POWER 33 | ||
#endif | ||
|
||
#define HUAWEI_MINIMAL_OFFLINE_VOLTAGE 48 | ||
#define HUAWEI_MINIMAL_ONLINE_VOLTAGE 42 | ||
|
||
#define MAX_CURRENT_MULTIPLIER 20 | ||
|
||
#define HUAWEI_OFFLINE_VOLTAGE 0x01 | ||
#define HUAWEI_ONLINE_VOLTAGE 0x00 | ||
#define HUAWEI_OFFLINE_CURRENT 0x04 | ||
#define HUAWEI_ONLINE_CURRENT 0x03 | ||
|
||
#define R48xx_DATA_INPUT_POWER 0x70 | ||
#define R48xx_DATA_INPUT_FREQ 0x71 | ||
#define R48xx_DATA_INPUT_CURRENT 0x72 | ||
#define R48xx_DATA_OUTPUT_POWER 0x73 | ||
#define R48xx_DATA_EFFICIENCY 0x74 | ||
#define R48xx_DATA_OUTPUT_VOLTAGE 0x75 | ||
#define R48xx_DATA_OUTPUT_CURRENT_MAX 0x76 | ||
#define R48xx_DATA_INPUT_VOLTAGE 0x78 | ||
#define R48xx_DATA_OUTPUT_TEMPERATURE 0x7F | ||
#define R48xx_DATA_INPUT_TEMPERATURE 0x80 | ||
#define R48xx_DATA_OUTPUT_CURRENT 0x81 | ||
#define R48xx_DATA_OUTPUT_CURRENT1 0x82 | ||
|
||
struct RectifierParameters_t { | ||
float input_voltage; | ||
float input_frequency; | ||
float input_current; | ||
float input_power; | ||
float input_temp; | ||
float efficiency; | ||
float output_voltage; | ||
float output_current; | ||
float max_output_current; | ||
float output_power; | ||
float output_temp; | ||
float amp_hour; | ||
}; | ||
|
||
class HuaweiCanClass { | ||
public: | ||
void init(uint8_t huawei_miso, uint8_t huawei_mosi, uint8_t huawei_clk, uint8_t huawei_irq, uint8_t huawei_cs, uint8_t huawei_power); | ||
void loop(); | ||
void setValue(float in, uint8_t parameterType); | ||
void setPower(bool power); | ||
|
||
RectifierParameters_t * get(); | ||
unsigned long getLastUpdate(); | ||
|
||
private: | ||
void sendRequest(); | ||
void onReceive(uint8_t* frame, uint8_t len); | ||
|
||
unsigned long previousMillis; | ||
unsigned long lastUpdate; | ||
RectifierParameters_t _rp; | ||
|
||
SPIClass *spi; | ||
MCP_CAN *CAN; | ||
uint8_t _huawei_irq; | ||
uint8_t _huawei_power; | ||
|
||
}; | ||
|
||
extern HuaweiCanClass HuaweiCan; |
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,21 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
#pragma once | ||
|
||
#include "Configuration.h" | ||
#include <Huawei_can.h> | ||
#include <espMqttClient.h> | ||
|
||
class MqttHandleHuaweiClass { | ||
public: | ||
void init(); | ||
void loop(); | ||
|
||
private: | ||
void onMqttMessage(const espMqttClientTypes::MessageProperties& properties, const char* topic, const uint8_t* payload, size_t len, size_t index, size_t total); | ||
|
||
uint32_t _lastPublishStats; | ||
uint32_t _lastPublish; | ||
|
||
}; | ||
|
||
extern MqttHandleHuaweiClass MqttHandleHuawei; |
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,19 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
#pragma once | ||
|
||
#include <ESPAsyncWebServer.h> | ||
#include <AsyncJson.h> | ||
|
||
class WebApiHuaweiClass { | ||
public: | ||
void init(AsyncWebServer* server); | ||
void loop(); | ||
void getJsonData(JsonObject& root); | ||
private: | ||
void onStatus(AsyncWebServerRequest* request); | ||
void onAdminGet(AsyncWebServerRequest* request); | ||
void onAdminPost(AsyncWebServerRequest* request); | ||
void onPost(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
#pragma once | ||
|
||
#include "ArduinoJson.h" | ||
#include <ESPAsyncWebServer.h> | ||
//#include <HuaweiFrameHandler.h> | ||
|
||
class WebApiWsHuaweiLiveClass { | ||
public: | ||
WebApiWsHuaweiLiveClass(); | ||
void init(AsyncWebServer* server); | ||
void loop(); | ||
|
||
private: | ||
void generateJsonResponse(JsonVariant& root); | ||
void onLivedataStatus(AsyncWebServerRequest* request); | ||
void onWebsocketEvent(AsyncWebSocket* server, AsyncWebSocketClient* client, AwsEventType type, void* arg, uint8_t* data, size_t len); | ||
|
||
AsyncWebServer* _server; | ||
AsyncWebSocket _ws; | ||
|
||
uint32_t _lastWsCleanup = 0; | ||
uint32_t _lastUpdateCheck = 0; | ||
}; |
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.