aboutsummaryrefslogtreecommitdiffstats
path: root/ctrl/facemgr
diff options
context:
space:
mode:
authorJordan Augé <jordan.auge+fdio@cisco.com>2020-12-14 13:40:55 +0100
committerJordan Augé <jordan.auge+fdio@cisco.com>2020-12-14 13:40:55 +0100
commita19882afff8306e46148b4f6456257c84e89443c (patch)
tree81acee7ed2171bf89925f2a3f16c666d85e4ef63 /ctrl/facemgr
parent72a9acca4500a9c07a4661fe112a1a212567fc9f (diff)
[HICN-660] Add priority priority control example based on RSSI
Change-Id: I745ad264b00e7fd3f7d09a9653779911f07becab Signed-off-by: Jordan Augé <jordan.auge+fdio@cisco.com>
Diffstat (limited to 'ctrl/facemgr')
-rw-r--r--ctrl/facemgr/src/interfaces/priority_controller/priority_controller.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/ctrl/facemgr/src/interfaces/priority_controller/priority_controller.c b/ctrl/facemgr/src/interfaces/priority_controller/priority_controller.c
index 9845796d2..67edc5e39 100644
--- a/ctrl/facemgr/src/interfaces/priority_controller/priority_controller.c
+++ b/ctrl/facemgr/src/interfaces/priority_controller/priority_controller.c
@@ -74,6 +74,7 @@ int priority_controller_tick(interface_t * interface, int fd, void * unused)
unsigned new_state = PREFER_BOTH;
jint rssi = (*data->env)->CallStaticIntMethod(data->env, data->cls, data->mid);
+ DEBUG("[priority_controller_tick] rssi=%d\n", rssi);
if (rssi > -67) {
new_state = PREFER_WIFI;
@@ -89,7 +90,7 @@ int priority_controller_tick(interface_t * interface, int fd, void * unused)
if (new_state == data->state)
return 0;
- ERROR("Setting priority to %s", prefer_str[new_state]);
+ ERROR("[priority_controller_tick] Setting priority to %s", prefer_str[new_state]);
/* XXX Factor this */
@@ -130,7 +131,6 @@ int priority_controller_tick(interface_t * interface, int fd, void * unused)
int priority_controller_initialize(interface_t * interface, void * cfg)
{
INFO("Initializing priority controller");
- struct sockaddr_in addr;
pc_data_t * data = malloc(sizeof(pc_data_t));
if (!data) {
@@ -165,6 +165,7 @@ int priority_controller_initialize(interface_t * interface, void * cfg)
data->state = PREFER_BOTH;
#else /* PRIORITY_CONTROLLER_INTERNAL */
+ struct sockaddr_in addr;
data->fd = socket(AF_INET, SOCK_DGRAM, 0);
//data->fd = socket(AF_INET, SOCK_STREAM, 0);
@@ -184,6 +185,8 @@ int priority_controller_initialize(interface_t * interface, void * cfg)
perror("bind error");
goto ERR_BIND;
}
+
+ DEBUG("[priority_controller_initialize] register fd");
if (interface_register_fd(interface, data->fd, NULL) < 0) {
ERROR("[priority_controller_initialize] Error registering fd");
goto ERR_FD;
@@ -214,10 +217,13 @@ int priority_controller_finalize(interface_t * interface)
pc_data_t * data = (pc_data_t*)interface->data;
#ifdef PRIORITY_CONTROLLER_INTERNAL
+ DEBUG("[priority_controller_finalize] unregister timer");
interface_unregister_timer(interface, data->fd);
#else
- if (data->fd > 0)
+ if (data->fd > 0) {
+ interface_unregister_fd(interface, data->fd);
close(data->fd);
+ }
free(data);
#endif /* PRIORITY_CONTROLLER_INTERNAL */