Skip to content

Commit

Permalink
Implement HoymilesRadio_CMT
Browse files Browse the repository at this point in the history
  • Loading branch information
tbnobody committed Apr 15, 2023
1 parent 8927b83 commit 90c689a
Show file tree
Hide file tree
Showing 7 changed files with 693 additions and 193 deletions.
290 changes: 101 additions & 189 deletions lib/CMT2300a/cmt2300a_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,212 +4,124 @@
#include "cmt2300a_defs.h"
#include <stdint.h>

/* [CMT Bank] */
static uint8_t g_cmt2300aCmtBank_default[CMT2300A_CMT_BANK_SIZE] = {
0x00,
0x66,
0xEC,
0x1D,
0x70,
0x80,
0x14,
0x08,
0x91,
0x02,
0x02,
0xD0,
};

/* [CMT Bank] with RSSI offset of +- 0 and 13dBm*/
static uint8_t g_cmt2300aCmtBank_RSSI_0[CMT2300A_CMT_BANK_SIZE] = {
0x00,
0x66,
0xEC,
0x1C,
0x70,
0x80,
0x14,
0x08,
0x11,
0x02,
0x02,
0x00,
/* [CMT Bank] with RSSI offset of +- 0 (and 13dBm) */
static uint8_t g_cmt2300aCmtBank[CMT2300A_CMT_BANK_SIZE] = {
0x00,
0x66,
0xEC,
0x1C,
0x70,
0x80,
0x14,
0x08,
0x11,
0x02,
0x02,
0x00,
};

/* [System Bank] */
static uint8_t g_cmt2300aSystemBank[CMT2300A_SYSTEM_BANK_SIZE] = {
0xAE,
0xE0,
0x35,
0x00,
0x00,
0xF4,
0x10,
0xE2,
0x42,
0x20,
0x0C,
0x81,
};

/* [Frequency Bank] 868 MHz (default) */
static uint8_t g_cmt2300aFrequencyBank_868[CMT2300A_FREQUENCY_BANK_SIZE] = {
0x42,
0xCF,
0xA7,
0x8C,
0x42,
0xC4,
0x4E,
0x1C,
};

/* [Frequency Bank] 863 MHz (EU) */
static uint8_t g_cmt2300aFrequencyBank_863[CMT2300A_FREQUENCY_BANK_SIZE] = {
0x42,
0x6D,
0x80,
0x86,
0x42,
0x62,
0x27,
0x16,
0xAE,
0xE0,
0x35,
0x00,
0x00,
0xF4,
0x10,
0xE2,
0x42,
0x20,
0x0C,
0x81,
};

/* [Frequency Bank] 860 MHz */
static uint8_t g_cmt2300aFrequencyBank_860[CMT2300A_FREQUENCY_BANK_SIZE] = {
0x42,
0x32,
0xCF,
0x82,
0x42,
0x27,
0x76,
0x12,
static uint8_t g_cmt2300aFrequencyBank[CMT2300A_FREQUENCY_BANK_SIZE] = {
0x42,
0x32,
0xCF,
0x82,
0x42,
0x27,
0x76,
0x12,
};

/* [Data Rate Bank] */
static uint8_t g_cmt2300aDataRateBank[CMT2300A_DATA_RATE_BANK_SIZE] = {
0xA6,
0xC9,
0x20,
0x20,
0xD2,
0x35,
0x0C,
0x0A,
0x9F,
0x4B,
0x29,
0x29,
0xC0,
0x14,
0x05,
0x53,
0x10,
0x00,
0xB4,
0x00,
0x00,
0x01,
0x00,
0x00,
};

/* [Baseband Bank] - default */
static uint8_t g_cmt2300aBasebandBank_default[CMT2300A_BASEBAND_BANK_SIZE] = {
0x12,
0x1E,
0x00,
0xAA,
0x06,
0x00,
0x00,
0x00,
0x00,
0xD6,
0xD5,
0xD4,
0x2D,
0x01,
0x1F,
0x00,
0x00,
0x00,
0x00,
0x00,
0xC3,
0x00,
0x00,
0x60,
0xFF,
0x00,
0x00,
0x1F,
0x10,
0xA6,
0xC9,
0x20,
0x20,
0xD2,
0x35,
0x0C,
0x0A,
0x9F,
0x4B,
0x29,
0x29,
0xC0,
0x14,
0x05,
0x53,
0x10,
0x00,
0xB4,
0x00,
0x00,
0x01,
0x00,
0x00,
};

/* [Baseband Bank] - EU */
static uint8_t g_cmt2300aBasebandBank_EU[CMT2300A_BASEBAND_BANK_SIZE] = {
0x12,
0x1E,
0x00,
0xAA,
0x06,
0x00,
0x00,
0x00,
0x00,
0x48,
0x5A,
0x48,
0x4D,
0x01,
0x1D, // default should be 0x1F (32 bytes length), but 0x45 is 0x01 -> variable length, so this value is ignored
0x00,
0x00,
0x00,
0x00,
0x00,
0xC3,
0x00,
0x00,
0x60,
0xFF,
0x00,
0x00,
0x1F,
0x10,
};

/* [Tx Bank] 20 dBm */
static uint8_t g_cmt2300aTxBank_20dBm[CMT2300A_TX_BANK_SIZE] = {
0x70,
0x4D,
0x06,
0x00,
0x07,
0x50,
0x00,
0x8A,
0x18,
0x3F,
0x7F,
static uint8_t g_cmt2300aBasebandBank[CMT2300A_BASEBAND_BANK_SIZE] = {
0x12,
0x1E,
0x00,
0xAA,
0x06,
0x00,
0x00,
0x00,
0x00,
0x48,
0x5A,
0x48,
0x4D,
0x01,
0x1F,
0x00,
0x00,
0x00,
0x00,
0x00,
0xC3,
0x00,
0x00,
0x60,
0xFF,
0x00,
0x00,
0x1F,
0x10,
};

/* [Tx Bank] 13 dBm */
static uint8_t g_cmt2300aTxBank_13dBm[CMT2300A_TX_BANK_SIZE] = {
0x70,
0x4D,
0x06,
0x00,
0x07,
0x50,
0x00,
0x42,
0x0C,
0x3F,
0x7F,
static uint8_t g_cmt2300aTxBank[CMT2300A_TX_BANK_SIZE] = {
0x70,
0x4D,
0x06,
0x00,
0x07,
0x50,
0x00,
0x42,
0x0C,
0x3F,
0x7F,
};

#endif
12 changes: 8 additions & 4 deletions lib/Hoymiles/src/Hoymiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,22 @@ void HoymilesClass::init(SPIClass* initialisedSpiBus, uint8_t pinCE, uint8_t pin
_pollInterval = 0;
_radioNrf.reset(new HoymilesRadio_NRF());
_radioNrf->init(initialisedSpiBus, pinCE, pinIRQ);

_radioCmt.reset(new HoymilesRadio_CMT());
_radioCmt->init();
}

void HoymilesClass::loop()
{
HOY_SEMAPHORE_TAKE();
_radioNrf->loop();
_radioCmt->loop();

if (getNumInverters() > 0) {
if (millis() - _lastPoll > (_pollInterval * 1000)) {
static uint8_t inverterPos = 0;

if (_radioNrf->isIdle()) {
if (_radioNrf->isIdle() && _radioCmt->isIdle()) {
std::shared_ptr<InverterAbstract> iv = getInverterByPos(inverterPos);
if (iv != nullptr) {
_messageOutput->print("Fetch inverter: ");
Expand Down Expand Up @@ -89,11 +93,11 @@ std::shared_ptr<InverterAbstract> HoymilesClass::addInverter(const char* name, u
{
std::shared_ptr<InverterAbstract> i = nullptr;
if (HMS_4CH::isValidSerial(serial)) {
i = std::make_shared<HMS_4CH>(_radioNrf.get(), serial);
i = std::make_shared<HMS_4CH>(_radioCmt.get(), serial);
} else if (HMS_2CH::isValidSerial(serial)) {
i = std::make_shared<HMS_2CH>(_radioNrf.get(), serial);
i = std::make_shared<HMS_2CH>(_radioCmt.get(), serial);
} else if (HMS_1CH::isValidSerial(serial)) {
i = std::make_shared<HMS_1CH>(_radioNrf.get(), serial);
i = std::make_shared<HMS_1CH>(_radioCmt.get(), serial);
} else if (HM_4CH::isValidSerial(serial)) {
i = std::make_shared<HM_4CH>(_radioNrf.get(), serial);
} else if (HM_2CH::isValidSerial(serial)) {
Expand Down
2 changes: 2 additions & 0 deletions lib/Hoymiles/src/Hoymiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#pragma once

#include "HoymilesRadio_NRF.h"
#include "HoymilesRadio_CMT.h"
#include "inverters/InverterAbstract.h"
#include "types.h"
#include <Print.h>
Expand Down Expand Up @@ -35,6 +36,7 @@ class HoymilesClass {
private:
std::vector<std::shared_ptr<InverterAbstract>> _inverters;
std::unique_ptr<HoymilesRadio_NRF> _radioNrf;
std::unique_ptr<HoymilesRadio_CMT> _radioCmt;

SemaphoreHandle_t _xSemaphore;

Expand Down
Loading

0 comments on commit 90c689a

Please sign in to comment.