Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mdmngr
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This project is archived. Its data is
read-only
.
Show more breadcrumbs
IOPSYS
mdmngr
Commits
ddb0345b
Commit
ddb0345b
authored
Jul 9, 2018
by
Jakob Olsson
Browse files
Options
Downloads
Patches
Plain Diff
dongle_infrastructure: add functionality to activate sim through ubus
parent
c25f678d
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
dongle_infrastructure.c
+59
-0
59 additions, 0 deletions
dongle_infrastructure.c
with
59 additions
and
0 deletions
dongle_infrastructure.c
+
59
−
0
View file @
ddb0345b
...
@@ -51,6 +51,64 @@ const struct blobmsg_policy create_apn_policy_huawei[__CREATE_MAX_H] = {
...
@@ -51,6 +51,64 @@ const struct blobmsg_policy create_apn_policy_huawei[__CREATE_MAX_H] = {
[
PASS_H
]
=
{.
name
=
"password"
,
.
type
=
BLOBMSG_TYPE_STRING
}
[
PASS_H
]
=
{.
name
=
"password"
,
.
type
=
BLOBMSG_TYPE_STRING
}
};
};
int
activate_sim
(
struct
ubus_context
*
ctx
,
struct
ubus_object
*
obj
,
struct
ubus_request_data
*
req
,
const
char
*
method
,
struct
blob_attr
*
msg
)
{
struct
blob_attr
*
tb
[
__PIN_MAX
];
char
*
pin
;
int
rv
;
struct
json_object
*
response
;
struct
dongle
*
usb
;
usb
=
get_dongle_by_obj_name
(
obj
->
name
);
if
(
!
usb
)
{
ubus_print_key_val
(
ctx
,
req
,
"Failure"
,
"No device configured with this object"
);
debug_print
(
"No device configured with this object
\n
"
);
goto
fail
;
}
rv
=
sim_state
(
usb
);
if
(
rv
==
2
)
{
ubus_print_key_val
(
ctx
,
req
,
"Failure"
,
"No SIM card detected"
);
debug_print
(
"No SIM card detected
\n
"
);
goto
fail
;
}
blobmsg_parse
(
pin_policy
,
__PIN_MAX
,
tb
,
blob_data
(
msg
),
blob_len
(
msg
));
if
(
!
tb
[
PIN
])
{
ubus_print_key_val
(
ctx
,
req
,
"Failure"
,
"Provide a pin"
);
debug_print
(
"Please enter a pin!
\n
"
);
goto
fail
;
}
pin
=
(
char
*
)
blobmsg_data
(
tb
[
PIN
]);
rv
=
validate_pin_format
(
pin
);
if
(
rv
<
0
)
{
ubus_print_key_val
(
ctx
,
req
,
"Failure"
,
"Invalid pin format"
);
debug_print
(
"invalid pin format!
\n
"
);
goto
fail
;
}
response
=
mobile_activate_sim
(
*
usb
,
pin
);
if
(
!
response
)
{
debug_print
(
"error disabling pin!
\n
"
);
ubus_print_key_val
(
ctx
,
req
,
"Failure"
,
"No valid response received from dongle"
);
goto
fail
;
}
rv
=
check_response
(
response
,
usb
->
if_name
);
if
(
rv
<
0
)
ubus_print_key_val
(
ctx
,
req
,
"Failure"
,
"Incorrect pin"
);
else
ubus_print_key_val
(
ctx
,
req
,
"Success"
,
"SIM activated"
);
json_object_put
(
response
);
fail:
return
UBUS_STATUS_OK
;
}
int
set_pin
(
struct
ubus_context
*
ctx
,
struct
ubus_object
*
obj
,
int
set_pin
(
struct
ubus_context
*
ctx
,
struct
ubus_object
*
obj
,
struct
ubus_request_data
*
req
,
const
char
*
method
,
struct
ubus_request_data
*
req
,
const
char
*
method
,
struct
blob_attr
*
msg
)
struct
blob_attr
*
msg
)
...
@@ -1101,6 +1159,7 @@ fail:
...
@@ -1101,6 +1159,7 @@ fail:
}
}
struct
ubus_method
obj_methods
[]
=
{
struct
ubus_method
obj_methods
[]
=
{
UBUS_METHOD
(
"activate_sim"
,
activate_sim
,
pin_policy
),
UBUS_METHOD
(
"set_pin"
,
set_pin
,
set_pin_policy
),
//pin
UBUS_METHOD
(
"set_pin"
,
set_pin
,
set_pin_policy
),
//pin
UBUS_METHOD
(
"disable_pin"
,
disable_pin
,
pin_policy
),
UBUS_METHOD
(
"disable_pin"
,
disable_pin
,
pin_policy
),
UBUS_METHOD
(
"enable_pin"
,
enable_pin
,
pin_policy
),
UBUS_METHOD
(
"enable_pin"
,
enable_pin
,
pin_policy
),
...
...
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment