@@ -22,7 +22,7 @@ struct prov_link {
22
22
const struct prov_bearer_cb * cb ;
23
23
void * cb_data ;
24
24
struct net_buf_simple * rx_buf ;
25
- struct k_delayed_work prot_timer ;
25
+ struct k_work_delayable prot_timer ;
26
26
};
27
27
28
28
static struct prov_link link ;
@@ -34,7 +34,8 @@ static void reset_state(void)
34
34
link .conn = NULL ;
35
35
}
36
36
37
- k_delayed_work_cancel (& link .prot_timer );
37
+ /* If this fails, the protocol timeout handler will exit early. */
38
+ (void )k_work_cancel_delayable (& link .prot_timer );
38
39
39
40
link .rx_buf = bt_mesh_proxy_get_buf ();
40
41
}
@@ -51,8 +52,12 @@ static void link_closed(enum prov_bearer_link_status status)
51
52
52
53
static void protocol_timeout (struct k_work * work )
53
54
{
54
- BT_DBG ("Protocol timeout" );
55
+ if (!link .conn ) {
56
+ /* Already disconnected */
57
+ return ;
58
+ }
55
59
60
+ BT_DBG ("Protocol timeout" );
56
61
link_closed (PROV_BEARER_LINK_STATUS_TIMEOUT );
57
62
}
58
63
@@ -70,7 +75,7 @@ int bt_mesh_pb_gatt_recv(struct bt_conn *conn, struct net_buf_simple *buf)
70
75
return - EINVAL ;
71
76
}
72
77
73
- k_delayed_work_submit (& link .prot_timer , PROTOCOL_TIMEOUT );
78
+ k_work_reschedule (& link .prot_timer , PROTOCOL_TIMEOUT );
74
79
75
80
link .cb -> recv (& pb_gatt , link .cb_data , buf );
76
81
@@ -86,7 +91,7 @@ int bt_mesh_pb_gatt_open(struct bt_conn *conn)
86
91
}
87
92
88
93
link .conn = bt_conn_ref (conn );
89
- k_delayed_work_submit (& link .prot_timer , PROTOCOL_TIMEOUT );
94
+ k_work_reschedule (& link .prot_timer , PROTOCOL_TIMEOUT );
90
95
91
96
link .cb -> link_opened (& pb_gatt , link .cb_data );
92
97
@@ -125,7 +130,7 @@ static int buf_send(struct net_buf_simple *buf, prov_bearer_send_complete_t cb,
125
130
return - ENOTCONN ;
126
131
}
127
132
128
- k_delayed_work_submit (& link .prot_timer , PROTOCOL_TIMEOUT );
133
+ k_work_reschedule (& link .prot_timer , PROTOCOL_TIMEOUT );
129
134
130
135
return bt_mesh_proxy_send (link .conn , BT_MESH_PROXY_PROV , buf );
131
136
}
@@ -137,7 +142,7 @@ static void clear_tx(void)
137
142
138
143
void pb_gatt_init (void )
139
144
{
140
- k_delayed_work_init (& link .prot_timer , protocol_timeout );
145
+ k_work_init_delayable (& link .prot_timer , protocol_timeout );
141
146
}
142
147
143
148
void pb_gatt_reset (void )
0 commit comments