// HalConfig.h
#ifndef _HalConfig_h_
#define _HalConfig_h_
#include <arduino_lmic_hal_configuration.h>
class MyHalConfig_t : public Arduino_LMIC::HalConfiguration_t {
public:
MyHalConfig_t();
virtual TxPowerPolicy_t getTxPowerPolicy (TxPowerPolicy_t policy, int8_t requestedPower, uint32_t frequency) override;
};
#endif
// HalConfig.cpp
#include <arduino_lmic_hal_configuration.h>
#include "HalConfig.h"
#include "Boards.h"
#define LMIC_FORCE_POWER_POLICY Arduino_LMIC::HalConfiguration_t::TxPowerPolicy_t::RFO
// Init
MyHalConfig_t::MyHalConfig_t(){};
// Override getTxPowerPolicy
Arduino_LMIC::HalConfiguration_t::TxPowerPolicy_t MyHalConfig_t::getTxPowerPolicy (
Arduino_LMIC::HalConfiguration_t::TxPowerPolicy_t policy,
int8_t requestedPower,
uint32_t frequency
) {
LMIC_API_PARAMETER(policy);
LMIC_API_PARAMETER(requestedPower);
LMIC_API_PARAMETER(frequency);
#ifdef LMIC_FORCE_POWER_POLICY
return LMIC_FORCE_POWER_POLICY;
#endif
// default: use PA_BOOST exclusively
return Arduino_LMIC::HalConfiguration_t::TxPowerPolicy_t::PA_BOOST;
};
#pragma once
#ifndef BSF_SBC_OLIMEX_V1
#define BSF_SBC_OLIMEX_V1
#include "config.h" // from packages/toolchain-xtensa-esp32
#include "LMIC-node.h"
#define DEVICEID_DEFAULT "sbc-olimex-v1" // Default deviceid value
#ifndef LMIC_CLOCK_ERROR_PPM
#define LMIC_CLOCK_ERROR_PPM 0
#endif
// https://forum.mcci.io/t/olimex-mod-lora868/264/2
#include "HalConfig.h"
static MyHalConfig_t myHalConfig{};
const lmic_pinmap lmic_pins = {
.nss = 5,
.rxtx = LMIC_UNUSED_PIN,
.rst = 21,
.dio = {26, 33, 32},
.rxtx_rx_active = 0,
.rssi_cal = 10,
.spi_freq = 8000000,
.pConfig = &myHalConfig
};
// nothing changed after this.
[platformio]
default_envs =
sbc_olimex_v1 ;added new
[common]
lib_deps =
olikraus/U8g2 ;even if there is no oled. make sure it is included. Otherwise i got compiling errors - OLED display library
[esp32]
build_flags =
-D hal_init=LMICHAL_init
[env:sbc_olimex_v1]
platform = espressif32
board = upesy_wroom
framework = arduino
upload_speed = 921600
monitor_speed = ${common.monitor_speed}
lib_deps =
${common.lib_deps}
${mcci_lmic.lib_deps}
build_flags =
${common.build_flags}
${esp32.build_flags}
${mcci_lmic.build_flags}
-D BSFILE=\"boards/sbc_olimex_v1.h\"
-D MONITOR_SPEED=${common.monitor_speed}
-D LMIC_PRINTF_TO=Serial
-D USE_SERIAL
QuoteYou need to power down the board, close jumper PROG, power up the board then issue the change address command, then power down the board, then open the jumper PROG and finally power and check new address.
QuoteAre you sure it is on I2C port 1? It can be I2C 0 or 2?
QuoteSure you can try modio2tool, there is explanation on how to compile and use:
https://github.com/OLIMEX/OLINUXINO/tree/master/SOFTWARE/UEXT%20MODULES/MOD-IO2/linux-access-tool
# chmod a+x ./modio2tool
# ./modio2tool
bash: ./modio2tool: No such file or directory
#define SET_ADDRESS 0xF0
i2cset 2 0x21 0xHH
i2cset 2 0x21 0xF0 0xHH