janderkan Well-Known Member Licensed User Longtime User Jul 30, 2018 #1 In RH_RF95.h is this struct B4X: typedef struct { uint8_t reg_1d; ///< Value for register RH_RF95_REG_1D_MODEM_CONFIG1 uint8_t reg_1e; ///< Value for register RH_RF95_REG_1E_MODEM_CONFIG2 uint8_t reg_26; ///< Value for register RH_RF95_REG_26_MODEM_CONFIG3 } ModemConfig; and this function B4X: void setModemRegisters(const ModemConfig* config); I have tried with this wrap B4X: void RF95::SetModemRegisters(byte Reg_1D, byte Reg_1E, Byte Reg26) { const RH_RF95->ModemConfig mc; mc.reg_1d = Reg_1D; mc.reg_1e = Reg_1D; mc.reg_26 = Reg26; rf95->setModemRegisters(mc); } but I cannot figure out how to do it.
In RH_RF95.h is this struct B4X: typedef struct { uint8_t reg_1d; ///< Value for register RH_RF95_REG_1D_MODEM_CONFIG1 uint8_t reg_1e; ///< Value for register RH_RF95_REG_1E_MODEM_CONFIG2 uint8_t reg_26; ///< Value for register RH_RF95_REG_26_MODEM_CONFIG3 } ModemConfig; and this function B4X: void setModemRegisters(const ModemConfig* config); I have tried with this wrap B4X: void RF95::SetModemRegisters(byte Reg_1D, byte Reg_1E, Byte Reg26) { const RH_RF95->ModemConfig mc; mc.reg_1d = Reg_1D; mc.reg_1e = Reg_1D; mc.reg_26 = Reg26; rf95->setModemRegisters(mc); } but I cannot figure out how to do it.
Erel B4X founder Staff member Licensed User Longtime User Jul 31, 2018 #2 Which error do you get? Shouldn't it be: B4X: ModemConfig mc; mc.reg_1d = Reg_1D; mc.reg_1e = Reg_1E; mc.reg_26 = Reg26; rf95->setModemRegisters(mc); ? There is a typo in your code. You missed Reg_1E.
Which error do you get? Shouldn't it be: B4X: ModemConfig mc; mc.reg_1d = Reg_1D; mc.reg_1e = Reg_1E; mc.reg_26 = Reg26; rf95->setModemRegisters(mc); ? There is a typo in your code. You missed Reg_1E.
janderkan Well-Known Member Licensed User Longtime User Jul 31, 2018 #3 It always help if you go to bed, next morning everything is easier. B4X: void RF95::SetModemRegisters(byte Reg_1D, byte Reg_1E, Byte Reg26) { RH_RF95::ModemConfig mc; mc.reg_1d = Reg_1D; mc.reg_1e = Reg_1E; mc.reg_26 = Reg26; rf95->setModemRegisters(&mc); } There was 3 errors. To reference a typedef struct, use the :: Error when cut and paste The function needs a pointer to the config &mc
It always help if you go to bed, next morning everything is easier. B4X: void RF95::SetModemRegisters(byte Reg_1D, byte Reg_1E, Byte Reg26) { RH_RF95::ModemConfig mc; mc.reg_1d = Reg_1D; mc.reg_1e = Reg_1E; mc.reg_26 = Reg26; rf95->setModemRegisters(&mc); } There was 3 errors. To reference a typedef struct, use the :: Error when cut and paste The function needs a pointer to the config &mc