Commit 7e0e8dc4 authored by Pitchaiah Murugan's avatar Pitchaiah Murugan Committed by Sukru Senli
Browse files

Peripheral Manager: Reduce button press timeout for production mode

                    Add ubus button object for every button in the router.
parent 217afad5
Pipeline #1683 passed with stage
in 23 seconds
......@@ -11,7 +11,7 @@
#include "touch_sx9512.h"
#include "prox_px3220.h"
#define BUTTON_STATE_MAX 3
typedef enum {
BUTTON_NORMAL,
......@@ -96,6 +96,8 @@ static LIST_HEAD(drv_buttons_list);
/* list containing all function buttons read from config file */
static LIST_HEAD(buttons);
/*Production mode policy for changing mode from normal to production*/
enum {
BUTTON_MODE,
__BUTTON_MAX
......@@ -302,12 +304,22 @@ static button_press_type_t timer_valid(struct button_drv_list *button_drv, int m
sec = now.tv_sec - button_drv->pressed_time.tv_sec;
nsec = now.tv_nsec - button_drv->pressed_time.tv_nsec;
time_elapsed = sec*1000 + nsec/1000000;
if ( mtimeout < time_elapsed) {
if (longpress && (longpress < time_elapsed))
return BUTTON_PRESS_LONG;
return BUTTON_PRESS_SHORT;
}
}
if(global_button_state == BUTTON_PRODUCTION) {
mtimeout=mtimeout/10; longpress=longpress/10;
if ( mtimeout < time_elapsed) {
if (longpress && (longpress < time_elapsed))
return BUTTON_PRESS_LONG;
return BUTTON_PRESS_SHORT;
}
}
else {
if ( mtimeout < time_elapsed) {
if (longpress && (longpress < time_elapsed))
return BUTTON_PRESS_LONG;
return BUTTON_PRESS_SHORT;
}
}
}
return BUTTON_PRESS_NONE;
}
......@@ -558,8 +570,8 @@ static int buttons_set_method(struct ubus_context *ubus_ctx, struct ubus_object
static const struct ubus_method button_methods[] = {
// { .name = "status", .handler = button_status_method },
{ .name = "state", .handler = button_state_method },
{ .name = "press", .handler = button_press_method },
{ .name = "press_long", .handler = button_press_long_method },
// { .name = "press", .handler = button_press_method },
// { .name = "press_long", .handler = button_press_long_method },
};
static struct ubus_object_type button_object_type = UBUS_OBJECT_TYPE("button", button_methods);
......@@ -578,21 +590,19 @@ static struct ubus_object buttons_object = { .name = "buttons", .type = &buttons
static void add_buttons_to_ubus(struct server_ctx *s_ctx)
{
int ret = ubus_add_object(s_ctx->ubus_ctx, &buttons_object);
if (ret)
DBG(1,"Failed to add object: %s", ubus_strerror(ret));
/* struct ubus_object *ubo;
struct ubus_object *ubo;
int r;
char name[UBUS_BUTTON_NAME_PREPEND_LEN+BUTTON_MAX_NAME_LEN+1];
struct list_head *i;
/* register buttons object with ubus */
r = ubus_add_object(s_ctx->ubus_ctx, &buttons_object);
if (r)
DBG(1,"Failed to add object: %s", ubus_strerror(r));
struct list_head *i;
list_for_each(i, &buttons) {
struct function_button *node = list_entry(i, struct function_button, list);
{
/* register buttons object with ubus */
/* if((r = ubus_add_object(s_ctx->ubus_ctx, &buttons_object)))
DBG(1,"Failed to add object: %s", ubus_strerror(r));
ubo = malloc(sizeof(struct ubus_object));
memset(ubo, 0, sizeof(struct ubus_object));
......@@ -600,14 +610,14 @@ static void add_buttons_to_ubus(struct server_ctx *s_ctx)
snprintf(name, UBUS_BUTTON_NAME_PREPEND_LEN+BUTTON_MAX_NAME_LEN+1, "%s%s",
UBUS_BUTTON_NAME_PREPEND,
node->name);
ubo->name = strdup(node->name);
ubo->name = strdup(name);
ubo->methods = button_methods;
ubo->n_methods = ARRAY_SIZE(button_methods);
ubo->type = &button_object_type;
if((r = ubus_add_object(s_ctx->ubus_ctx, ubo)))
DBG(1,"Failed to add object: %s", ubus_strerror(r));
}
}*/
}
}
static void create_button(struct uci_context *ctx, struct uci_section *sec, int fixed)
......
......@@ -6,6 +6,7 @@
#define BUTTON_MAX_NAME_LEN 16
#define UBUS_BUTTON_NAME_PREPEND "button."
#define UBUS_BUTTON_NAME_PREPEND_LEN (sizeof(UBUS_BUTTON_NAME_PREPEND)-1)
#define BUTTON_STATE_MAX 3
typedef enum {
BUTTON_RELEASED,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment