mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-10 07:44:39 +01:00
bbf: support for bbk_cli operate command
This commit is contained in:
parent
9574e5dc0b
commit
680864df19
3 changed files with 37 additions and 0 deletions
25
dmoperate.c
25
dmoperate.c
|
|
@ -366,6 +366,30 @@ static opr_ret_t fetch_neighboring_wifi_diagnostic(struct dmctx *dmctx, char *pa
|
|||
return SUCCESS;
|
||||
}
|
||||
|
||||
static opr_ret_t bbk_speedtest(struct dmctx *dmctx, char *path, char *input)
|
||||
{
|
||||
json_object *ubus_res = NULL;
|
||||
|
||||
#ifdef DM_USE_LIBUBUS
|
||||
int timeout = dmubus_get_timeout();
|
||||
dmubus_set_timeout(90000);
|
||||
#endif
|
||||
dmubus_call("bbk", "start", UBUS_ARGS{}, 0, &ubus_res);
|
||||
|
||||
char *param_latency = (char *) dmjson_get_value(ubus_res, 1, "latency");
|
||||
char *param_download = (char *) dmjson_get_value(ubus_res, 1, "download");
|
||||
char *param_upload = (char *) dmjson_get_value(ubus_res, 1, "upload");
|
||||
|
||||
add_list_paramameter(dmctx, dmstrdup("Latency"), param_latency, "string", NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("Download"), param_download, "string", NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("Upload"), param_upload, "string", NULL, 0);
|
||||
|
||||
#ifdef DM_USE_LIBUBUS
|
||||
dmubus_set_timeout(timeout);
|
||||
#endif
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
static opr_ret_t ip_diagnostics_ipping(struct dmctx *dmctx, char *path, char *input)
|
||||
{
|
||||
json_object *json_res = NULL;
|
||||
|
|
@ -829,6 +853,7 @@ static struct op_cmd operate_helper[] = {
|
|||
{"Device.IP.Diagnostics.UploadDiagnostics", ip_diagnostics_upload},
|
||||
{"Device.IP.Diagnostics.UDPEchoDiagnostics", ip_diagnostics_udpecho},
|
||||
{"Device.IP.Diagnostics.ServerSelectionDiagnostics", ip_diagnostics_serverselection},
|
||||
{"Device.BBKSpeedTest", bbk_speedtest},
|
||||
{"Device.DNS.Diagnostics.NSLookupDiagnostics", ip_diagnostics_nslookup}
|
||||
};
|
||||
|
||||
|
|
|
|||
10
dmubus.c
10
dmubus.c
|
|
@ -34,6 +34,16 @@ static int timeout = 1000;
|
|||
const char *ubus_socket = NULL;
|
||||
json_object *json_res = NULL;
|
||||
|
||||
int dmubus_get_timeout()
|
||||
{
|
||||
return (timeout);
|
||||
}
|
||||
|
||||
void dmubus_set_timeout(int val)
|
||||
{
|
||||
timeout = val;
|
||||
}
|
||||
|
||||
static inline bool dmblobmsg_add_object(struct blob_buf *b, json_object *obj)
|
||||
{
|
||||
json_object_object_foreach(obj, key, val) {
|
||||
|
|
|
|||
2
dmubus.h
2
dmubus.h
|
|
@ -61,6 +61,8 @@ enum ubus_args_enum {
|
|||
extern struct dmubus_ctx dmubus_ctx;
|
||||
extern struct ubus_context *ubus_ctx;
|
||||
|
||||
int dmubus_get_timeout();
|
||||
void dmubus_set_timeout(int time);
|
||||
#define dm_ubus_get_value(jobj,ARGC,args...) \
|
||||
dmjson_get_value(jobj, ARGC, ##args)
|
||||
int dmubus_call(char *obj, char *method, struct ubus_arg u_args[], int u_args_size, json_object **req_res);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue