11/*
2- * Copyright (c) 2018, 2019 O.S.Systems
2+ * Copyright (c) 2018-2020 O.S.Systems
33 *
44 * SPDX-License-Identifier: Apache-2.0
55 */
@@ -66,6 +66,8 @@ static struct update_info {
6666 int image_size ;
6767} update_info ;
6868
69+ static struct k_delayed_work updatehub_work_handle ;
70+
6971static void wait_fds (void )
7072{
7173 if (poll (ctx .fds , ctx .nfds , NETWORK_TIMEOUT ) < 0 ) {
@@ -76,7 +78,7 @@ static void wait_fds(void)
7678static void prepare_fds (void )
7779{
7880 ctx .fds [ctx .nfds ].fd = ctx .sock ;
79- ctx .fds [ctx .nfds ].events = 1 ;
81+ ctx .fds [ctx .nfds ].events = POLLIN ;
8082 ctx .nfds ++ ;
8183}
8284
@@ -288,7 +290,7 @@ static int send_request(enum coap_msgtype msgtype, enum coap_method method,
288290 }
289291
290292 ret = coap_packet_append_payload (& request_packet ,
291- & ctx .payload ,
293+ ctx .payload ,
292294 strlen (ctx .payload ));
293295 if (ret < 0 ) {
294296 LOG_ERR ("Not able to append payload" );
@@ -614,8 +616,6 @@ enum updatehub_response updatehub_probe(void)
614616 goto error ;
615617 }
616618
617- k_sem_init (& ctx .semaphore , 0 , 1 );
618-
619619 if (!boot_is_img_confirmed ()) {
620620 LOG_ERR ("The current image is not confirmed" );
621621 ctx .code_status = UPDATEHUB_UNCONFIRMED_IMAGE ;
@@ -765,7 +765,7 @@ enum updatehub_response updatehub_update(void)
765765 return ctx .code_status ;
766766}
767767
768- static void autohandler (struct k_delayed_work * work )
768+ static void autohandler (struct k_work * work )
769769{
770770 switch (updatehub_probe ()) {
771771 case UPDATEHUB_UNCONFIRMED_IMAGE :
@@ -794,13 +794,11 @@ static void autohandler(struct k_delayed_work *work)
794794 break ;
795795 }
796796
797- k_delayed_work_submit (work , UPDATEHUB_POLL_INTERVAL );
797+ k_delayed_work_submit (& updatehub_work_handle , UPDATEHUB_POLL_INTERVAL );
798798}
799799
800800void updatehub_autohandler (void )
801801{
802- static struct k_delayed_work work ;
803-
804- k_delayed_work_init (& work , autohandler );
805- k_delayed_work_submit (& work , K_NO_WAIT );
802+ k_delayed_work_init (& updatehub_work_handle , autohandler );
803+ k_delayed_work_submit (& updatehub_work_handle , K_NO_WAIT );
806804}
0 commit comments