_is_remote(false), _is_calculated(false), _tech(TECH_UNKNOWN),
_last_update(std::chrono::steady_clock::now()) {};
- Node(unsigned long long distance, int pan_id, unsigned long long node_id,
- int x, int y, int z, bool is_remote, bool is_calculated, int tech) :
- _distance(distance), _pan_id(pan_id), _node_id(node_id),
- _x(x), _y(y), _z(z), _is_remote(is_remote), _is_calculated(is_calculated),
- _tech(tech), _last_update(std::chrono::steady_clock::now()) {};
-
Node(uwb_hpi_node_s *node) :
_distance(node->distance), _pan_id(node->pan_id), _node_id(node->node_id),
_x(node->x), _y(node->y), _z(node->z), _is_remote(node->is_remote),
_is_calculated(false), _tech(TECH_UWB),
_last_update(std::chrono::steady_clock::now()){};
- Node(const Node *node) {
- _distance = node->_distance;
- _pan_id = node->_pan_id;
- _node_id = node->_node_id;
- _x = node->_x;
- _y = node->_y;
- _z = node->_z;
- _is_remote = node->_is_remote;
- _is_calculated = node->_is_calculated;
- _tech = node->_tech;
- _last_update = node->_last_update;
- }
+
+ Node(Node *node) :
+ _distance(node->_distance), _pan_id(node->_pan_id), _node_id(node->_node_id),
+ _x(node->_x), _y(node->_y), _z(node->_z), _is_remote(node->_is_remote),
+ _is_calculated(node->_is_calculated), _tech(node->_tech),
+ _last_update(node->_last_update){};
//~Node(){UWB_LOGI("%llu removed", _node_id);}
Node(const Node &node) = default;
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include <utility>
#include <uwb-log-def.h>
#include <uwb-error-def.h>
return TRUE;
}
-typedef gboolean (*method_handler)(
- UwbGdbuslibManager *gdbus_manager,
- GDBusMethodInvocation *invocation,
- gpointer user_data);
+static std::pair<std::string, void *> handlers[] = {
+ std::make_pair(std::string{"handle-test"}, (void *)__handle_test),
+ std::make_pair(std::string{"handle-reset"}, (void *)__handle_reset),
+ std::make_pair(std::string{"handle-factory-reset"}, (void *)__handle_factory_reset),
-static struct {
- const char *method_name;
- //trick
- void * handler;
-} handlers[] = {
- {"handle-test", (void *)__handle_test},
- {"handle-reset", (void *)__handle_reset},
- {"handle-factory-reset", (void *)__handle_factory_reset},
+ std::make_pair(std::string{"handle-enable-network"}, (void *)__handle_enable_network),
+ std::make_pair(std::string{"handle-disable-network"}, (void *)__handle_disable_network),
- {"handle-enable-network", (void *)__handle_enable_network},
- {"handle-disable-network", (void *)__handle_disable_network},
+ std::make_pair(std::string{"handle-start-location-engine"}, (void *)__handle_start_location_engine),
+ std::make_pair(std::string{"handle-stop-location-engine"}, (void *)__handle_stop_location_engine),
- {"handle-start-location-engine", (void *)__handle_start_location_engine},
- {"handle-stop-location-engine", (void *)__handle_stop_location_engine},
+ std::make_pair(std::string{"handle-get-own-node"}, (void *)__handle_get_own_node),
+ std::make_pair(std::string{"handle-get-network-info"}, (void *)__handle_get_network_info),
- {"handle-get-own-node", (void *)__handle_get_own_node},
- {"handle-get-network-info", (void *)__handle_get_network_info},
+ std::make_pair(std::string{"handle-set-configurations"}, (void *)__handle_set_configurations),
+ std::make_pair(std::string{"handle-get-configurations"}, (void *)__handle_get_configurations),
- {"handle-set-configurations", (void *)__handle_set_configurations},
- {"handle-get-configurations", (void *)__handle_get_configurations},
+ std::make_pair(std::string{"handle-set-position"}, (void *)__handle_set_position),
- {"handle-set-position", (void *)__handle_set_position},
-
- {"handle-send-message", (void *)__handle_send_message},
- {"handle-send-message-to", (void *)__handle_send_message_to}
+ std::make_pair(std::string{"handle-send-message"}, (void *)__handle_send_message),
+ std::make_pair(std::string{"handle-send-message-to"}, (void *)__handle_send_message_to)
};
void UwbDbusIfaceAdapter::init(GDBusConnection *connection,
for (const auto &handler : handlers)
g_signal_connect(
manager_skeleton,
- handler.method_name,
- G_CALLBACK(handler.handler),
+ handler.first.c_str(),
+ G_CALLBACK(handler.second),
gpointer(this));
/* Set connection to 'manager' */