main/task_ds18b20.h

Tue, 03 Oct 2023 17:24:06 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 03 Oct 2023 17:24:06 +0200
changeset 77
15dc572a7fcb
parent 44
e52d11b8f252
permissions
-rw-r--r--

Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.


/**
 * @file task_ds18b20.h
 * @brief The FreeRTOS task to query the DS18B20 sensors on one or two
 *        one-wire busses. Each bus must have only one sensor. That way
 *        we don't need to care about the DS18B20 internal ROM address.
 *        The task will update the DS18B20_State structure.
 */

#ifndef	_TASK_DS18B20_H
#define	_TASK_DS18B20_H

/*
 * Error codes in this task
 */
#define	DS18B20_ERR_NONE		0			///< No errors
#define	DS18B20_ERR_CRC			1			///< CRC read error
#define	DS18B20_ERR_READ		2			///< Generic read error

#define	DS18B20_MAX			4			///< Maximum number of DS18B20 sensors.

/**
 * @brief Structure for a temperature sensor.
 */
typedef struct strTempsensor {
    double      temperature;            	///< Current temperature.
    char        rom_code[17];           	///< ROM code of this device.
    int         error;                  	///< Error number.
} tempsensor_t;



/**
 * @brief Structure containing the variables for the DS18B20 task.
 */
typedef struct {
    bool		valid;			///< Sensor valid reading.
    int			num_sensors;		///< Number of sensors
    tempsensor_t	sensor[DS18B20_MAX];	///< Temperature sensors
} DS18B20_State;



/**
 * @brief Request a new measurement
 */
void request_ds18b20(void);


/**
 * @brief Measurement ready state
 * @return Returns true if the temperature measurements are ready
 */
bool ready_ds18b20(void);


/**
 * @brief The FreeRTOS task to update the DS18B20 temperature sensors on request.
 * @param pvParameters Parameters for the task.
 */
void task_ds18b20(void *pvParameters);


#endif

mercurial