Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
mmsd
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chris T
mmsd
Commits
c1e0cb96
Commit
c1e0cb96
authored
Jan 23, 2021
by
Chris T
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better handle suspending.
parent
82d95bad
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
22 deletions
+41
-22
plugins/modemmanager.c
plugins/modemmanager.c
+41
-22
No files found.
plugins/modemmanager.c
View file @
c1e0cb96
...
...
@@ -76,7 +76,10 @@ struct modem_data {
//The Bus org.ofono.mms.ModemManager
GDBusConnection
*
master_connection
;
guint
owner_id
;
guint
registration_id
;
guint
registration_id
;
// This is a way to track the state of the modem if it is disabled
MmGdbusModem
*
gdbus_modem
;
gulong
modem_state_watch_id
;
//These are modem manager related settings
MMManager
*
mm
;
guint
mm_watch_id
;
...
...
@@ -500,8 +503,6 @@ pur_mm_get_modem_state (void)
}
state
=
mm_modem_get_state
(
modem
->
modem
);
if
(
state
<
MM_MODEM_STATE_ENABLED
)
{
mms_error
(
"ModemManagerPlugin(): Modem Initializing...."
);
while
(
state
<
MM_MODEM_STATE_DISABLED
)
{
mms_error
(
"ModemManagerPlugin(): Something May be wrong with the modem, checking...."
);
switch
(
state
)
{
case
MM_MODEM_STATE_FAILED
:
...
...
@@ -517,22 +518,16 @@ pur_mm_get_modem_state (void)
pur_mm_state
(
PUR_MM_STATE_MODEM_DISABLED
);
return
FALSE
;
case
MM_MODEM_STATE_INITIALIZING
:
/* Give the modem a second to initialize*/
sleep
(
3
);
state
=
mm_modem_get_state
(
modem
->
modem
);
break
;
mms_error
(
"ModemManagerPlugin(): MM_MODEM_STATE_INITIALIZING"
);
pur_mm_state
(
PUR_MM_STATE_MODEM_DISABLED
);
return
FALSE
;
case
MM_MODEM_STATE_DISABLED
:
mms_error
(
"ModemManagerPlugin(): MM_MODEM_STATE_DISABLED"
);
mms_error
(
"ModemManagerPlugin(): Turning on Modem...."
);
mm_modem_set_power_state_sync
(
modem
->
modem
,
MM_MODEM_POWER_STATE_ON
,
NULL
,
&
error
);
return
FALSE
;
default:
break
;
}
}
if
(
state
==
MM_MODEM_STATE_DISABLED
)
{
mms_error
(
"ModemManagerPlugin(): MM_MODEM_STATE_DISABLED"
);
mms_error
(
"ModemManagerPlugin(): Turning on Modem...."
);
mm_modem_set_power_state_sync
(
modem
->
modem
,
MM_MODEM_POWER_STATE_ON
,
NULL
,
&
error
);
if
(
error
!=
NULL
)
{
g_warning
(
"ModemManagerPlugin(): Error setting power state: %s
\n
"
,
error
->
message
);
}
sleep
(
1
);
}
}
else
{
mms_error
(
"ModemManagerPlugin(): MM_MODEM_STATE_ENABLED"
);
...
...
@@ -541,6 +536,22 @@ pur_mm_get_modem_state (void)
return
TRUE
;
}
static
void
state_changed_cb
(
MMModem
*
cb_modem
,
MMModemState
old
,
MMModemState
new
,
MMModemStateChangeReason
reason
)
{
mms_error
(
"ModemManagerPlugin(): State Change: Old: %d New: %d, Reason: %d"
,
old
,
new
,
reason
);
if
(
new
>=
MM_MODEM_STATE_CONNECTING
)
{
mms_error
(
"ModemManagerPlugin(): Modem is ready"
);
g_signal_handler_disconnect
(
modem
->
gdbus_modem
,
modem
->
modem_state_watch_id
);
pur_mm_state
(
PUR_MM_STATE_MODEM_FOUND
);
}
}
static
void
pur_mm_state
(
int
state
)
...
...
@@ -550,15 +561,23 @@ pur_mm_state (int state)
case
PUR_MM_STATE_MODEM_FOUND
:
if
(
!
modem
->
modem_available
)
{
if
(
modem
->
modem
)
{
mm_modem_get_sim
(
modem
->
modem
,
NULL
,
(
GAsyncReadyCallback
)
cb_get_sim_ready
,
NULL
);
mms_error
(
"ModemManagerPlugin(): SIM is Unlocked!"
);
if
(
!
pur_mm_get_modem_state
())
{
mms_error
(
"ModemManagerPlugin(): There's a problem with the modem!"
);
modem
->
gdbus_modem
=
MM_GDBUS_MODEM
(
modem
->
modem
);
modem
->
modem_state_watch_id
=
g_signal_connect
(
modem
->
gdbus_modem
,
"state-changed"
,
G_CALLBACK
(
state_changed_cb
),
NULL
);
mms_error
(
"ModemManagerPlugin(): Monitoring the modem to see if it will recover...."
);
break
;
}
else
{
pur_mm_state
(
PUR_MM_STATE_READY
);
mm_modem_get_sim
(
modem
->
modem
,
NULL
,
(
GAsyncReadyCallback
)
cb_get_sim_ready
,
NULL
);
}
}
modem
->
modem_available
=
TRUE
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment