summaryrefslogtreecommitdiff
path: root/drivers/ubloxmodem/ubloxmodem.c
blob: 034f7db1a49499a156920872a24d46200de5a410 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*
 *
 *  oFono - Open Source Telephony
 *
 *  Copyright (C) 2016  Endocode AG. All rights reserved.
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License version 2 as
 *  published by the Free Software Foundation.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <string.h>

#include <glib.h>
#include <gatchat.h>

#define OFONO_API_SUBJECT_TO_CHANGE
#include <ofono/plugin.h>
#include <ofono/types.h>
#include <ofono/modem.h>

#include "ubloxmodem.h"

const struct ublox_model ublox_models[] = {
	{
		.name = "SARA-G270",
	},
	/* TOBY L2 series */
	{
		.name = "TOBY-L200",
		.flags = UBLOX_F_TOBY_L2|UBLOX_F_HAVE_USBCONF,
	},
	{
		.name = "TOBY-L201",
		.flags = UBLOX_F_TOBY_L2|UBLOX_F_HAVE_USBCONF,
	},
	{
		.name = "TOBY-L210",
		.flags = UBLOX_F_TOBY_L2|UBLOX_F_HAVE_USBCONF,
	},
	{
		.name = "TOBY-L220",
		.flags = UBLOX_F_TOBY_L2|UBLOX_F_HAVE_USBCONF,
	},
	{
		.name = "TOBY-L280",
		.flags = UBLOX_F_TOBY_L2|UBLOX_F_HAVE_USBCONF,
	},
	/* TOBY L4 series */
	{
		.name = "TOBY-L4006",
		.flags = UBLOX_F_TOBY_L4,
	},
	{
		.name = "TOBY-L4106",
		.flags = UBLOX_F_TOBY_L4,
	},
	{
		.name = "TOBY-L4206",
		.flags = UBLOX_F_TOBY_L4,
	},
	{
		.name = "TOBY-L4906",
		.flags = UBLOX_F_TOBY_L4,
	},
	/* LARA L2 series */
	{
		.name = "LARA-R202",
		.flags = UBLOX_F_LARA_R2,
	},
	{
		.name = "LARA-R211",
		.flags = UBLOX_F_LARA_R2,
	},
	{ /* 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;
}

int ublox_is_toby_l4(const struct ublox_model *model)
{
	return model->flags & UBLOX_F_TOBY_L4;
}

static int ubloxmodem_init(void)
{
	ublox_gprs_context_init();
	ublox_netreg_init();
	ublox_netmon_init();
	ublox_lte_init();

	return 0;
}

static void ubloxmodem_exit(void)
{
	ublox_gprs_context_exit();
	ublox_netreg_exit();
	ublox_netmon_exit();
	ublox_lte_exit();
}

OFONO_PLUGIN_DEFINE(ubloxmodem, "U-Blox Toby L2 high speed modem driver",
			VERSION, OFONO_PLUGIN_PRIORITY_DEFAULT,
			ubloxmodem_init, ubloxmodem_exit)