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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
IOPSYS
mdmngr
Commits
b091583a
Commit
b091583a
authored
7 years ago
by
Jakob Olsson
Browse files
Options
Downloads
Patches
Plain Diff
add connect & disconnect network
parent
26e81aaf
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
dongle_apn.c
+0
-18
0 additions, 18 deletions
dongle_apn.c
dongle_network.c
+25
-4
25 additions, 4 deletions
dongle_network.c
libmobile.c
+16
-1
16 additions, 1 deletion
libmobile.c
libmobile.h
+2
-0
2 additions, 0 deletions
libmobile.h
with
43 additions
and
23 deletions
dongle_apn.c
+
0
−
18
View file @
b091583a
...
@@ -32,24 +32,6 @@ int list_apn_profiles(struct ubus_context *ctx, struct ubus_object *obj,
...
@@ -32,24 +32,6 @@ int list_apn_profiles(struct ubus_context *ctx, struct ubus_object *obj,
struct
json_object
*
apn_profiles
=
get_apn_profiles_json
();
struct
json_object
*
apn_profiles
=
get_apn_profiles_json
();
write_to_ubus
(
apn_profiles
,
ctx
,
req
);
write_to_ubus
(
apn_profiles
,
ctx
,
req
);
/*struct blob_buf bb;
memset(&bb, 0, sizeof(struct blob_buf));
blob_buf_init(&bb, 0);
json_object_object_foreach(apn_profiles, key, val) {
char *apn_profile = json_object_get_string(val);
if (strlen(apn_profile) > 0) {
char *apn_name = strtok(apn_profile, "($)");
blobmsg_add_string(&bb, key, apn_name);
} else
break;
}
ubus_send_reply(ctx, req, bb.head);
json_object_put(apn_profiles);
blob_buf_free(&bb);*/
return
0
;
return
0
;
}
}
...
...
This diff is collapsed.
Click to expand it.
dongle_network.c
+
25
−
4
View file @
b091583a
...
@@ -17,12 +17,10 @@
...
@@ -17,12 +17,10 @@
struct
ubus_context
*
ctx
;
struct
ubus_context
*
ctx
;
int
signal_strength
(
struct
ubus_context
*
ctx
,
struct
ubus_object
*
obj
,
int
get_
signal_strength
(
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
)
{
{
struct
blob_buf
bb
;
char
*
response
=
get_request
(
"rssi"
);
char
*
response
=
get_request
(
"rssi"
);
struct
json_object
*
parsed_response
=
json_tokener_parse
(
response
);
struct
json_object
*
parsed_response
=
json_tokener_parse
(
response
);
...
@@ -32,9 +30,32 @@ int signal_strength(struct ubus_context *ctx, struct ubus_object *obj,
...
@@ -32,9 +30,32 @@ int signal_strength(struct ubus_context *ctx, struct ubus_object *obj,
return
0
;
return
0
;
}
}
int
connect_network
(
struct
ubus_context
*
ctx
,
struct
ubus_object
*
obj
,
struct
ubus_request_data
*
req
,
const
char
*
method
,
struct
blob_attr
*
msg
)
{
char
*
response
=
_connect
();
struct
json_object
*
parsed_response
=
json_tokener_parse
(
response
);
write_to_ubus
(
parsed_response
,
ctx
,
req
);
return
0
;
}
int
disconnect
(
struct
ubus_context
*
ctx
,
struct
ubus_object
*
obj
,
struct
ubus_request_data
*
req
,
const
char
*
method
,
struct
blob_attr
*
msg
)
{
char
*
response
=
_disconnect
();
struct
json_object
*
parsed_response
=
json_tokener_parse
(
response
);
write_to_ubus
(
parsed_response
,
ctx
,
req
);
return
0
;
}
struct
ubus_method
dongle_object_methods
[]
=
{
struct
ubus_method
dongle_object_methods
[]
=
{
UBUS_METHOD_NOARG
(
"signal_strength"
,
signal_strength
),
UBUS_METHOD_NOARG
(
"get_signal_strength"
,
get_signal_strength
),
UBUS_METHOD_NOARG
(
"connect"
,
connect_network
),
UBUS_METHOD_NOARG
(
"disconnect"
,
disconnect
),
};
};
struct
ubus_object_type
dongle_object_type
=
UBUS_OBJECT_TYPE
(
"dongle"
,
dongle_object_methods
);
struct
ubus_object_type
dongle_object_type
=
UBUS_OBJECT_TYPE
(
"dongle"
,
dongle_object_methods
);
...
...
This diff is collapsed.
Click to expand it.
libmobile.c
+
16
−
1
View file @
b091583a
...
@@ -101,11 +101,26 @@ int get_apn_profiles_len(void)
...
@@ -101,11 +101,26 @@ int get_apn_profiles_len(void)
return
-
1
;
return
-
1
;
}
}
char
*
_connect
(
void
)
{
char
query
[
1024
]
=
{
0
};
strncpy
(
query
,
"http://192.168.0.1/goform//goform_set_cmd_process?isTest=false&goformId=CONNECT_NETWORK"
,
1023
);
return
post_request
(
query
);
}
char
*
_disconnect
(
void
)
{
char
query
[
1024
]
=
{
0
};
// removed notcallback, why have it?
strncpy
(
query
,
"http://192.168.0.1/goform//goform_set_cmd_process?isTest=false&goformId=DISCONNECT_NETWORK"
,
1023
);
return
post_request
(
query
);
}
char
*
_delete_apn
(
int
idx
)
char
*
_delete_apn
(
int
idx
)
{
{
char
query
[
1024
]
=
{
0
};
char
query
[
1024
]
=
{
0
};
query
[
0
]
=
'\0'
;
strncpy
(
query
,
"isTest=false&apn_action=delete&apn_mode=manual&index="
,
1023
);
strncpy
(
query
,
"isTest=false&apn_action=delete&apn_mode=manual&index="
,
1023
);
sprintf
(
query
+
strlen
(
query
),
"%d"
,
idx
);
sprintf
(
query
+
strlen
(
query
),
"%d"
,
idx
);
strncat
(
query
+
strlen
(
query
),
"&goformId=APN_PROC_EX"
,
1023
);
strncat
(
query
+
strlen
(
query
),
"&goformId=APN_PROC_EX"
,
1023
);
...
...
This diff is collapsed.
Click to expand it.
libmobile.h
+
2
−
0
View file @
b091583a
...
@@ -12,6 +12,8 @@ size_t write_func(void *buffer, size_t size, size_t nmemb, void *userp);
...
@@ -12,6 +12,8 @@ size_t write_func(void *buffer, size_t size, size_t nmemb, void *userp);
struct
json_object
*
get_apn_profiles_json
(
void
);
struct
json_object
*
get_apn_profiles_json
(
void
);
struct
blob_buf
json_to_blob
(
struct
json_object
*
response
,
struct
blob_buf
bb
);
struct
blob_buf
json_to_blob
(
struct
json_object
*
response
,
struct
blob_buf
bb
);
int
get_apn_profiles_len
(
void
);
int
get_apn_profiles_len
(
void
);
char
*
_connect
(
void
);
char
*
_disconnect
(
void
);
char
*
_delete_apn
(
int
idx
);
char
*
_delete_apn
(
int
idx
);
int
get_apn_profile_idx
(
struct
json_object
*
apn_profiles
,
char
*
name
);
int
get_apn_profile_idx
(
struct
json_object
*
apn_profiles
,
char
*
name
);
char
*
get_current_wan_apn
(
void
);
char
*
get_current_wan_apn
(
void
);
...
...
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
register
or
sign in
to comment