1#include <sensors/sensor.h>
2#include <sensors/sensor_command.h>
3#include <platform-header.h>
24void sensor_com_list(
struct command *com) {
25 if (!sensors_inited()) {
33 if (!all_sensors_probed()) {
43 while (((sd = &
sensors[t])->power_on) != NULL) {
56 dcom->
flags = COMFLAGS_DATA | COMFLAGS_SUCCESS;
70void sensor_com_config(
struct command *com) {
72 printf(
"inv sensor config command argctr==%i\r\n", com->
argctr);
76 long idx = ascii_parse_hex((
const byte *)
get_arg(com, 0), 8, NULL);
79 printf(
"invalid sensor 0\r\n");
86 long activate = ascii_parse_hex((
const byte *)
get_arg(com, 1), 8, NULL);
87 long poll_frequency = ascii_parse_hex((
const byte *)
get_arg(com, 2), 8, NULL);
88 long report_frequency = ascii_parse_hex((
const byte *)
get_arg(com, 3), 8, NULL);
90 printf(
"[sensor] config: Sensor %i (%s) activate: %i, poll_frequency: %i, report_frequency: %i\r\n", idx, sdf->name, activate, poll_frequency, report_frequency);
91 int r = sensor_update_config(com->
sender, idx - 1, poll_frequency, report_frequency, 100);
95 snprintf(e, 99,
"err=failed to update config (errorcode=%i)", r);
99 sensor_activation(sr, activate);
int send_command_reply_with_args(struct command *com, byte flags, const char *format,...)
send a reply to a command
int send_command(struct command *com)
send a command to another module (or broadcast)
void free_command(struct command *com)
free a command
void command_add_arg(struct command *com, const char *format,...)
adds an arg to a partially initialised command structure
struct sensordev sensors[]
list of sensors...
int send_command_reply(struct command *com, byte flags)
send a reply to a command
void command_init(struct command *com)
initialize a command structure with default values
void sensors_newstyle()
enable new-style sensors (and disable old)
struct command * alloc_command()
allocate a free command
const char * get_arg(const struct command *com, int index)
given an argument by index[0..n], will return a pointer to the bytearray (excluding the fieldtype) th...
runtime data per sensor (in-ram)