2017-04-27 18:18:03 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2014-02-11 18:14:46 +00:00
|
|
|
#ifndef DEVICE_H
|
|
|
|
#define DEVICE_H
|
2013-01-09 20:07:09 +00:00
|
|
|
|
2019-08-05 17:41:15 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2013-04-01 10:51:49 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2019-08-05 17:41:15 +00:00
|
|
|
struct divecomputer;
|
2020-10-05 18:55:57 +00:00
|
|
|
struct device;
|
|
|
|
struct device_table;
|
2020-10-06 19:36:51 +00:00
|
|
|
struct dive_table;
|
2020-10-05 18:55:57 +00:00
|
|
|
|
|
|
|
// global device table
|
|
|
|
extern struct device_table device_table;
|
|
|
|
|
2018-05-05 17:26:48 +00:00
|
|
|
extern void fake_dc(struct divecomputer *dc);
|
2020-10-10 19:41:36 +00:00
|
|
|
extern void set_dc_deviceid(struct divecomputer *dc, unsigned int deviceid, const struct device_table *table);
|
|
|
|
|
|
|
|
extern void set_dc_nickname(struct dive *dive, struct device_table *table);
|
|
|
|
extern void create_device_node(struct device_table *table, const char *model, uint32_t deviceid, const char *serial, const char *firmware, const char *nickname);
|
2020-10-05 18:55:57 +00:00
|
|
|
extern int nr_devices(const struct device_table *table);
|
|
|
|
extern const struct device *get_device(const struct device_table *table, int i);
|
2020-10-17 11:28:05 +00:00
|
|
|
extern void clear_device_table(struct device_table *table);
|
2020-10-05 07:56:21 +00:00
|
|
|
const char *get_dc_nickname(const struct divecomputer *dc);
|
2020-10-06 19:36:51 +00:00
|
|
|
extern bool device_used_by_selected_dive(const struct device *dev);
|
2020-10-05 19:12:49 +00:00
|
|
|
|
|
|
|
extern const struct device *get_device_for_dc(const struct device_table *table, const struct divecomputer *dc);
|
2020-10-17 12:01:52 +00:00
|
|
|
extern bool device_exists(const struct device_table *table, const struct device *dev);
|
|
|
|
extern void add_to_device_table(struct device_table *table, const struct device *dev);
|
|
|
|
extern void remove_device(struct device_table *table, const struct device *dev);
|
2013-01-09 20:07:09 +00:00
|
|
|
|
2020-10-05 18:55:57 +00:00
|
|
|
// struct device accessors for C-code. The returned strings are not stable!
|
|
|
|
const char *device_get_model(const struct device *dev);
|
|
|
|
const uint32_t device_get_id(const struct device *dev);
|
|
|
|
const char *device_get_serial(const struct device *dev);
|
|
|
|
const char *device_get_firmware(const struct device *dev);
|
|
|
|
const char *device_get_nickname(const struct device *dev);
|
|
|
|
|
2013-04-01 10:51:49 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2020-09-13 17:08:41 +00:00
|
|
|
// Functions and global variables that are only available to C++ code
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
2020-10-05 07:56:21 +00:00
|
|
|
#include <string>
|
2020-10-05 08:12:12 +00:00
|
|
|
#include <vector>
|
2020-10-03 09:18:42 +00:00
|
|
|
struct device {
|
2020-10-05 19:28:26 +00:00
|
|
|
bool operator==(const device &a) const; // TODO: remove, once devices are integrated in the undo system
|
2020-10-03 09:18:42 +00:00
|
|
|
bool operator<(const device &a) const;
|
2020-10-05 07:56:21 +00:00
|
|
|
void showchanges(const std::string &n, const std::string &s, const std::string &f) const;
|
|
|
|
std::string model;
|
2020-09-13 17:08:41 +00:00
|
|
|
uint32_t deviceId;
|
2020-10-05 07:56:21 +00:00
|
|
|
std::string serialNumber;
|
|
|
|
std::string firmware;
|
|
|
|
std::string nickName;
|
2020-09-13 17:08:41 +00:00
|
|
|
};
|
|
|
|
|
2020-10-03 09:18:42 +00:00
|
|
|
struct device_table {
|
2020-09-13 17:08:41 +00:00
|
|
|
// Keep the dive computers in a vector sorted by (model, deviceId)
|
2020-10-05 08:12:12 +00:00
|
|
|
std::vector<device> devices;
|
2020-09-13 17:08:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2014-02-11 18:14:46 +00:00
|
|
|
#endif // DEVICE_H
|