Does any know if the Concentratord support pins above gpiochip0?
What I’m trying to do is run chipstack on a
SeeedStudio Gateway
with a custom image, as the gateway is not a opensource project I’m having to work thing out myself (support have been helpfully with some request).
I have two pin controlling the LoRa connect on this device:
Power/Enable: gpio0_22 (22)
LoRa_RST: gpio1_17 (49)
configuring up my globle.toml like:
# Concentratord configuration.
[concentratord]
# Log level.
# Valid options are:
# * TRACE
# * DEBUG
# * INFO
# * WARN
# * ERROR
# * OFF
log_level="DEBUG"
# Log to syslog.
# When set to true, log messages are being written to syslog instead of stdout.
log_to_syslog=true
# Statistics interval.
stats_interval="30s"
# Configuration for the (ZeroMQ based) API.
[concentratord.api]
# Event PUB socket bind.
event_bind="ipc:///tmp/concentratord_event"
# Command REP socket bind.
command_bind="ipc:///tmp/concentratord_command"
# LoRa gateway configuration.
[gateway]
# Antenna gain (dB).
antenna_gain=0
# Public LoRaWAN network.
lorawan_public=true
# Gateway vendor / model.
# This configures various vendor and model specific settings like the min / max
# frequency, TX gain table.
model="generic_au915"
# Gateway vendor / model flags.
model_flags=[]
# Gateway ID.
gateway_id="<my gateway id>"
# Reset pin.
# Note: most model configurations come with a pre-defined reset_pin, in which
# case the setting below will be ignored.
reset_pin=49
I get and error when running:
thread 'main' panicked at 'setup reset pin error: Error { kind: Offset(49) }', src/libcore/result.rs:1165:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
having a look through the concentratord source to try and work out what I should be doing I can across (and don’t know if it related or not), let mut chip = Chip::new("/dev/gpiochip0")?; in reset.rs
also of note I see power_en in this same file, where do we define what pin to use for power_en?
Regards,
Never programed rust before, but I gave it a hack and most likely missed a few things, but it not erroring out on offset anymore. Just need to get my SPI bus working and we will see.
This is what I came up with for reset.rs:
use std::sync::Mutex;
use std::thread::sleep;
use std::time::Duration;
use gpio_cdev::errors::Error;
use gpio_cdev::{Chip, LineHandle, LineRequestFlags};
use log::info;
// use modular::*;
lazy_static! {
static ref RESET: Mutex<Option<LineHandle>> = Mutex::new(None);
static ref POWER_EN: Mutex<Option<LineHandle>> = Mutex::new(None);
pub fn setup_pins(reset: u32, power_en: Option<u32>) -> Result<(), Error> {
let chip_number = (reset / 32) as i16;
// let reset_pin = (reset.to_modulo(32)) as i16;
let reset_pin = (((reset % 32) + 32) % 32) as i16;;
let mut chip = Chip::new(format!("/dev/gpiochip{}", chip_number))?;
info!("Configuring reset pin, pin: {}", reset_pin);
let line = chip.get_line(reset_pin)?;
let mut reset = RESET.lock().unwrap();
*reset = Some(line.request(LineRequestFlags::OUTPUT, 0, "reset")?);
if power_en.is_some() {
let power_en = power_en.unwrap();
info!("Configuring power enable pin, pin: {}", power_en);
let line = chip.get_line(power_en)?;
let mut power_en = POWER_EN.lock().unwrap();
*power_en = Some(line.request(LineRequestFlags::OUTPUT, 0, "power_en")?);
Ok(())
pub fn reset() -> Result<(), Error> {
let reset = RESET.lock().unwrap();
if reset.is_some() {
let reset = reset.as_ref().unwrap();
info!("Triggering concentrator reset");
reset.set_value(1)?;
sleep(Duration::from_millis(100));
reset.set_value(0)?;
sleep(Duration::from_millis(100));
let power_en = POWER_EN.lock().unwrap();
if power_en.is_some() {
let power_en = power_en.as_ref().unwrap();
info!("Enabling concentrator power");
power_en.set_value(1)?;
sleep(Duration::from_millis(100));
Ok(())
If you like, maybe it makes sense to add config options for the reset pin gpio chip numbers? In that case, please create an issue in the Concentratord repo 
Note that the power_en
is only used for the SX1302.
Add request to the repo https://github.com/brocaar/chirpstack-concentratord/issues/15#issue-796317194
Thanks for having a look.