[RFC] HFP support into oFono and BlueZ
by Gustavo F. Padovan
Hi,
These patches implement the new API for the Audio Gateway in BlueZ. It
follows the last version of the HandsfreeGateway and HandsfreeAgent
Intefaces API.
The first two patches is for BlueZ and the other for oFono. You can
test it with using enable-modem and test-voicecall scripts into the
test dir of oFono.
Feel free to test it and send me your comments. We have some bugs yet.
The audio part is not working yet. We are going to work on pulseaudio
this week to get this done soon.
Regards,
--
Gustavo F. Padovan
ProFUSION embedded systems - http://profusion.mobi
8 years, 6 months
CDMA SMS Handling
by Rajesh.Nagaiah@elektrobit.com
Hi,
There was a discussion about the CDMA SMS handling and CDMA PDUs in the
IRC channel couple of days before. I would like to highlight the
differences between CDMA and GSM PDU and how we should proceed with this
from my understanding. Let me know your opinion.
Even though oFono supports +CMT and +CMTI, if we feed the incoming CDMA
PDUs to the SMS core it wont get decoded correctly, as there is
substantial differences between the GSM and CDMA SMS PDUs as described
in 3GPP2 specification C.S0015-B Short Message Service (SMS) for
Wideband Spread Spectrum Systems
For eg, the incoming PDU example that was mentioned in the IRC
discussion
+CMT: , 40,
00000210020207028CE95DCC65800601FC08150003168D30010610241830608003061010
04044847
40 - Length of the PDU in bytes
00 - Message Type ( 00 - SMS Point-to-Point)
00 - TeleService Identifier Tag (SMS Parameter Indentifier)
02 - TeleService Identifier Length (SMS Parameter Length)
10 - TeleService Identifier Value - First 8 bits
02 - TeleService Identifier Value - Second 8 bits
TeleService Identifier - 0x1002 - CDMA Messaging Teleservice
(CMT-95)
02 - Originating Address Tag
07 - Originating Address Length
02 - Originating Address 1st 8 Bits
8C - Originating Address 2nd 8 Bits
E9 - Originating Address 3rd 8 Bits
5D - Originating Address 4th 8 Bits
CC - Originating Address 5th 8 Bits
65 - Originating Address 6th 8 Bits
80 - Originating Address 7th 8 Bits
Digit Mode - 1 Bit
Number Mode - 1 Bit
Number Type - 0 or 3 bits
Number Plan - 0 or 4 bits
Number Fields - 8 Bits
Number Field occurrence of CHARi
CHARi - 4 or 8 bits ( 4 - in case of DTMF encoding, 8 - incase
of ASCII encoding)
Reserved - 0-7 bits
Lets take the 1st and 2nd 8 bits
02 - 0000 0010 ( Digit Mode bit - 0, Number Mode bit - 0)
8C - 1000 1100
As Digit mode bit is set to 0, Number Plan and Number Type is void
(0 bits) in this case.
So the remaining 6 bits of 1st 8bits and the first 2 bits of 2nd
8bit is Number fields
Number fields - 00 0010 10 - 0000 1010 - 0x0A (10 digits)
As Digit mode bit is set to 0, each address digit here is
represented as 4bit DTMF digit
0x8C 0xE9 0x5D 0xCC 0x65 0X80
1000 1100 1110 1001 0101 1101 1100 1100 0110 0101 1000 0000
10 0011 0011 1010 0101 0111 0111 0011 0001 1001 0110 0000 00
3 3 0 5 7 7 3 1 9 6 Last 6 bits
are reserved bits
Originating Address - 3305773196
06 - Bearer Reply Option Tag
01 - Bearer Reply Option Length
FC - First 6 bits Reply Sequence number and last 2 bits reserved set to
0
1111 1100 - 111111 REPLY_SEQ
00 Reserved
08 - Bearer Data Tag
15 - Bearer Data Length
00 - Message Indentifier Tag ( Bearer Data Sub parameter )
03 - Message Indentifier Length
16 - Message Type 4 bits Message Id 4 Bits
8D - Message Id 8 Bits
30 - Message Id 4 Bits, UDH Header indicator 1 Bit, Reserved 3 Bits
How Message Identifier value 16 8D 30 was formed ?
Message type ( 4 bits ) - 1( 0001 - Deliver)
Message Identifier ( 16 bits ) - 26835( 0x68D3)
Header Indicator (1 bit) - 0 (UDH not present in User Data
Subparameter)
Reserved ( 3bits) - 0 (000)
01 - User Data Tag ( Bearer Data Sub parameter )
06 - User Data Length
10 - Message Encoding 5 bits ( 0001 0000 ( 00010 = 2 -> 7-bit ASCII )) &
Number Fields 3 bits ( 000)
24 - Number Fields 5 Bits + User char field 1's 3 bits ( 0010 0100 )
18 - User char field 1's remaining 5 bits + User char field 2's 3 bits
(0001 1000)
30 - User char field 2's remaining 5 bits + User char field 3's 3 bits
(0011 0000)
60 - User char field 3's remaining 5 bits + User char field 4's 3 bits
(0110 0000)
80 - User char field 4's remaining 5 bits + Reserved 3 Bits (1000 0000)
Number Fields: 000 00100 - 04 (4 Character fields)
User Char [1] - 100 00011 - 0x83
User Char [2] - 000 00110 - 0x06
User Char [3] - 000 01100 - 0x0C
User Char [4] - 000 10000 - 0x10
Hex 0x83 0x06 0x0C 0x10
Octets 1000 0011 0000 0110 0000 1100 0001 0000
Septets 1000 001 10000 01 100000 1 1000001
Character A(0x41) A(0x41) A(0x41) A(0x41)
Message content: AAAA
Message Encoding - 2 (00010 - 5 bits)
Number Fields - 4 (0000 0100 - 8 bits)
User characters - 0x83 0x06 0x0C 0x10 ( 8 bits each)
00010 0000 0100 1000 0011 0000 0110 0000 1100 0001 0000
0001 0000 - 0x10
0010 0100 - 0x24
0001 1000 - 0x18
0011 0000 - 0x30
0110 0000 - 0x60
1000 0000 - 0x80 (Last 3 bits set to 0's(reserved bit) to complete
the octets)
03 - Message Center Time Stamp Tag ( Bearer Data Sub parameter )
06 - Message Center Time Stamp Length
all date and time fields contain two 4-bit BCD numbers giving the
decimal value of the field.
10 - Year (2010)
10 - Month (10 - October)
04 - Day
04 - Hour
48 - Minutes
47 - Seconds
Time Stamp 04:48:47 04/10/2010
Decoded Information:
Message Type: Deliver (Incoming Message)
Teleservice: CMT-95
Message Identifier: 26835
Originating Address: 3305773196
Message content: AAAA
Message Center Time Stamp: 04:48:47 04/10/2010
As from the above decoding example we can see there is substantial
differences between the GSM and CDMA SMS specifications and so the SMS
atom needs many additions and needs to be heavily modified to support
also CDMA SMS handling. Currently the oFono sms file unit handles the
common and the GSM technology aspects of the SMS stack along with the
smsutils. The SMS atom has the GSM specific members, segmentation and
queuing logic. The smsutils mainly takes care of encoding/decoding of
the PDUs, which is GSM specific. As the segmentation and queuing logic
and the interface is common for both GSM and CDMA, we could reuse this
common code and add the CDMA handling into it and create a new
cdmasmsutils unit to support the CDMA SMS specifics, much like the
smsutils does already for GSM.
BR,
Rajesh
8 years, 8 months
[PATCH 0/3] mmsd: (resending) new tasks definition
by Ronald Tessier
These patches concern mmsd and update TODO and documentation to describe new
functionalities to add to mmsd.
Ronald Tessier (3):
TODO: Add new tasks
doc: Describe delivered group in storage doc
doc: Add new D-Bus methods to service interface
TODO | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++
doc/service-api.txt | 20 +++++++++++++++
doc/storage.txt | 30 ++++++++++++++++++++++
3 files changed, 117 insertions(+), 0 deletions(-)
--
1.7.4.1
8 years, 8 months
[RFC 0/3] Fix crash when network is lost
by Guillaume Zajac
Hi,
Problem description:
Some Huawei modems are trying to keep PPP session with the network alive even if the network is lost.
Thus oFono PPP session with the modem is never ended. Currently when network is lost, oFono will release the active contexts into the core however the context is still active at driver level. If the connection with the network is established again and we try to enable a data call, we have a crash.
This issue is very tricky there might be multiple solutions, here is one I discussed with Denis yesterday.
A new driver entry is added to release context into the driver in shutting down the PPP session between oFono and the modem.
Then ofono_context_deactivated() is called to signal the context is inactive at driver level.
In the case we lost the network and we are reattaching to the network but the PPP session had no time to be released, there is a mechanism to wait for the previous context to be released and then signal modem is reattached to the network. ConnMan can do again a data call.
Guillaume Zajac (3):
gprs-context: Add new driver entry
gprs-context: Add new driver entry definition
gprs: Release context in driver and core when network is lost
drivers/atmodem/gprs-context.c | 11 +++++
include/gprs-context.h | 2 +
src/gprs.c | 84 ++++++++++++++++++++++++++++++----------
3 files changed, 76 insertions(+), 21 deletions(-)
--
1.7.5.4
8 years, 8 months
[PATCH 0/2] v3: Wavecom Q2403/Q2686 modems support
by pablo@gnumonks.org
From: Pablo Neira Ayuso <pablo(a)gnumonks.org>
Hi!
This patch adds the missing bits to fully support Wavecom
Q2403/Q2686 modems.
Thanks to Denis Kenzior for providing useful tips to get a
much nicer patch.
Pablo Neira Ayuso (2):
udev: add Wavecom support
plugins: add support for Wavecom Q2403/Q2686 modems
drivers/atmodem/sim.c | 3 +++
plugins/udev.c | 27 +++++++++++++++++++++++++++
plugins/wavecom.c | 21 +++++++++++++++++++--
3 files changed, 49 insertions(+), 2 deletions(-)
--
1.7.10
8 years, 8 months
[PATCH v2 1/2] dbus: Add __ofono_error_from_error utility function
by Philippe Nunes
---
src/dbus.c | 42 ++++++++++++++++++++++++++++++++++++++++++
src/ofono.h | 3 +++
2 files changed, 45 insertions(+)
diff --git a/src/dbus.c b/src/dbus.c
index 5cccc32..4ae6969 100644
--- a/src/dbus.c
+++ b/src/dbus.c
@@ -32,6 +32,21 @@
static DBusConnection *g_connection;
+struct error_mapping_entry {
+ int error;
+ DBusMessage *(*ofono_error_func)(DBusMessage *);
+};
+
+struct error_mapping_entry cme_errors_mapping[] = {
+ { 3, __ofono_error_not_allowed },
+ { 4, __ofono_error_not_supported },
+ { 16, __ofono_error_incorrect_password },
+ { 30, __ofono_error_not_registered },
+ { 31, __ofono_error_timed_out },
+ { 32, __ofono_error_access_denied },
+ { 50, __ofono_error_invalid_args },
+};
+
static void append_variant(DBusMessageIter *iter,
int type, void *value)
{
@@ -388,6 +403,33 @@ DBusMessage *__ofono_error_not_allowed(DBusMessage *msg)
"Operation is not allowed");
}
+DBusMessage *__ofono_error_from_error(const struct ofono_error *error,
+ DBusMessage *msg)
+{
+ struct error_mapping_entry *e;
+ int maxentries;
+ int i;
+
+ switch (error->type) {
+ case OFONO_ERROR_TYPE_CME:
+ e = cme_errors_mapping;
+ maxentries = sizeof(cme_errors_mapping) /
+ sizeof(struct error_mapping_entry);
+ for (i = 0; i < maxentries; i++)
+ if (e[i].error == error->error)
+ return e[i].ofono_error_func(msg);
+ break;
+ case OFONO_ERROR_TYPE_CMS:
+ return __ofono_error_failed(msg);
+ case OFONO_ERROR_TYPE_CEER:
+ return __ofono_error_failed(msg);
+ default:
+ return __ofono_error_failed(msg);
+ }
+
+ return __ofono_error_failed(msg);
+}
+
void __ofono_dbus_pending_reply(DBusMessage **msg, DBusMessage *reply)
{
DBusConnection *conn = ofono_dbus_get_connection();
diff --git a/src/ofono.h b/src/ofono.h
index 81d5f71..f0e1072 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -66,6 +66,9 @@ DBusMessage *__ofono_error_emergency_active(DBusMessage *msg);
DBusMessage *__ofono_error_incorrect_password(DBusMessage *msg);
DBusMessage *__ofono_error_not_allowed(DBusMessage *msg);
+DBusMessage *__ofono_error_from_error(const struct ofono_error *error,
+ DBusMessage *msg);
+
void __ofono_dbus_pending_reply(DBusMessage **msg, DBusMessage *reply);
gboolean __ofono_dbus_valid_object_path(const char *path);
--
1.7.9.5
8 years, 9 months
[PATCH_v2] test: Add new script for SS GCF test cases
by Guillaume Zajac
This script uses dynamic SS codes in input and
displays answers to the different requests.
It handles all SS: call barring, call forwarding,
call waiting, CLIP, CLIR, ...
---
Makefile.am | 1 +
test/test-ss | 42 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+), 0 deletions(-)
create mode 100755 test/test-ss
diff --git a/Makefile.am b/Makefile.am
index 56fa75a..f4bca7f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -558,6 +558,7 @@ test_scripts = test/backtrace \
test/test-network-registration \
test/test-phonebook \
test/test-cbs \
+ test/test-ss \
test/test-ss-control-cb \
test/test-ss-control-cf \
test/test-ss-control-cs \
diff --git a/test/test-ss b/test/test-ss
new file mode 100755
index 0000000..d5488d7
--- /dev/null
+++ b/test/test-ss
@@ -0,0 +1,42 @@
+#!/usr/bin/python
+
+import sys
+import dbus
+
+bus = dbus.SystemBus()
+
+manager = dbus.Interface(bus.get_object('org.ofono', '/'),
+ 'org.ofono.Manager')
+
+modems = manager.GetModems()
+modem = modems[0][0]
+
+if (len(sys.argv) == 2):
+ ss_code = sys.argv[1]
+else:
+ modem = sys.argv[1]
+ ss_code = sys.argv[2]
+
+ss = dbus.Interface(bus.get_object('org.ofono', modem),
+ 'org.ofono.SupplementaryServices')
+
+try:
+ ss_type, properties = ss.Initiate(ss_code, timeout=100)
+except dbus.DBusException, e:
+ print "Unable to perform operation: ", e
+ sys.exit(1);
+
+if (ss_type == "CallBarring"):
+ print "%s : Operation [ %s ] Service Type [ %s ]" % (ss_type, properties[0], properties[1])
+ for key in properties[2]:
+ print "%s : %s" % (key, properties[2][key])
+elif (ss_type == "CallForwarding"):
+ print "%s : Operation [ %s ] Service Type [ %s ]" % (ss_type, properties[0], properties[1])
+ for key in properties[2]:
+ print "%s : %s" % (key, properties[2][key])
+elif (ss_type == "CallWaiting"):
+ print "%s : Operation [ %s ]" % (ss_type, properties[0])
+ for key in properties[1]:
+ print "%s : %s" % (key, properties[1][key])
+else:
+ print "%s : Operation [ %s ] Status [ %s ]" % (ss_type, properties[0], properties[1])
--
1.7.5.4
8 years, 9 months
[PATCH] Add WSP_VALUE_TYPE_TEXT support in wsp_decode_application_id()
by Jens Rehsack
From: Jens Rehsack <sno(a)NetBSD.org>
---
src/wsputil.c | 24 ++++++++++++++++++++----
1 Datei geändert, 20 Zeilen hinzugefügt(+), 4 Zeilen entfernt(-)
diff --git a/src/wsputil.c b/src/wsputil.c
index 1b2b2b7..ece58e6 100644
--- a/src/wsputil.c
+++ b/src/wsputil.c
@@ -490,13 +490,26 @@ gboolean wsp_decode_application_id(struct wsp_header_iter *iter,
unsigned int val_len;
unsigned int i;
+ switch (wsp_header_iter_get_val_type(iter)) {
+ case WSP_VALUE_TYPE_TEXT:
+ if (out_value)
+ *out_value = pdu_val;
+
+ break;
+
/*
* Well-known field values MUST be encoded using the
* compact binary formats
*/
- if (wsp_header_iter_get_val_type(iter) == WSP_VALUE_TYPE_SHORT) {
+ case WSP_VALUE_TYPE_SHORT:
val = *pdu_val & 0x7f;
- } else {
+
+ if (out_value)
+ *out_value = get_text_entry(val, app_id);
+
+ break;
+
+ case WSP_VALUE_TYPE_LONG:
val_len = wsp_header_iter_get_val_len(iter);
if (val_len > 2)
@@ -504,10 +517,13 @@ gboolean wsp_decode_application_id(struct wsp_header_iter *iter,
for (i = 0, val = 0; i < val_len && i < sizeof(val); i++)
val = (val << 8) | pdu_val[i];
+
+ if (out_value)
+ *out_value = get_text_entry(val, app_id);
+
+ break;
}
- if (out_value)
- *out_value = get_text_entry(val, app_id);
return TRUE;
}
--
1.7.10.1
8 years, 9 months
[PATCH] Add WSP_VALUE_TYPE_TEXT support in wsp_decode_application_id()
by Jens Rehsack
From: Jens Rehsack <sno(a)NetBSD.org>
---
src/wsputil.c | 43 ++++++++++++++++++++++++++-----------------
1 Datei geändert, 26 Zeilen hinzugefügt(+), 17 Zeilen entfernt(-)
diff --git a/src/wsputil.c b/src/wsputil.c
index 1b2b2b7..5611ed2 100644
--- a/src/wsputil.c
+++ b/src/wsputil.c
@@ -486,28 +486,37 @@ gboolean wsp_decode_application_id(struct wsp_header_iter *iter,
const void **out_value)
{
const unsigned char *pdu_val = wsp_header_iter_get_val(iter);
- unsigned int val;
- unsigned int val_len;
- unsigned int i;
- /*
- * Well-known field values MUST be encoded using the
- * compact binary formats
- */
- if (wsp_header_iter_get_val_type(iter) == WSP_VALUE_TYPE_SHORT) {
- val = *pdu_val & 0x7f;
+ if (wsp_header_iter_get_val_type(iter) == WSP_VALUE_TYPE_TEXT) {
+ wsp_header_iter_get_val_len(iter);
+
+ if (out_value)
+ *out_value = pdu_val;
} else {
- val_len = wsp_header_iter_get_val_len(iter);
+ unsigned int val;
- if (val_len > 2)
- return FALSE;
+ /*
+ * Well-known field values MUST be encoded using the
+ * compact binary formats
+ */
+ if (wsp_header_iter_get_val_type(iter) == WSP_VALUE_TYPE_SHORT) {
+ val = *pdu_val & 0x7f;
+ } else {
+ unsigned int val_len;
+ unsigned int i;
- for (i = 0, val = 0; i < val_len && i < sizeof(val); i++)
- val = (val << 8) | pdu_val[i];
- }
+ val_len = wsp_header_iter_get_val_len(iter);
- if (out_value)
- *out_value = get_text_entry(val, app_id);
+ if (val_len > 2)
+ return FALSE;
+
+ for (i = 0, val = 0; i < val_len && i < sizeof(val); i++)
+ val = (val << 8) | pdu_val[i];
+ }
+
+ if (out_value)
+ *out_value = get_text_entry(val, app_id);
+ }
return TRUE;
}
--
1.7.10.1
8 years, 9 months
[PATCH 1/4] n900: Use consistent naming in GPIO API
by Aki Niemi
In addition, add header guards as the API can be used from more than
one plugin.
---
plugins/n900.c | 12 +++---
plugins/nokia-gpio.c | 106 ++++++++++++++++++++++----------------------------
plugins/nokia-gpio.h | 37 +++++++++++++++--
3 files changed, 85 insertions(+), 70 deletions(-)
diff --git a/plugins/n900.c b/plugins/n900.c
index 44e2e75..420fd0c 100644
--- a/plugins/n900.c
+++ b/plugins/n900.c
@@ -308,7 +308,7 @@ static void n900_power_cb(enum power_state state, void *data)
struct ofono_modem *modem = data;
struct isi_data *isi = ofono_modem_get_data(modem);
- DBG("power state %s", gpio_power_state_name(state));
+ DBG("power state %s", nokia_gpio_power_state_name(state));
isi->power_state = state;
@@ -358,7 +358,7 @@ static int n900_probe(struct ofono_modem *modem)
if (getenv("OFONO_ISI_TRACE"))
g_isi_modem_set_trace(isimodem, isi_trace);
- if (gpio_probe(isimodem, address, n900_power_cb, modem) != 0) {
+ if (nokia_gpio_probe(isimodem, address, n900_power_cb, modem) != 0) {
DBG("gpio for %s: %s", ifname, strerror(errno));
goto error;
}
@@ -382,7 +382,7 @@ static int n900_probe(struct ofono_modem *modem)
error:
g_isi_modem_destroy(isimodem);
- gpio_remove(modem);
+ nokia_gpio_remove(modem);
g_free(isi);
return -errno;
@@ -397,7 +397,7 @@ static void n900_remove(struct ofono_modem *modem)
if (!isi)
return;
- gpio_remove(modem);
+ nokia_gpio_remove(modem);
if (isi->timeout)
g_source_remove(isi->timeout);
@@ -523,7 +523,7 @@ static int n900_enable(struct ofono_modem *modem)
isi->enabled = TRUE;
- return gpio_enable(modem);
+ return nokia_gpio_enable(modem);
}
static int n900_disable(struct ofono_modem *modem)
@@ -534,7 +534,7 @@ static int n900_disable(struct ofono_modem *modem)
isi->enabled = FALSE;
- return gpio_disable(modem);
+ return nokia_gpio_disable(modem);
}
static struct ofono_modem_driver n900_driver = {
diff --git a/plugins/nokia-gpio.c b/plugins/nokia-gpio.c
index 57aad8d..d9e05f3 100644
--- a/plugins/nokia-gpio.c
+++ b/plugins/nokia-gpio.c
@@ -60,18 +60,6 @@ enum phonet_link {
PHONET_LINK_UP,
};
-enum power_event {
- POWER_EVENT_PHONET_LINK_UP = 1,
- POWER_EVENT_PHONET_LINK_DOWN,
- POWER_EVENT_ON,
- POWER_EVENT_ON_TIMEOUT,
- POWER_EVENT_REBOOT_TIMEOUT,
- POWER_EVENT_OFF,
- POWER_EVENT_OFF_IMMEDIATELY,
- POWER_EVENT_OFF_TIMEOUT,
- POWER_EVENT_OFF_COMPLETE,
-};
-
struct gpio_data {
GIsiPhonetNetlink *link;
gpio_finished_cb_t callback;
@@ -98,41 +86,6 @@ struct gpio_data {
static struct gpio_data self;
-#define _(X) case X: return #X
-
-static inline char const *gpio_power_event_name(enum power_event value)
-{
- switch (value) {
- _(POWER_EVENT_PHONET_LINK_UP);
- _(POWER_EVENT_PHONET_LINK_DOWN);
- _(POWER_EVENT_ON);
- _(POWER_EVENT_ON_TIMEOUT);
- _(POWER_EVENT_REBOOT_TIMEOUT);
- _(POWER_EVENT_OFF);
- _(POWER_EVENT_OFF_IMMEDIATELY);
- _(POWER_EVENT_OFF_TIMEOUT);
- _(POWER_EVENT_OFF_COMPLETE);
- }
- return "<UNKNOWN>";
-}
-
-char const *gpio_power_state_name(enum power_state value)
-{
- switch (value) {
- _(POWER_STATE_NONE);
- _(POWER_STATE_ON_STARTED);
- _(POWER_STATE_ON);
- _(POWER_STATE_ON_RESET);
- _(POWER_STATE_ON_FAILED);
- _(POWER_STATE_OFF_STARTED);
- _(POWER_STATE_OFF_WAITING);
- _(POWER_STATE_OFF);
- }
- return "<UNKNOWN>";
-}
-
-#undef _
-
static void gpio_power_state_machine(enum power_event event);
static void gpio_power_set_state(enum power_state new_state);
@@ -324,14 +277,13 @@ static gboolean gpio_power_timer_cb(gpointer user)
return FALSE;
}
-
static void gpio_power_state_machine(enum power_event event)
{
enum power_state new_state;
DBG("(%s) @ state %s",
- gpio_power_event_name(event),
- gpio_power_state_name(self.state));
+ nokia_gpio_power_event_name(event),
+ nokia_gpio_power_state_name(self.state));
switch (event) {
case POWER_EVENT_ON:
@@ -491,10 +443,10 @@ static void gpio_power_state_machine(enum power_event event)
return;
}
- DBG("Event %s (%d) not handled", gpio_power_event_name(event), event);
+ DBG("Event %s (%d) not handled", nokia_gpio_power_event_name(event),
+ event);
}
-
static void gpio_power_set_state(enum power_state new_state)
{
enum power_state old_state = self.state;
@@ -502,8 +454,8 @@ static void gpio_power_set_state(enum power_state new_state)
enum power_event timer_event;
DBG("(%s) at (%s)%s",
- gpio_power_state_name(new_state),
- gpio_power_state_name(old_state),
+ nokia_gpio_power_state_name(new_state),
+ nokia_gpio_power_state_name(old_state),
new_state == old_state ? " - already" : "");
switch (old_state) {
@@ -707,8 +659,8 @@ static int gpio_probe_links(void)
return -(errno = ENODEV);
}
-
-int gpio_probe(GIsiModem *idx, unsigned addr, gpio_finished_cb_t cb, void *data)
+int nokia_gpio_probe(GIsiModem *idx, unsigned addr, gpio_finished_cb_t cb,
+ void *data)
{
int error;
@@ -774,7 +726,7 @@ int gpio_probe(GIsiModem *idx, unsigned addr, gpio_finished_cb_t cb, void *data)
return 0;
}
-int gpio_remove(void *data)
+int nokia_gpio_remove(void *data)
{
if (self.data != data)
return -EINVAL;
@@ -792,7 +744,7 @@ int gpio_remove(void *data)
return 0;
}
-int gpio_enable(void *data)
+int nokia_gpio_enable(void *data)
{
if (self.data != data)
return -EINVAL;
@@ -805,7 +757,7 @@ int gpio_enable(void *data)
return -EINPROGRESS;
}
-int gpio_disable(void *data)
+int nokia_gpio_disable(void *data)
{
if (self.data != data)
return -EINVAL;
@@ -818,3 +770,39 @@ int gpio_disable(void *data)
return -EINPROGRESS;
}
+
+
+#define _(X) case X: return #X
+
+const char *nokia_gpio_power_event_name(enum power_event value)
+{
+ switch (value) {
+ _(POWER_EVENT_PHONET_LINK_UP);
+ _(POWER_EVENT_PHONET_LINK_DOWN);
+ _(POWER_EVENT_ON);
+ _(POWER_EVENT_ON_TIMEOUT);
+ _(POWER_EVENT_REBOOT_TIMEOUT);
+ _(POWER_EVENT_OFF);
+ _(POWER_EVENT_OFF_IMMEDIATELY);
+ _(POWER_EVENT_OFF_TIMEOUT);
+ _(POWER_EVENT_OFF_COMPLETE);
+ }
+ return "<UNKNOWN>";
+}
+
+const char *nokia_gpio_power_state_name(enum power_state value)
+{
+ switch (value) {
+ _(POWER_STATE_NONE);
+ _(POWER_STATE_ON_STARTED);
+ _(POWER_STATE_ON);
+ _(POWER_STATE_ON_RESET);
+ _(POWER_STATE_ON_FAILED);
+ _(POWER_STATE_OFF_STARTED);
+ _(POWER_STATE_OFF_WAITING);
+ _(POWER_STATE_OFF);
+ }
+ return "<UNKNOWN>";
+}
+
+#undef _
diff --git a/plugins/nokia-gpio.h b/plugins/nokia-gpio.h
index b653bb8..991c10a 100644
--- a/plugins/nokia-gpio.h
+++ b/plugins/nokia-gpio.h
@@ -19,6 +19,13 @@
*
*/
+#ifndef __NOKIA_GPIO_H
+#define __NOKIA_GPIO_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
enum power_state {
POWER_STATE_NONE,
POWER_STATE_ON_STARTED,
@@ -30,11 +37,31 @@ enum power_state {
POWER_STATE_OFF,
};
+enum power_event {
+ POWER_EVENT_PHONET_LINK_UP = 1,
+ POWER_EVENT_PHONET_LINK_DOWN,
+ POWER_EVENT_ON,
+ POWER_EVENT_ON_TIMEOUT,
+ POWER_EVENT_REBOOT_TIMEOUT,
+ POWER_EVENT_OFF,
+ POWER_EVENT_OFF_IMMEDIATELY,
+ POWER_EVENT_OFF_TIMEOUT,
+ POWER_EVENT_OFF_COMPLETE,
+};
+
typedef void (*gpio_finished_cb_t)(enum power_state value, void *opaque);
-int gpio_probe(GIsiModem *idx, unsigned addr, gpio_finished_cb_t cb, void *data);
-int gpio_enable(void *opaque);
-int gpio_disable(void *opaque);
-int gpio_remove(void *opaque);
+int nokia_gpio_probe(GIsiModem *idx, unsigned addr, gpio_finished_cb_t cb,
+ void *data);
+int nokia_gpio_enable(void *opaque);
+int nokia_gpio_disable(void *opaque);
+int nokia_gpio_remove(void *opaque);
+
+const char *nokia_gpio_power_event_name(enum power_event value);
+const char *nokia_gpio_power_state_name(enum power_state value);
+
+#ifdef __cplusplus
+};
+#endif
-char const *gpio_power_state_name(enum power_state value);
+#endif /* !__NOKIA_GPIO_H */
--
1.7.5.4
8 years, 9 months