This started as porting for Arduino library in this post
it is a C++ library so I changed main.c to main.cpp and did the change as advised that post
extern "C" enum mgos_app_init_result mgos_app_init(void)
{
The rest of the functions in that was in the main.c stayed the same in main.cpp
now I’m getting this error
/data/fwbuild-volumes/2.14.0/apps/GardenSystem/esp32/build_contexts/build_ctx_076654842/src/main.cpp: In function 'void power_flow_timer_cb(void*)':
/data/fwbuild-volumes/2.14.0/apps/GardenSystem/esp32/build_contexts/build_ctx_076654842/src/main.cpp:132:72: sorry, unimplemented: non-trivial designated initializers not supported
struct mg_rpc_call_opts opts {.dst = mg_mk_str(MGOS_RPC_LOOPBACK_ADDR)};
^
/data/fwbuild-volumes/2.14.0/apps/GardenSystem/esp32/build_contexts/build_ctx_076654842/src/main.cpp:132:72: warning: missing initializer for member 'mg_rpc_call_opts::dst' [-Wmissing-field-initializers]
/data/fwbuild-volumes/2.14.0/apps/GardenSystem/esp32/build_contexts/build_ctx_076654842/src/main.cpp:132:72: warning: missing initializer for member 'mg_rpc_call_opts::tag' [-Wmissing-field-initializers]
/data/fwbuild-volumes/2.14.0/apps/GardenSystem/esp32/build_contexts/build_ctx_076654842/src/main.cpp:132:72: warning: missing initializer for member 'mg_rpc_call_opts::key' [-Wmissing-field-initializers]
/data/fwbuild-volumes/2.14.0/apps/GardenSystem/esp32/build_contexts/build_ctx_076654842/src/main.cpp:132:72: warning: missing initializer for member 'mg_rpc_call_opts::no_queue' [-Wmissing-field-initializers]
/data/fwbuild-volumes/2.14.0/apps/GardenSystem/esp32/build_contexts/build_ctx_076654842/src/main.cpp:132:72: warning: missing initializer for member 'mg_rpc_call_opts::broadcast' [-Wmissing-field-initializers]
/data/fwbuild-volumes/2.14.0/apps/GardenSystem/esp32/build_contexts/build_ctx_076654842/src/main.cpp: In function 'void call_health_cb(mg_rpc_request_info*, void*, mg_rpc_frame_info*, mg_str)':
/data/fwbuild-volumes/2.14.0/apps/GardenSystem/esp32/build_contexts/build_ctx_076654842/src/main.cpp:238:7: warning: unused variable 'res' [-Wunused-variable]
bool res = mgos_mqtt_pub(topic, message, strlen(message), 1, false);
which is referring to this function
static void power_flow_timer_cb(void *arg)
{
struct mg_rpc_call_opts opts {.dst = mg_mk_str(MGOS_RPC_LOOPBACK_ADDR)};
int sleep_time = mgos_sys_config_get_cct_scent_conf_sleep_cycle();
LOG(LL_INFO, ("Enter Power Flow Timer"));
mg_rpc_callf(mgos_rpc_get_global(), mg_mk_str("CCT.nodeHealth"), NULL, NULL, &opts,
"{}");
mg_rpc_callf(mgos_rpc_get_global(), mg_mk_str("Config.Save"), NULL, NULL, &opts,
"{reboot: false}");
for (int i = 0; i < 5; i++)
{
i++;
}
mg_rpc_callf(mgos_rpc_get_global(), mg_mk_str("CCT.espSleep"), NULL, NULL, &opts,
"{time: %d}", sleep_time);
(void)arg;
}
I understand its a related to the struct, but not sure how to deal with it after changing the main to c++, and the main reason it is used is to invoke a set or RPCs locally.
your guidance is appreciated.
Leo