39
39
40
40
LOG_MODULE_REGISTER (hawkbit , CONFIG_HAWKBIT_LOG_LEVEL );
41
41
42
- #define RECV_BUFFER_SIZE 640
43
- #define URL_BUFFER_SIZE 300
44
- #define SHA256_HASH_SIZE 32
45
- #define RESPONSE_BUFFER_SIZE 1100
46
- #define DDI_SECURITY_TOKEN_SIZE 32
47
- #define RANGE_HEADER_SIZE 50
48
- #define HAWKBIT_RECV_TIMEOUT (300 * MSEC_PER_SEC)
42
+ #define RECV_BUFFER_SIZE 640
43
+ #define URL_BUFFER_SIZE 300
44
+ #define SHA256_HASH_SIZE 32
45
+ #define RESPONSE_BUFFER_SIZE 1100
46
+ #define DDI_SECURITY_TOKEN_SIZE 32
47
+ #define RANGE_HEADER_SIZE 50
48
+ #define HAWKBIT_RECV_TIMEOUT (300 * MSEC_PER_SEC)
49
49
#define HAWKBIT_SET_SERVER_TIMEOUT K_MSEC(300)
50
50
51
51
#define HAWKBIT_JSON_URL "/" CONFIG_HAWKBIT_TENANT "/controller/v1"
52
52
53
53
#define HTTP_HEADER_CONTENT_TYPE_JSON "application/json;charset=UTF-8"
54
54
55
55
#define SLOT1_LABEL slot1_partition
56
- #define SLOT1_SIZE FIXED_PARTITION_SIZE(SLOT1_LABEL)
56
+ #define SLOT1_SIZE FIXED_PARTITION_SIZE(SLOT1_LABEL)
57
57
58
58
static uint32_t poll_sleep = (CONFIG_HAWKBIT_POLL_INTERVAL * SEC_PER_MIN );
59
59
@@ -90,12 +90,12 @@ static struct hawkbit_config {
90
90
} hb_cfg ;
91
91
92
92
#ifdef CONFIG_HAWKBIT_SET_SETTINGS_RUNTIME
93
- #define HAWKBIT_SERVER hb_cfg.server_addr
94
- #define HAWKBIT_PORT hb_cfg.server_port
93
+ #define HAWKBIT_SERVER hb_cfg.server_addr
94
+ #define HAWKBIT_PORT hb_cfg.server_port
95
95
#define HAWKBIT_PORT_INT atoi(hb_cfg.server_port)
96
96
#else
97
- #define HAWKBIT_SERVER CONFIG_HAWKBIT_SERVER
98
- #define HAWKBIT_PORT STRINGIFY(CONFIG_HAWKBIT_PORT)
97
+ #define HAWKBIT_SERVER CONFIG_HAWKBIT_SERVER
98
+ #define HAWKBIT_PORT STRINGIFY(CONFIG_HAWKBIT_PORT)
99
99
#define HAWKBIT_PORT_INT CONFIG_HAWKBIT_PORT
100
100
#endif /* CONFIG_HAWKBIT_SET_SETTINGS_RUNTIME */
101
101
@@ -161,7 +161,7 @@ enum hawkbit_state {
161
161
};
162
162
163
163
int hawkbit_default_config_data_cb (const char * device_id , uint8_t * buffer ,
164
- const size_t buffer_size );
164
+ const size_t buffer_size );
165
165
166
166
static hawkbit_config_device_data_cb_handler_t hawkbit_config_device_data_cb_handler =
167
167
hawkbit_default_config_data_cb ;
@@ -626,8 +626,7 @@ static char *hawkbit_get_url(const char *href)
626
626
/*
627
627
* Find URL component for the device cancel action id
628
628
*/
629
- static int hawkbit_find_cancel_action_id (struct hawkbit_ctl_res * res ,
630
- int32_t * cancel_action_id )
629
+ static int hawkbit_find_cancel_action_id (struct hawkbit_ctl_res * res , int32_t * cancel_action_id )
631
630
{
632
631
char * helper ;
633
632
@@ -885,12 +884,10 @@ static void response_json_cb(struct http_response *rsp, enum http_final_call fin
885
884
body_data = rsp -> body_frag_start ;
886
885
body_len = rsp -> body_frag_len ;
887
886
888
- if ((hb_context -> dl .downloaded_size + body_len ) >
889
- hb_context -> response_data_size ) {
890
- hb_context -> response_data_size =
891
- hb_context -> dl .downloaded_size + body_len ;
887
+ if ((hb_context -> dl .downloaded_size + body_len ) > hb_context -> response_data_size ) {
888
+ hb_context -> response_data_size = hb_context -> dl .downloaded_size + body_len ;
892
889
rsp_tmp = k_realloc (hb_context -> response_data ,
893
- hb_context -> response_data_size );
890
+ hb_context -> response_data_size );
894
891
if (rsp_tmp == NULL ) {
895
892
LOG_ERR ("Failed to realloc memory" );
896
893
hb_context -> code_status = HAWKBIT_ALLOC_ERROR ;
@@ -899,36 +896,35 @@ static void response_json_cb(struct http_response *rsp, enum http_final_call fin
899
896
900
897
hb_context -> response_data = rsp_tmp ;
901
898
}
902
- strncpy (hb_context -> response_data + hb_context -> dl .downloaded_size ,
903
- body_data , body_len );
899
+ strncpy (hb_context -> response_data + hb_context -> dl .downloaded_size , body_data ,
900
+ body_len );
904
901
hb_context -> dl .downloaded_size += body_len ;
905
902
}
906
903
907
904
if (final_data == HTTP_DATA_FINAL ) {
908
905
if (hb_context -> dl .http_content_size != hb_context -> dl .downloaded_size ) {
909
906
LOG_ERR ("HTTP response len mismatch, expected %d, got %d" ,
910
- hb_context -> dl .http_content_size ,
911
- hb_context -> dl .downloaded_size );
907
+ hb_context -> dl .http_content_size , hb_context -> dl .downloaded_size );
912
908
hb_context -> code_status = HAWKBIT_METADATA_ERROR ;
913
909
return ;
914
910
}
915
911
916
912
hb_context -> response_data [hb_context -> dl .downloaded_size ] = '\0' ;
917
913
memset (& hb_context -> results , 0 , sizeof (hb_context -> results ));
918
914
if (hb_context -> type == HAWKBIT_PROBE ) {
919
- ret = json_obj_parse (
920
- hb_context -> response_data , hb_context -> dl .downloaded_size ,
921
- json_ctl_res_descr , ARRAY_SIZE (json_ctl_res_descr ),
922
- & hb_context -> results .base );
915
+ ret = json_obj_parse (hb_context -> response_data ,
916
+ hb_context -> dl .downloaded_size , json_ctl_res_descr ,
917
+ ARRAY_SIZE (json_ctl_res_descr ),
918
+ & hb_context -> results .base );
923
919
if (ret < 0 ) {
924
920
LOG_ERR ("JSON parse error (%s): %d" , "HAWKBIT_PROBE" , ret );
925
921
hb_context -> code_status = HAWKBIT_METADATA_ERROR ;
926
922
}
927
923
} else {
928
- ret = json_obj_parse (
929
- hb_context -> response_data , hb_context -> dl .downloaded_size ,
930
- json_dep_res_descr , ARRAY_SIZE (json_dep_res_descr ),
931
- & hb_context -> results .dep );
924
+ ret = json_obj_parse (hb_context -> response_data ,
925
+ hb_context -> dl .downloaded_size , json_dep_res_descr ,
926
+ ARRAY_SIZE (json_dep_res_descr ),
927
+ & hb_context -> results .dep );
932
928
if (ret < 0 ) {
933
929
LOG_ERR ("JSON parse error (%s): %d" , "deploymentBase" , ret );
934
930
hb_context -> code_status = HAWKBIT_METADATA_ERROR ;
@@ -1605,6 +1601,7 @@ static void s_terminate(void *o)
1605
1601
smf_set_terminate (SMF_CTX (s ), s -> hb_context .code_status );
1606
1602
}
1607
1603
1604
+ /* clang-format off */
1608
1605
static const struct smf_state hawkbit_states [] = {
1609
1606
[S_HAWKBIT_START ] = SMF_CREATE_STATE (
1610
1607
s_start ,
@@ -1661,6 +1658,7 @@ static const struct smf_state hawkbit_states[] = {
1661
1658
NULL ,
1662
1659
NULL ),
1663
1660
};
1661
+ /* clang-format on */
1664
1662
1665
1663
enum hawkbit_response hawkbit_probe (void )
1666
1664
{
0 commit comments