RUI i2c at-command

Hi colleagues,
I think, there is an error in https://github.com/RAKWireless/Products_practice_based_on_RUI,
all files lora_config.c
Line 480
rui_return_status = rui_i2c_rw(&I2c_temp,RUI_IF_WRITE,strtoul(argv[2],0,16),(uint16_t)strtoul(argv[3],0,16),i2c_data,(uint16_t)atoi(argv[4]));

shoul be
rui_return_status = rui_i2c_rw(&I2c_temp,RUI_IF_WRITE,strtoul(argv[2],0,16),(uint16_t)strtoul(argv[3],0,16),i2c_data, app_len);

The last parameter for rui_i2c_rw() should be length, what is in this write case length of user data.

Am I wrong ?
Thx Ant

Hi @Hofmann,

You’re right.

The prototype of the rui_i2c_rw can be seen in the link below.
https://github.com/RAKWireless/Products_practice_based_on_RUI/blob/master/common%20header/rui.h , line528.

In lora_config.c, the length of user data is obtained from the parameters (argv[x]) of the AT command.

Hi Sucre,
thanks for info, can you help me more please.

I cannot make the i2C run, rui_i2c_rw() always returns me RUI_STATUS_IIC_RW_ERROR.
I am not sure if HW/SW error. Is there any possibilities to get more info, diagnostics, etc.
How can I find the issue?
Thx Ant

// SHTC3
#define I2C_SDA 10 // RAK 4200
#define I2C_SCL 9
#define SHTC3_ADDR 0x70

RUI_I2C_ST rui_i2c;

void SHTC3_init(void)
{
rui_i2c.INSTANCE_ID = 1;
/*
rui_i2c.FREQUENCY = RUI_I2C_FREQ_100K;
rui_i2c.PIN_SDA = I2C_SDA;
rui_i2c.PIN_SCL = I2C_SCL;
rui_i2c.REG_NULL = I2C_REG_MAGIC;

int err = rui_i2c_init(&rui_i2c);
*/

int SHTC3_GetStatus()
{
uint8_t buffer[4] = { 0 };

// instance, Read, DeviceAddr, RegisterAddr, buf, len
RUI_RETURN_STATUS status = rui_i2c_rw(&rui_i2c, RUI_IF_READ, SHTC3_ADDR, 0xEFC8, buffer, 3); // 0xEFC8 is GetId cmd

if (status == RUI_STATUS_OK)
{
	RUI_LOG_PRINTF("SHTC3_GetStatus OK %02X %02X %02X\r\n", buffer[0], buffer[1], buffer[2]);
}
else
{
	RUI_LOG_PRINTF("SHTC3_GetStatus ERR:%d", status);
}

return status == RUI_STATUS_OK;

}