mirror of git://git.sysmocom.de/ofono
ublox: create model data structures
This sets up some device model data structures and adds some helpers for manipulating them. These data structures are a first step to trying to support the large number of devices that ublox produces with a common driver structure.
This commit is contained in:
parent
55bec598b6
commit
d7844183c0
|
@ -23,6 +23,8 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <gatchat.h>
|
#include <gatchat.h>
|
||||||
|
|
||||||
|
@ -33,6 +35,61 @@
|
||||||
|
|
||||||
#include "ubloxmodem.h"
|
#include "ubloxmodem.h"
|
||||||
|
|
||||||
|
const struct ublox_model ublox_models[] = {
|
||||||
|
{
|
||||||
|
.name = "SARA-G270",
|
||||||
|
},
|
||||||
|
/* TOBY L2 series */
|
||||||
|
{
|
||||||
|
.name = "TOBY-L200",
|
||||||
|
.flags = UBLOX_F_TOBY_L2,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "TOBY-L201",
|
||||||
|
.flags = UBLOX_F_TOBY_L2,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "TOBY-L210",
|
||||||
|
.flags = UBLOX_F_TOBY_L2,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "TOBY-L220",
|
||||||
|
.flags = UBLOX_F_TOBY_L2,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "TOBY-L280",
|
||||||
|
.flags = UBLOX_F_TOBY_L2,
|
||||||
|
},
|
||||||
|
{ /* sentinel */ },
|
||||||
|
};
|
||||||
|
|
||||||
|
const struct ublox_model *ublox_model_from_name(const char *name)
|
||||||
|
{
|
||||||
|
const struct ublox_model *m;
|
||||||
|
|
||||||
|
for (m = ublox_models; m->name; m++) {
|
||||||
|
if (!strcmp(name, m->name))
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
const struct ublox_model *ublox_model_from_id(int id)
|
||||||
|
{
|
||||||
|
return ublox_models + id;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ublox_model_to_id(const struct ublox_model *model)
|
||||||
|
{
|
||||||
|
return model - ublox_models;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ublox_is_toby_l2(const struct ublox_model *model)
|
||||||
|
{
|
||||||
|
return model->flags & UBLOX_F_TOBY_L2;
|
||||||
|
}
|
||||||
|
|
||||||
static int ubloxmodem_init(void)
|
static int ubloxmodem_init(void)
|
||||||
{
|
{
|
||||||
ublox_gprs_context_init();
|
ublox_gprs_context_init();
|
||||||
|
|
|
@ -23,6 +23,20 @@
|
||||||
|
|
||||||
#define UBLOXMODEM "ubloxmodem"
|
#define UBLOXMODEM "ubloxmodem"
|
||||||
|
|
||||||
|
enum ublox_flags {
|
||||||
|
UBLOX_F_TOBY_L2 = (1 << 0),
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ublox_model {
|
||||||
|
char *name;
|
||||||
|
int flags;
|
||||||
|
};
|
||||||
|
|
||||||
|
const struct ublox_model *ublox_model_from_name(const char *name);
|
||||||
|
const struct ublox_model *ublox_model_from_id(int id);
|
||||||
|
int ublox_model_to_id(const struct ublox_model *model);
|
||||||
|
int ublox_is_toby_l2(const struct ublox_model *model);
|
||||||
|
|
||||||
extern void ublox_gprs_context_init(void);
|
extern void ublox_gprs_context_init(void);
|
||||||
extern void ublox_gprs_context_exit(void);
|
extern void ublox_gprs_context_exit(void);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue