mqtt_simple example adds TWI function

Hi:

It is normal when TWI is canceled.

When TWI is added, it is an error

These two functions:

int twi_init(void)
{
	for (size_t i = 0U; i < ARRAY_SIZE(slm_twi_dev); i++) {
		if (slm_twi_dev[i] != NULL && !device_is_ready(slm_twi_dev[i])) {
			return -ENODEV;
		}
	}
	return 0;
}

Call the above API location:

void expiry_function(struct k_timer *timer_id)
{
	LOG_INF("expiry function");
	twi_read();
}

void main(void)
{
	int err;
	uint32_t connect_attempt = 0;

	LOG_INF("The MQTT simple sample started");

#if defined(CONFIG_MQTT_LIB_TLS)
	err = certificates_provision();
	if (err != 0) {
		LOG_ERR("Failed to provision certificates");
		return;
	}
#endif /* defined(CONFIG_MQTT_LIB_TLS) */
	twi_init();
...

Source code:

7762.mqtt_simple.zip

Related