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
|
/*
*
* hh2serial GPS
*
* Copyright (C) 2007-2012 Intel Corporation. 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 <stdio.h>
#include <errno.h>
#define CONNMAN_API_SUBJECT_TO_CHANGE
#include <connman/plugin.h>
#include <connman/device.h>
#include <connman/log.h>
static struct connman_device *hh2serial_device;
static int set_reg(char *key, char *value)
{
FILE *reg_file;
reg_file = fopen(key, "w");
if (!reg_file)
return -errno;
fprintf(reg_file, "%s", value);
fclose(reg_file);
return 0;
}
static int hh2serial_probe(struct connman_device *device)
{
return 0;
}
static void hh2serial_remove(struct connman_device *device)
{
}
static int hh2serial_enable(struct connman_device *device)
{
DBG("");
set_reg("/sys/class/gpio/expo_rt", "85");
set_reg("/sys/class/gpio/gpio85/direction", "out");
set_reg("/sys/class/gpio/gpio85/value", "1");
return 0;
}
static int hh2serial_disable(struct connman_device *device)
{
DBG("");
set_reg("/sys/class/gpio/expo_rt", "85");
set_reg("/sys/class/gpio/gpio85/direction", "out");
set_reg("/sys/class/gpio/gpio85/value", "0");
return 0;
}
static struct connman_device_driver hh2seial_device_driver = {
.name = "hh2serial GPS",
.type = CONNMAN_DEVICE_TYPE_GPS,
.enable = hh2serial_enable,
.disable = hh2serial_disable,
.probe = hh2serial_probe,
.remove = hh2serial_remove,
};
static int hh2serial_init(void)
{
connman_device_driver_register(&hh2seial_device_driver);
hh2serial_device = connman_device_create("hh2serial_gps",
CONNMAN_DEVICE_TYPE_GPS);
if (hh2serial_device == NULL)
return -ENODEV;
connman_device_register(hh2serial_device);
return 0;
}
static void hh2serial_exit(void)
{
if (hh2serial_device != NULL) {
connman_device_unregister(hh2serial_device);
connman_device_unref(hh2serial_device);
}
}
CONNMAN_PLUGIN_DEFINE(hh2serial_gps, "hh2serial GPS", VERSION,
CONNMAN_PLUGIN_PRIORITY_LOW, hh2serial_init, hh2serial_exit)
|