summaryrefslogtreecommitdiff
path: root/cleopatre
diff options
context:
space:
mode:
authorJulien Lacour2013-10-28 14:04:17 +0100
committerJulien Lacour2013-11-05 16:58:02 +0100
commit482c9ec49877f8e7745d22042886e05b29d87239 (patch)
tree2bb10454af07f2af37263e64ffaf1ab6c6de8c8d /cleopatre
parent658e4cf356f13cfee5267259952d7b961371f949 (diff)
cleo/devkit/p1905: trigger push button event by hpav.info, refs #4257
The 1905 push button event was triggered by gpio rising edge. But now, managerd don't always process simple connect event by gpio rising edge. And push button event shall be processed only if simple connect event.
Diffstat (limited to 'cleopatre')
-rw-r--r--cleopatre/devkit/p1905_managerd/src/p1905_managerd.c57
-rw-r--r--cleopatre/devkit/p1905_managerd/src/p1905_push_button.c1
2 files changed, 35 insertions, 23 deletions
diff --git a/cleopatre/devkit/p1905_managerd/src/p1905_managerd.c b/cleopatre/devkit/p1905_managerd/src/p1905_managerd.c
index 31c046d52f..028bf524c2 100644
--- a/cleopatre/devkit/p1905_managerd/src/p1905_managerd.c
+++ b/cleopatre/devkit/p1905_managerd/src/p1905_managerd.c
@@ -16,9 +16,10 @@
#include "p1905_managerd.h"
#include "cmdu.h"
+#include "libspid.h"
#ifdef SUPPORT_WIFI
-#include "wifi_utils.h"
+#include "wifi_utils.h"
#endif
//#define P1905_MANAGERD_DEBUG
@@ -51,6 +52,7 @@ unsigned char nearest_bridge_group_address[6]
static unsigned char lldpdu_timer_expired = 0;
volatile sig_atomic_t timer_expired = 0;
volatile sig_atomic_t exit_signal = 0;
+volatile sig_atomic_t hpav_info_has_changed = 0;
static void p1905_timer_handler(int signum)
{
@@ -58,12 +60,16 @@ static void p1905_timer_handler(int signum)
exit_signal = 1;
else if (signum == SIGALRM)
timer_expired = 1;
+ else if (signum == SIGHUP)
+ hpav_info_has_changed = 1;
}
static void p1905_signal_handler(struct p1905_managerd_ctx *ctx)
{
static unsigned int cnt = 0;
int is_tpg_changed = 0;
+ libspid_hpav_info_t info;
+ memset (&info, 0, sizeof (libspid_hpav_info_t));
if(timer_expired)
{
@@ -73,7 +79,7 @@ static void p1905_signal_handler(struct p1905_managerd_ctx *ctx)
ctx->non_p1905_neighbor_dev);
if(is_tpg_changed)
- {
+ {
delete_non_p1905_neighbor_dev_info(ctx->non_p1905_neighbor_dev);
update_non_1905_device_from_fdb(&(ctx->topology_entry.tpddb_head),
ctx->non_p1905_neighbor_dev);
@@ -92,6 +98,22 @@ static void p1905_signal_handler(struct p1905_managerd_ctx *ctx)
#endif
}
+ if (hpav_info_has_changed)
+ {
+ hpav_info_has_changed = 0;
+ if (libspid_hpav_info_read_file (&info) == LIBSPID_SUCCESS)
+ {
+ if (info.is_sc_button)
+ {
+ if(0 > p1905_push_button_process(ctx))
+ {
+ debug_syslog("p1905_push_button_process fail \n");
+ return -1;
+ }
+ }
+ }
+ }
+
/* now this function be triggerd per second, use cnt to seperate
* different timer
*/
@@ -157,7 +179,7 @@ static void p1905_signal_handler(struct p1905_managerd_ctx *ctx)
if(ctx->almefd > 0)
{
wait_4_link_metric_rsp_timeout(ctx->almefd);
- close(ctx->almefd);
+ close(ctx->almefd);
ctx->almefd = -1;
}
else
@@ -392,6 +414,14 @@ static int p1905_managerd_init(struct p1905_managerd_ctx *ctx)
signal( SIGINT, p1905_timer_handler);
signal( SIGTERM, p1905_timer_handler);
+ // Register to signal SIGHUP on hpav.info modification.*/
+ if (LIBSPID_SUCCESS != libspid_system_file_update_register (
+ getpid(),
+ LIBSPID_HPAV_INFO_PATH, p1905_timer_handler))
+ {
+ return -1;
+ }
+
return 0;
}
@@ -423,7 +453,6 @@ static int p1905_managerd_process(struct p1905_managerd_ctx *ctx)
fd_set readfds, exceptfds;
FD_ZERO(&readfds);
- FD_ZERO(&exceptfds);
/*listen to cmdu message, by ether type*/
FD_SET(ctx->sock_br0, &readfds);
/*listen to lldp message, by ether type*/
@@ -432,18 +461,8 @@ static int p1905_managerd_process(struct p1905_managerd_ctx *ctx)
/*listen to socket for ALME*/
FD_SET(ctx->sock_alme, &readfds);
#endif
- /*listen to push button interrupt happen*/
- FD_SET(ctx->gpio_fd, &exceptfds);
-
- /* for listening GPIO interrupt, we must use exceptfds because of POLLPRI
- * is the return value from spc300_gpio_poll.
- * please check the function do_select() in select.c ==>
- * if ((mask & POLLEX_SET) && (ex & bit))
- * and the definition #define POLLEX_SET (POLLPRI)
- */
-
/*do not block signal in pselect, if any signal arrive , return errno = EINTR */
- result = pselect (ctx->gpio_fd + 1, &readfds, NULL, &exceptfds, NULL,&empty_sigmask);
+ result = pselect (ctx->gpio_fd + 1, &readfds, NULL, NULL, NULL,&empty_sigmask);
/*block signal from here*/
if (result > 0)
{
@@ -491,14 +510,6 @@ static int p1905_managerd_process(struct p1905_managerd_ctx *ctx)
alme_process(ctx, buffer, length);
}
#endif
- else if(FD_ISSET(ctx->gpio_fd, &exceptfds))
- {
- if(0 > p1905_push_button_process(ctx))
- {
- debug_syslog("p1905_push_button_process fail \n");
- return -1;
- }
- }
}
else
{
diff --git a/cleopatre/devkit/p1905_managerd/src/p1905_push_button.c b/cleopatre/devkit/p1905_managerd/src/p1905_push_button.c
index 96ba1e688d..d33c43b9d5 100644
--- a/cleopatre/devkit/p1905_managerd/src/p1905_push_button.c
+++ b/cleopatre/devkit/p1905_managerd/src/p1905_push_button.c
@@ -88,6 +88,7 @@ int p1905_push_button_process(struct p1905_managerd_ctx *ctx)
unsigned char sta_num = 0;
#endif
+ syslog (LOG_NOTICE, "push button process\n");
/*send 1905.1 push button event notification to eth port*/
ctx->mid ++;
insert_cmdu_txq(p1905_multicast_address, ctx->eth0_mac_addr,\