16 const auto& cmd = args[0];
21 encoder.
write(sensors);
23 transport.
send(
reinterpret_cast<const char*
>(encoder.
data()), encoder.
size());
29 bool called_by_event =
false) {
31 const auto& cmd = args[0];
32 const size_t sensor_id = std::atoi(args[1].c_str());
33 const size_t enable = std::atoi(args[2].c_str());
34 const size_t opt_id = std::atoi(args[3].c_str());
39 auto it = std::find_if(sensors.begin(), sensors.end(), [&](
const Sensor* s) { return s->getID() == sensor_id; });
40 if (it == sensors.end()) {
45 switch ((*it)->getType()) {
47 auto* camera =
static_cast<Camera*
>(*it);
52 ret = camera->init(opt_id);
69 if (!called_by_event) {
77 if (it != sensors.end()) {
78 encoder.
write(*it, (*it)->currentPresetIdx());
81 transport.
send(
reinterpret_cast<const char*
>(encoder.
data()), encoder.
size());
90 if (!transport || !*transport) {
101 std::vector<std::string> args{
102 "INIT@SENSOR", std::to_string(
static_cast<int>(sensor_id)),
"1", std::to_string(
static_cast<int>(opt_id))};
108 const auto& cmd = args[0];
113 auto it = std::find_if(sensors.begin(), sensors.end(), [&](
const Sensor* s) {
114 return s->getID() == static_resource->current_sensor_id;
116 if (it == sensors.end()) {
121 if (it != sensors.end()) {
122 encoder.
write(*it, (*it)->currentPresetIdx());
125 transport.
send(
reinterpret_cast<const char*
>(encoder.
data()), encoder.
size());
Definition: ma_camera.h:13
Definition: ma_codec_base.h:14
virtual ma_err_t end()=0
Encoder type for end.
virtual const void * data() const =0
Encoder type for get data.
virtual ma_err_t begin()=0
Encoder type for begin.
virtual ma_err_t write(const std::string &key, int8_t value)=0
Encoder type for write int8_t value.
virtual const size_t size() const =0
Encoder type for get size.
Definition: ma_sensor.h:12
virtual void deInit() noexcept=0
Definition: ma_transport.h:12
virtual size_t send(const char *data, size_t length) noexcept=0
#define MA_LOGD(TAG,...)
Definition: ma_debug.h:79
#define MA_ASSERT(expr)
Definition: ma_debug.h:119
#define MA_TAG
Definition: ma_debug.h:9
#define MA_STORAGE_KEY_SENSOR_OPT_ID
Definition: ma_definations.h:23
#define MA_STORAGE_KEY_SENSOR_ID
Definition: ma_definations.h:22
@ MA_MSG_TYPE_RESP
Definition: ma_types.h:252
ma_err_t
Definition: ma_types.h:21
@ MA_ENOENT
Definition: ma_types.h:33
@ MA_OK
Definition: ma_types.h:23
Definition: algorithm.hpp:11
void initDefaultSensor(Encoder &encoder)
Definition: sensor.hpp:84
void getSensorStatus(const std::vector< std::string > &args, Transport &transport, Encoder &encoder)
Definition: sensor.hpp:106
void configureSensor(const std::vector< std::string > &args, Transport &transport, Encoder &encoder, bool called_by_event=false)
Definition: sensor.hpp:26
void getAvailableSensors(const std::vector< std::string > &args, Transport &transport, Encoder &encoder)
Definition: sensor.hpp:14
#define static_resource
Definition: resource.hpp:64