+int sensor_manager::serialize(sensor_info *info, char **bytes)
+{
+ int size;
+ raw_data_t *raw = new(std::nothrow) raw_data_t;
+ retvm_if(!raw, -ENOMEM, "Failed to allocated memory");
+
+ info->serialize(*raw);
+
+ *bytes = new(std::nothrow) char[raw->size()];
+ retvm_if(!*bytes, -ENOMEM, "Failed to allocate memory");
+
+ std::copy(raw->begin(), raw->end(), *bytes);
+
+ size = raw->size();
+ delete raw;
+
+ return size;
+}
+
+void sensor_manager::send(ipc::message &msg)
+{
+ for (auto it = m_channels.begin(); it != m_channels.end(); ++it)
+ (*it)->send_sync(&msg);
+}
+
+void sensor_manager::send_added_msg(sensor_info *info)
+{
+ char *bytes;
+ int size;
+
+ size = serialize(info, &bytes);
+
+ ipc::message msg((const char *)bytes, size);
+ msg.set_type(CMD_MANAGER_SENSOR_ADDED);
+
+ send(msg);
+}
+
+void sensor_manager::send_removed_msg(const std::string &uri)
+{
+ ipc::message msg;
+ msg.set_type(CMD_MANAGER_SENSOR_REMOVED);
+ msg.enclose(uri.c_str(), uri.size());
+
+ send(msg);
+}
+