Skip to content

Commit

Permalink
Implement get and set channel in cmt2300 wrapper class
Browse files Browse the repository at this point in the history
  • Loading branch information
tbnobody committed Apr 15, 2023
1 parent fffd872 commit 2a92f67
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
10 changes: 10 additions & 0 deletions lib/CMT2300a/cmt2300wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ bool CMT2300A::write(const uint8_t* buf, uint8_t len)
return true;
}

void CMT2300A::setChannel(uint8_t channel)
{
CMT2300A_SetFrequencyChannel(channel);
}

uint8_t CMT2300A::getChannel(void)
{
return CMT2300A_ReadReg(CMT2300A_CUS_FREQ_CHNL);
}

bool CMT2300A::setPALevel(int8_t level)
{
uint16_t Tx_dBm_word;
Expand Down
12 changes: 12 additions & 0 deletions lib/CMT2300a/cmt2300wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ class CMT2300A {

bool write(const uint8_t* buf, uint8_t len);

/**
* Set RF communication channel. The frequency used by a channel is
* @param channel Which RF channel to communicate on, 0-254
*/
void setChannel(uint8_t channel);

/**
* Get RF communication channel
* @return The currently configured RF Channel
*/
uint8_t getChannel(void);

bool setPALevel(int8_t level);

private:
Expand Down
4 changes: 1 addition & 3 deletions lib/Hoymiles/src/HoymilesRadio_CMT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ String HoymilesRadio_CMT::cmtChToFreq(const uint8_t channel)

void HoymilesRadio_CMT::cmtSwitchChannel(const uint8_t channel)
{
yield();
CMT2300A_SetFrequencyChannel(channel);
yield();
_radio->setChannel(channel);
cmtCurrentCh = channel;
}

Expand Down

0 comments on commit 2a92f67

Please sign in to comment.