mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-01 04:20:33 +00:00
mesh: fix unused, shadowing, signed compares
This commit is contained in:
parent
85417dcb2e
commit
2983fbcb5f
@ -198,6 +198,7 @@ static void adv_bearer_emit_can_send_now(void){
|
||||
}
|
||||
|
||||
static void adv_bearer_timeout_handler(btstack_timer_source_t * ts){
|
||||
UNUSED(ts);
|
||||
uint32_t now = btstack_run_loop_get_time_ms();
|
||||
switch (adv_bearer_state){
|
||||
case STATE_GAP:
|
||||
|
@ -159,8 +159,8 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
||||
UNUSED(size);
|
||||
mesh_msg_sar_field_t msg_sar_field;
|
||||
|
||||
int pdu_segment_len;
|
||||
int pos;
|
||||
uint16_t pdu_segment_len;
|
||||
uint16_t pos;
|
||||
hci_con_handle_t con_handle;
|
||||
int send_to_mesh_network;
|
||||
|
||||
|
@ -74,7 +74,7 @@ static void * btstack_tlv_singleton_context;
|
||||
// Transitions
|
||||
static btstack_linked_list_t transitions;
|
||||
static btstack_timer_source_t transitions_timer;
|
||||
static int transition_step_min_ms;
|
||||
static uint32_t transition_step_min_ms;
|
||||
static uint8_t mesh_transaction_id_counter = 0;
|
||||
|
||||
static void mesh_access_setup_tlv(void){
|
||||
@ -994,7 +994,7 @@ void mesh_access_message_processed(mesh_pdu_t * pdu){
|
||||
}
|
||||
|
||||
int mesh_model_contains_subscription(mesh_model_t * mesh_model, uint16_t address){
|
||||
int i;
|
||||
uint16_t i;
|
||||
for (i=0;i<MAX_NR_MESH_SUBSCRIPTION_PER_MODEL;i++){
|
||||
if (mesh_model->subscriptions[i] == address) return 1;
|
||||
}
|
||||
@ -1274,14 +1274,14 @@ void mesh_delete_appkey_lists(void){
|
||||
}
|
||||
|
||||
void mesh_model_reset_appkeys(mesh_model_t * mesh_model){
|
||||
int i;
|
||||
uint16_t i;
|
||||
for (i=0;i<MAX_NR_MESH_APPKEYS_PER_MODEL;i++){
|
||||
mesh_model->appkey_indices[i] = MESH_APPKEY_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t mesh_model_bind_appkey(mesh_model_t * mesh_model, uint16_t appkey_index){
|
||||
int i;
|
||||
uint16_t i;
|
||||
for (i=0;i<MAX_NR_MESH_APPKEYS_PER_MODEL;i++){
|
||||
if (mesh_model->appkey_indices[i] == appkey_index) return MESH_FOUNDATION_STATUS_SUCCESS;
|
||||
}
|
||||
@ -1296,7 +1296,7 @@ uint8_t mesh_model_bind_appkey(mesh_model_t * mesh_model, uint16_t appkey_index)
|
||||
}
|
||||
|
||||
void mesh_model_unbind_appkey(mesh_model_t * mesh_model, uint16_t appkey_index){
|
||||
int i;
|
||||
uint16_t i;
|
||||
for (i=0;i<MAX_NR_MESH_APPKEYS_PER_MODEL;i++){
|
||||
if (mesh_model->appkey_indices[i] == appkey_index) {
|
||||
mesh_model->appkey_indices[i] = MESH_APPKEY_INVALID;
|
||||
@ -1591,6 +1591,8 @@ void mesh_access_key_refresh_revoke_keys(mesh_subnet_t * subnet){
|
||||
|
||||
static void mesh_access_secure_network_beacon_handler(uint8_t packet_type, uint16_t channel, uint8_t * packet, uint16_t size){
|
||||
UNUSED(channel);
|
||||
UNUSED(size);
|
||||
|
||||
if (packet_type != MESH_BEACON_PACKET) return;
|
||||
|
||||
// lookup subnet and netkey by network id
|
||||
|
@ -290,6 +290,8 @@ uint16_t mesh_model_get_model_id(uint32_t model_identifier);
|
||||
|
||||
uint32_t mesh_model_get_model_identifier(uint16_t vendor_id, uint16_t model_id);
|
||||
|
||||
uint16_t mesh_model_get_vendor_id(uint32_t model_identifier);
|
||||
|
||||
mesh_model_t * mesh_model_get_configuration_server(void);
|
||||
|
||||
mesh_model_t * mesh_access_model_for_address_and_model_identifier(uint16_t element_address, uint32_t model_identifier, uint8_t * status);
|
||||
|
@ -266,7 +266,7 @@ void mesh_delete_subscriptions(void){
|
||||
}
|
||||
|
||||
static uint8_t mesh_model_add_subscription(mesh_model_t * mesh_model, uint16_t address){
|
||||
int i;
|
||||
uint16_t i;
|
||||
for (i=0;i<MAX_NR_MESH_SUBSCRIPTION_PER_MODEL;i++){
|
||||
if (mesh_model->subscriptions[i] == address) return MESH_FOUNDATION_STATUS_SUCCESS;
|
||||
}
|
||||
@ -280,7 +280,7 @@ static uint8_t mesh_model_add_subscription(mesh_model_t * mesh_model, uint16_t a
|
||||
}
|
||||
|
||||
static void mesh_model_delete_subscription(mesh_model_t * mesh_model, uint16_t address){
|
||||
int i;
|
||||
uint16_t i;
|
||||
for (i=0;i<MAX_NR_MESH_SUBSCRIPTION_PER_MODEL;i++){
|
||||
if (mesh_model->subscriptions[i] == address) {
|
||||
mesh_model->subscriptions[i] = MESH_ADDRESS_UNSASSIGNED;
|
||||
@ -289,7 +289,7 @@ static void mesh_model_delete_subscription(mesh_model_t * mesh_model, uint16_t a
|
||||
}
|
||||
|
||||
static void mesh_model_delete_all_subscriptions(mesh_model_t * mesh_model){
|
||||
int i;
|
||||
uint16_t i;
|
||||
for (i=0;i<MAX_NR_MESH_SUBSCRIPTION_PER_MODEL;i++){
|
||||
mesh_model->subscriptions[i] = MESH_ADDRESS_UNSASSIGNED;
|
||||
}
|
||||
@ -472,7 +472,7 @@ static void config_server_send_message(uint16_t netkey_index, uint16_t dest, mes
|
||||
mesh_access_send_unacknowledged_pdu(pdu);
|
||||
}
|
||||
|
||||
static void config_composition_data_status(mesh_model_t * mesh_model, uint16_t netkey_index, uint16_t dest){
|
||||
static void config_composition_data_status(uint16_t netkey_index, uint16_t dest){
|
||||
|
||||
printf("Received Config Composition Data Get -> send Config Composition Data Status\n");
|
||||
|
||||
@ -493,10 +493,10 @@ static void config_composition_data_status(mesh_model_t * mesh_model, uint16_t n
|
||||
// Features - Relay, Proxy, Friend, Lower Power, ...
|
||||
mesh_access_transport_add_uint16(transport_pdu, 0);
|
||||
|
||||
mesh_element_iterator_t it;
|
||||
mesh_element_iterator_init(&it);
|
||||
while (mesh_element_iterator_has_next(&it)){
|
||||
mesh_element_t * element = mesh_element_iterator_next(&it);
|
||||
mesh_element_iterator_t element_it;
|
||||
mesh_element_iterator_init(&element_it);
|
||||
while (mesh_element_iterator_has_next(&element_it)){
|
||||
mesh_element_t * element = mesh_element_iterator_next(&element_it);
|
||||
|
||||
// Loc
|
||||
mesh_access_transport_add_uint16(transport_pdu, element->loc);
|
||||
@ -505,19 +505,19 @@ static void config_composition_data_status(mesh_model_t * mesh_model, uint16_t n
|
||||
// NumV
|
||||
mesh_access_transport_add_uint8( transport_pdu, element->models_count_vendor);
|
||||
|
||||
mesh_model_iterator_t it;
|
||||
mesh_model_iterator_t model_it;
|
||||
|
||||
// SIG Models
|
||||
mesh_model_iterator_init(&it, element);
|
||||
while (mesh_model_iterator_has_next(&it)){
|
||||
mesh_model_t * model = mesh_model_iterator_next(&it);
|
||||
mesh_model_iterator_init(&model_it, element);
|
||||
while (mesh_model_iterator_has_next(&model_it)){
|
||||
mesh_model_t * model = mesh_model_iterator_next(&model_it);
|
||||
if (!mesh_model_is_bluetooth_sig(model->model_identifier)) continue;
|
||||
mesh_access_transport_add_uint16(transport_pdu, model->model_identifier);
|
||||
}
|
||||
// Vendor Models
|
||||
mesh_model_iterator_init(&it, element);
|
||||
while (mesh_model_iterator_has_next(&it)){
|
||||
mesh_model_t * model = mesh_model_iterator_next(&it);
|
||||
mesh_model_iterator_init(&model_it, element);
|
||||
while (mesh_model_iterator_has_next(&model_it)){
|
||||
mesh_model_t * model = mesh_model_iterator_next(&model_it);
|
||||
if (mesh_model_is_bluetooth_sig(model->model_identifier)) continue;
|
||||
mesh_access_transport_add_uint32(transport_pdu, model->model_identifier);
|
||||
}
|
||||
@ -528,12 +528,14 @@ static void config_composition_data_status(mesh_model_t * mesh_model, uint16_t n
|
||||
}
|
||||
|
||||
static void config_composition_data_get_handler(mesh_model_t *mesh_model, mesh_pdu_t * pdu){
|
||||
config_composition_data_status(mesh_model, mesh_pdu_netkey_index(pdu), mesh_pdu_src(pdu));
|
||||
UNUSED(mesh_model);
|
||||
config_composition_data_status(mesh_pdu_netkey_index(pdu), mesh_pdu_src(pdu));
|
||||
|
||||
mesh_access_message_processed(pdu);
|
||||
}
|
||||
|
||||
static void config_model_beacon_status(mesh_model_t * mesh_model, uint16_t netkey_index, uint16_t dest){
|
||||
UNUSED(mesh_model);
|
||||
// setup message
|
||||
mesh_transport_pdu_t * transport_pdu = mesh_access_setup_segmented_message(&mesh_foundation_config_beacon_status,
|
||||
mesh_foundation_beacon_get());
|
||||
@ -569,6 +571,7 @@ static void config_beacon_set_handler(mesh_model_t *mesh_model, mesh_pdu_t * pdu
|
||||
}
|
||||
|
||||
static void config_model_default_ttl_status(mesh_model_t * mesh_model, uint16_t netkey_index, uint16_t dest){
|
||||
UNUSED(mesh_model);
|
||||
// setup message
|
||||
mesh_transport_pdu_t * transport_pdu = mesh_access_setup_segmented_message(
|
||||
&mesh_foundation_config_default_ttl_status, mesh_foundation_default_ttl_get());
|
||||
@ -603,6 +606,8 @@ static void config_default_ttl_set_handler(mesh_model_t *mesh_model, mesh_pdu_t
|
||||
}
|
||||
|
||||
static void config_friend_status(mesh_model_t * mesh_model, uint16_t netkey_index, uint16_t dest){
|
||||
UNUSED(mesh_model);
|
||||
|
||||
// setup message
|
||||
mesh_transport_pdu_t * transport_pdu = mesh_access_setup_segmented_message(
|
||||
&mesh_foundation_config_friend_status, mesh_foundation_friend_get());
|
||||
@ -640,6 +645,7 @@ static void config_friend_set_handler(mesh_model_t *mesh_model, mesh_pdu_t * pdu
|
||||
}
|
||||
|
||||
static void config_model_gatt_proxy_status(mesh_model_t * mesh_model, uint16_t netkey_index, uint16_t dest){
|
||||
UNUSED(mesh_model);
|
||||
// setup message
|
||||
mesh_transport_pdu_t * transport_pdu = mesh_access_setup_segmented_message(
|
||||
&mesh_foundation_config_gatt_proxy_status, mesh_foundation_gatt_proxy_get());
|
||||
@ -677,6 +683,8 @@ static void config_gatt_proxy_set_handler(mesh_model_t *mesh_model, mesh_pdu_t *
|
||||
}
|
||||
|
||||
static void config_model_relay_status(mesh_model_t * mesh_model, uint16_t netkey_index, uint16_t dest){
|
||||
UNUSED(mesh_model);
|
||||
|
||||
// setup message
|
||||
mesh_transport_pdu_t * transport_pdu = mesh_access_setup_segmented_message(&mesh_foundation_config_relay_status,
|
||||
mesh_foundation_relay_get(),
|
||||
@ -722,6 +730,8 @@ static void config_relay_set_handler(mesh_model_t *mesh_model, mesh_pdu_t * pdu)
|
||||
}
|
||||
|
||||
static void config_model_network_transmit_status(mesh_model_t * mesh_model, uint16_t netkey_index, uint16_t dest){
|
||||
UNUSED(mesh_model);
|
||||
|
||||
// setup message
|
||||
mesh_transport_pdu_t * transport_pdu = mesh_access_setup_segmented_message(
|
||||
&mesh_foundation_config_network_transmit_status, mesh_foundation_network_transmit_get());
|
||||
@ -760,6 +770,8 @@ void config_nekey_list_set_max(uint16_t max){
|
||||
}
|
||||
|
||||
static void config_netkey_status(mesh_model_t * mesh_model, uint16_t netkey_index, uint16_t dest, uint8_t status, uint16_t new_netkey_index){
|
||||
UNUSED(mesh_model);
|
||||
|
||||
// setup message
|
||||
mesh_transport_pdu_t * transport_pdu = mesh_access_setup_segmented_message(
|
||||
&mesh_foundation_config_netkey_status, status, new_netkey_index);
|
||||
@ -770,6 +782,8 @@ static void config_netkey_status(mesh_model_t * mesh_model, uint16_t netkey_inde
|
||||
}
|
||||
|
||||
static void config_netkey_list(mesh_model_t * mesh_model, uint16_t netkey_index, uint16_t dest) {
|
||||
UNUSED(mesh_model);
|
||||
|
||||
mesh_transport_pdu_t * transport_pdu = mesh_access_transport_init(MESH_FOUNDATION_OPERATION_NETKEY_LIST);
|
||||
if (!transport_pdu) return;
|
||||
|
||||
@ -984,6 +998,8 @@ static void config_netkey_get_handler(mesh_model_t * mesh_model, mesh_pdu_t * pd
|
||||
// AppKey List
|
||||
|
||||
static void config_appkey_status(mesh_model_t * mesh_model, uint16_t netkey_index, uint16_t dest, uint32_t netkey_and_appkey_index, uint8_t status){
|
||||
UNUSED(mesh_model);
|
||||
|
||||
// setup message
|
||||
mesh_transport_pdu_t * transport_pdu = mesh_access_setup_segmented_message(&mesh_foundation_config_appkey_status,
|
||||
status, netkey_and_appkey_index);
|
||||
@ -994,6 +1010,8 @@ static void config_appkey_status(mesh_model_t * mesh_model, uint16_t netkey_inde
|
||||
}
|
||||
|
||||
static void config_appkey_list(mesh_model_t * mesh_model, uint16_t netkey_index, uint16_t dest, uint32_t netkey_index_of_list){
|
||||
UNUSED(mesh_model);
|
||||
|
||||
mesh_transport_pdu_t * transport_pdu = mesh_access_transport_init(MESH_FOUNDATION_OPERATION_APPKEY_LIST);
|
||||
if (!transport_pdu) return;
|
||||
|
||||
@ -1219,6 +1237,8 @@ static void config_appkey_get_handler(mesh_model_t *mesh_model, mesh_pdu_t * pdu
|
||||
// Configuration Model Subscriptions (messages)
|
||||
|
||||
static void config_model_subscription_list_status(mesh_model_t * mesh_model, uint16_t netkey_index, uint16_t dest, uint8_t status, uint16_t element_address, uint32_t model_identifier, mesh_model_t * target_model){
|
||||
UNUSED(mesh_model);
|
||||
|
||||
uint16_t opcode;
|
||||
if (mesh_model_is_bluetooth_sig(model_identifier)){
|
||||
opcode = MESH_FOUNDATION_OPERATION_SIG_MODEL_SUBSCRIPTION_LIST;
|
||||
@ -1235,7 +1255,7 @@ static void config_model_subscription_list_status(mesh_model_t * mesh_model, uin
|
||||
mesh_access_transport_add_model_identifier(transport_pdu, model_identifier);
|
||||
|
||||
if (target_model != NULL){
|
||||
int i;
|
||||
uint16_t i;
|
||||
for (i = 0; i < MAX_NR_MESH_SUBSCRIPTION_PER_MODEL; i++){
|
||||
if (target_model->subscriptions[i] == MESH_ADDRESS_UNSASSIGNED) continue;
|
||||
if (mesh_network_address_virtual(target_model->subscriptions[i])) continue;
|
||||
@ -1260,6 +1280,8 @@ static void config_model_subscription_get_handler(mesh_model_t *mesh_model, mesh
|
||||
}
|
||||
|
||||
static void config_model_subscription_status(mesh_model_t * mesh_model, uint16_t netkey_index, uint16_t dest, uint8_t status, uint16_t element_address, uint16_t address, uint32_t model_identifier){
|
||||
UNUSED(mesh_model);
|
||||
|
||||
// setup message
|
||||
mesh_transport_pdu_t * transport_pdu = mesh_access_setup_segmented_message(&mesh_foundation_config_model_subscription_status,
|
||||
status, element_address, address, model_identifier);
|
||||
@ -1507,6 +1529,8 @@ static void config_model_subscription_delete_all_handler(mesh_model_t *mesh_mode
|
||||
// Configuration Model to AppKey List
|
||||
|
||||
static void config_model_app_status(mesh_model_t * mesh_model, uint16_t netkey_index, uint16_t dest, uint8_t status, uint16_t element_address, uint16_t appkey_index, uint32_t model_identifier){
|
||||
UNUSED(mesh_model);
|
||||
|
||||
// setup message
|
||||
mesh_transport_pdu_t * transport_pdu = mesh_access_setup_segmented_message(&mesh_foundation_config_model_app_status,
|
||||
status, element_address, appkey_index, model_identifier);
|
||||
@ -1517,6 +1541,8 @@ static void config_model_app_status(mesh_model_t * mesh_model, uint16_t netkey_i
|
||||
}
|
||||
|
||||
static void config_model_app_list(mesh_model_t * config_server_model, uint16_t netkey_index, uint16_t dest, uint8_t status, uint16_t element_address, uint32_t model_identifier, mesh_model_t * mesh_model){
|
||||
UNUSED(config_server_model);
|
||||
|
||||
uint16_t opcode;
|
||||
if (mesh_model_is_bluetooth_sig(model_identifier)){
|
||||
opcode = MESH_FOUNDATION_OPERATION_SIG_MODEL_APP_LIST;
|
||||
@ -1536,7 +1562,7 @@ static void config_model_app_list(mesh_model_t * config_server_model, uint16_t n
|
||||
|
||||
// add list of appkey indexes
|
||||
if (mesh_model){
|
||||
int i;
|
||||
uint16_t i;
|
||||
for (i=0;i<MAX_NR_MESH_APPKEYS_PER_MODEL;i++){
|
||||
uint16_t appkey_index = mesh_model->appkey_indices[i];
|
||||
if (appkey_index == MESH_APPKEY_INVALID) continue;
|
||||
@ -1610,7 +1636,7 @@ static void config_model_app_unbind_handler(mesh_model_t *config_server_model, m
|
||||
mesh_access_message_processed(pdu);
|
||||
}
|
||||
|
||||
static void config_model_app_get(mesh_model_t *config_server_model, mesh_pdu_t * pdu, int sig_model){
|
||||
static void config_model_app_get_handler(mesh_model_t *config_server_model, mesh_pdu_t * pdu){
|
||||
mesh_access_parser_state_t parser;
|
||||
mesh_access_parser_init(&parser, (mesh_pdu_t*) pdu);
|
||||
|
||||
@ -1623,14 +1649,6 @@ static void config_model_app_get(mesh_model_t *config_server_model, mesh_pdu_t *
|
||||
mesh_access_message_processed(pdu);
|
||||
}
|
||||
|
||||
static void config_sig_model_app_get_handler(mesh_model_t *config_server_model, mesh_pdu_t * pdu) {
|
||||
config_model_app_get(config_server_model, pdu, 1);
|
||||
}
|
||||
|
||||
static void config_vendor_model_app_get_handler(mesh_model_t *config_server_model, mesh_pdu_t * pdu) {
|
||||
config_model_app_get(config_server_model, pdu, 0);
|
||||
}
|
||||
|
||||
// Model Publication
|
||||
|
||||
static void config_model_publication_changed(mesh_model_t *mesh_model, mesh_publication_model_t * new_publication_model){
|
||||
@ -1655,6 +1673,8 @@ static void config_model_publication_changed(mesh_model_t *mesh_model, mesh_publ
|
||||
static void
|
||||
config_model_publication_status(mesh_model_t *mesh_model, uint16_t netkey_index, uint16_t dest, uint8_t status,
|
||||
uint16_t element_address, uint32_t model_identifier, mesh_publication_model_t *publication_model) {
|
||||
UNUSED(mesh_model);
|
||||
|
||||
// setup message
|
||||
uint16_t app_key_index_and_credential_flag = (publication_model->friendship_credential_flag << 12) | publication_model->appkey_index;
|
||||
mesh_transport_pdu_t * transport_pdu = mesh_access_setup_segmented_message(
|
||||
@ -1892,6 +1912,7 @@ static void config_heartbeat_publication_timeout_handler(btstack_timer_source_t
|
||||
}
|
||||
|
||||
static void config_heartbeat_publication_status(mesh_model_t *mesh_model, uint16_t netkey_index, uint16_t dest, uint8_t status, mesh_heartbeat_publication_t * mesh_heartbeat_publication){
|
||||
UNUSED(mesh_model);
|
||||
|
||||
// setup message
|
||||
uint8_t count_log = heartbeat_count_log(mesh_heartbeat_publication->count);
|
||||
@ -1978,6 +1999,7 @@ static void config_heartbeat_publication_get_handler(mesh_model_t *mesh_model, m
|
||||
// Heartbeat Subscription
|
||||
|
||||
static void config_heartbeat_subscription_status(mesh_model_t *mesh_model, uint16_t netkey_index, uint16_t dest, uint8_t status, mesh_heartbeat_subscription_t * mesh_heartbeat_subscription){
|
||||
UNUSED(mesh_model);
|
||||
|
||||
// setup message
|
||||
uint8_t count_log = heartbeat_count_log(mesh_heartbeat_subscription->count_log);
|
||||
@ -2068,11 +2090,13 @@ static void config_heartbeat_subscription_get_handler(mesh_model_t *mesh_model,
|
||||
|
||||
static void config_key_refresh_phase_status(mesh_model_t *mesh_model, uint16_t netkey_index_dest, uint16_t dest, uint8_t status, uint16_t netkey_index,
|
||||
mesh_key_refresh_state_t key_refresh_state){
|
||||
UNUSED(mesh_model);
|
||||
|
||||
// setup message
|
||||
mesh_transport_pdu_t * transport_pdu = mesh_access_setup_segmented_message(
|
||||
&mesh_key_refresh_phase_status,
|
||||
status,
|
||||
netkey_index_dest,
|
||||
netkey_index,
|
||||
key_refresh_state);
|
||||
if (!transport_pdu) return;
|
||||
|
||||
@ -2145,6 +2169,8 @@ static void config_key_refresh_phase_set_handler(mesh_model_t *mesh_model, mesh_
|
||||
|
||||
|
||||
static void config_node_reset_status(mesh_model_t *mesh_model, uint16_t netkey_index, uint16_t dest){
|
||||
UNUSED(mesh_model);
|
||||
|
||||
// setup message
|
||||
mesh_transport_pdu_t * transport_pdu = mesh_access_setup_segmented_message(&mesh_foundation_node_reset_status);
|
||||
if (!transport_pdu) return;
|
||||
@ -2160,6 +2186,8 @@ static void config_node_reset_handler(mesh_model_t *mesh_model, mesh_pdu_t * pdu
|
||||
}
|
||||
|
||||
static void low_power_node_poll_timeout_status(mesh_model_t *mesh_model, uint16_t netkey_index_dest, uint16_t dest, uint8_t status){
|
||||
UNUSED(mesh_model);
|
||||
|
||||
mesh_transport_pdu_t * transport_pdu = mesh_access_setup_segmented_message(
|
||||
&mesh_foundation_low_power_node_poll_timeout_status,
|
||||
status,
|
||||
@ -2181,11 +2209,13 @@ static void config_low_power_node_poll_timeout_get_handler(mesh_model_t *mesh_mo
|
||||
|
||||
static void config_node_identity_status(mesh_model_t *mesh_model, uint16_t netkey_index_dest, uint16_t dest, uint8_t status, uint16_t netkey_index,
|
||||
mesh_node_identity_state_t node_identity_state){
|
||||
UNUSED(mesh_model);
|
||||
|
||||
// setup message
|
||||
mesh_transport_pdu_t * transport_pdu = mesh_access_setup_segmented_message(
|
||||
&mesh_foundation_node_identity_status,
|
||||
status,
|
||||
netkey_index_dest,
|
||||
netkey_index,
|
||||
node_identity_state);
|
||||
if (!transport_pdu) return;
|
||||
|
||||
@ -2250,8 +2280,8 @@ const static mesh_operation_t mesh_configuration_server_model_operations[] = {
|
||||
{ MESH_FOUNDATION_OPERATION_MODEL_SUBSCRIPTION_DELETE_ALL, 4, config_model_subscription_delete_all_handler },
|
||||
{ MESH_FOUNDATION_OPERATION_SIG_MODEL_SUBSCRIPTION_GET, 4, config_model_subscription_get_handler },
|
||||
{ MESH_FOUNDATION_OPERATION_VENDOR_MODEL_SUBSCRIPTION_GET, 6, config_model_subscription_get_handler },
|
||||
{ MESH_FOUNDATION_OPERATION_SIG_MODEL_APP_GET, 4, config_sig_model_app_get_handler },
|
||||
{ MESH_FOUNDATION_OPERATION_VENDOR_MODEL_APP_GET, 6, config_vendor_model_app_get_handler },
|
||||
{ MESH_FOUNDATION_OPERATION_SIG_MODEL_APP_GET, 4, config_model_app_get_handler },
|
||||
{ MESH_FOUNDATION_OPERATION_VENDOR_MODEL_APP_GET, 6, config_model_app_get_handler },
|
||||
{ MESH_FOUNDATION_OPERATION_MODEL_PUBLICATION_SET, 11, config_model_publication_set_handler },
|
||||
{ MESH_FOUNDATION_OPERATION_MODEL_PUBLICATION_VIRTUAL_ADDRESS_SET, 25, config_model_publication_virtual_address_set_handler },
|
||||
{ MESH_FOUNDATION_OPERATION_MODEL_PUBLICATION_GET, 4, config_model_publication_get_handler },
|
||||
|
@ -197,6 +197,7 @@ static uint16_t * mesh_virtual_address_hash;
|
||||
static uint8_t mesh_virtual_address_temp[16];
|
||||
|
||||
static void mesh_virtual_address_temp_callback(void * arg){
|
||||
UNUSED(arg);
|
||||
uint16_t addr = (big_endian_read_16(mesh_virtual_address_temp, 14) & 0x3fff) | 0x8000;
|
||||
*mesh_virtual_address_hash = addr;
|
||||
(*mesh_virtual_address_callback)(mesh_virtual_address_arg);
|
||||
@ -228,6 +229,7 @@ static const uint8_t id128_tag[] = { 'i', 'd', '1', '2', '8', 0x01};
|
||||
static uint8_t k2_result[33];
|
||||
|
||||
static void mesh_network_key_derive_network_id_calculated(void * arg) {
|
||||
UNUSED(arg);
|
||||
// done
|
||||
(*mesh_network_key_derive_callback)(mesh_network_key_derive_arg);
|
||||
}
|
||||
|
@ -685,6 +685,7 @@ static void mesh_network_run(void){
|
||||
|
||||
#ifdef ENABLE_MESH_ADV_BEARER
|
||||
static void mesh_adv_bearer_handle_network_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
UNUSED(channel);
|
||||
mesh_network_pdu_t * network_pdu;
|
||||
|
||||
switch (packet_type){
|
||||
@ -751,6 +752,7 @@ static void mesh_network_gatt_bearer_outgoing_complete(void){
|
||||
}
|
||||
|
||||
static void mesh_network_gatt_bearer_handle_network_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
UNUSED(channel);
|
||||
switch (packet_type){
|
||||
case MESH_PROXY_DATA_PACKET:
|
||||
if (mesh_foundation_gatt_proxy_get() == 0) break;
|
||||
@ -799,6 +801,7 @@ static void mesh_network_gatt_bearer_handle_network_event(uint8_t packet_type, u
|
||||
|
||||
#ifdef ENABLE_MESH_GATT_BEARER
|
||||
static void mesh_netework_gatt_bearer_handle_proxy_configuration(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
UNUSED(channel);
|
||||
switch (packet_type){
|
||||
case MESH_PROXY_DATA_PACKET:
|
||||
mesh_network_process_proxy_configuration_message(packet, size);
|
||||
|
@ -147,7 +147,7 @@ static void (*mesh_control_message_handler)(mesh_pdu_t * pdu);
|
||||
static btstack_linked_list_t upper_transport_incoming;
|
||||
|
||||
|
||||
void mesh_upper_unsegmented_control_message_received(mesh_network_pdu_t * network_pdu){
|
||||
static void mesh_upper_unsegmented_control_message_received(mesh_network_pdu_t * network_pdu){
|
||||
uint8_t * lower_transport_pdu = mesh_network_pdu_data(network_pdu);
|
||||
uint8_t opcode = lower_transport_pdu[0];
|
||||
if (mesh_control_message_handler){
|
||||
@ -486,7 +486,7 @@ static void mesh_upper_transport_process_message(mesh_transport_pdu_t * transpor
|
||||
mesh_upper_transport_validate_segmented_message(transport_pdu);
|
||||
}
|
||||
|
||||
void mesh_upper_transport_message_received(mesh_pdu_t * pdu){
|
||||
static void mesh_upper_transport_message_received(mesh_pdu_t * pdu){
|
||||
btstack_linked_list_add_tail(&upper_transport_incoming, (btstack_linked_item_t*) pdu);
|
||||
mesh_transport_run();
|
||||
}
|
||||
@ -508,7 +508,7 @@ void mesh_upper_transport_pdu_free(mesh_pdu_t * pdu){
|
||||
}
|
||||
}
|
||||
|
||||
void mesh_upper_transport_pdu_handler(mesh_transport_callback_type_t callback_type, mesh_transport_status_t status, mesh_pdu_t * pdu){
|
||||
static void mesh_upper_transport_pdu_handler(mesh_transport_callback_type_t callback_type, mesh_transport_status_t status, mesh_pdu_t * pdu){
|
||||
switch (callback_type){
|
||||
case MESH_TRANSPORT_PDU_RECEIVED:
|
||||
mesh_upper_transport_message_received(pdu);
|
||||
|
@ -141,16 +141,16 @@ static void pb_adv_emit_pdu_sent(uint8_t status){
|
||||
pb_adv_packet_handler(HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||
}
|
||||
|
||||
static void pb_adv_emit_link_open(uint8_t status, uint16_t pb_adv_cid){
|
||||
static void pb_adv_emit_link_open(uint8_t status, uint16_t the_pb_adv_cid){
|
||||
uint8_t event[7] = { HCI_EVENT_MESH_META, 5, MESH_SUBEVENT_PB_TRANSPORT_LINK_OPEN, status};
|
||||
little_endian_store_16(event, 4, pb_adv_cid);
|
||||
little_endian_store_16(event, 4, the_pb_adv_cid);
|
||||
event[6] = PB_TYPE_ADV;
|
||||
pb_adv_packet_handler(HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||
}
|
||||
|
||||
static void pb_adv_emit_link_close(uint16_t pb_adv_cid, uint8_t reason){
|
||||
static void pb_adv_emit_link_close(uint16_t the_pb_adv_cid, uint8_t reason){
|
||||
uint8_t event[5] = { HCI_EVENT_MESH_META, 3, MESH_SUBEVENT_PB_TRANSPORT_LINK_CLOSED};
|
||||
little_endian_store_16(event, 4, pb_adv_cid);
|
||||
little_endian_store_16(event, 4, the_pb_adv_cid);
|
||||
pb_adv_packet_handler(HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||
}
|
||||
|
||||
@ -370,6 +370,7 @@ static int pb_adv_packet_to_send(void){
|
||||
}
|
||||
|
||||
static void pb_adv_timer_handler(btstack_timer_source_t * ts){
|
||||
UNUSED(ts);
|
||||
pb_adv_random_delay_active = 0;
|
||||
if (!pb_adv_packet_to_send()) return;
|
||||
adv_bearer_request_can_send_now_for_provisioning_pdu();
|
||||
@ -389,6 +390,8 @@ static void pb_adv_run(void){
|
||||
}
|
||||
|
||||
static void pb_adv_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
UNUSED(channel);
|
||||
|
||||
if (packet_type != HCI_EVENT_PACKET) return;
|
||||
const uint8_t * data;
|
||||
uint8_t length;
|
||||
@ -565,8 +568,8 @@ void pb_adv_register_packet_handler(btstack_packet_handler_t packet_handler){
|
||||
pb_adv_packet_handler = packet_handler;
|
||||
}
|
||||
|
||||
void pb_adv_send_pdu(uint16_t pb_adv_cid, const uint8_t * pdu, uint16_t size){
|
||||
UNUSED(pb_adv_cid);
|
||||
void pb_adv_send_pdu(uint16_t the_pb_adv_cid, const uint8_t * pdu, uint16_t size){
|
||||
UNUSED(the_pb_adv_cid);
|
||||
printf("PB-ADV: Send packet ");
|
||||
printf_hexdump(pdu, size);
|
||||
pb_adv_msg_out_buffer = pdu;
|
||||
@ -579,14 +582,14 @@ void pb_adv_send_pdu(uint16_t pb_adv_cid, const uint8_t * pdu, uint16_t size){
|
||||
|
||||
/**
|
||||
* Close Link
|
||||
* @param pb_adv_cid
|
||||
* @param the_pb_adv_cid
|
||||
*/
|
||||
void pb_adv_close_link(uint16_t pb_adv_cid, uint8_t reason){
|
||||
void pb_adv_close_link(uint16_t the_pb_adv_cid, uint8_t reason){
|
||||
switch (link_state){
|
||||
case LINK_STATE_W4_ACK:
|
||||
case LINK_STATE_OPEN:
|
||||
case LINK_STATE_W2_SEND_ACK:
|
||||
pb_adv_emit_link_close(pb_adv_cid, 0);
|
||||
pb_adv_emit_link_close(the_pb_adv_cid, 0);
|
||||
link_state = LINK_STATE_CLOSING;
|
||||
pb_adv_link_close_countdown = 3;
|
||||
pb_adv_link_close_reason = reason;
|
||||
|
@ -80,8 +80,8 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
||||
UNUSED(size);
|
||||
mesh_msg_sar_field_t msg_sar_field;
|
||||
mesh_msg_type_t msg_type;
|
||||
int pdu_segment_len;
|
||||
int pos;
|
||||
uint16_t pdu_segment_len;
|
||||
uint16_t pos;
|
||||
hci_con_handle_t con_handle;
|
||||
|
||||
switch (packet_type) {
|
||||
@ -223,6 +223,8 @@ void pb_gatt_send_pdu(uint16_t con_handle, const uint8_t * pdu, uint16_t size){
|
||||
* @param reason 0 = success, 1 = timeout, 2 = fail
|
||||
*/
|
||||
void pb_gatt_close_link(hci_con_handle_t con_handle, uint8_t reason){
|
||||
UNUSED(con_handle);
|
||||
UNUSED(reason);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -231,5 +233,6 @@ void pb_gatt_close_link(hci_con_handle_t con_handle, uint8_t reason){
|
||||
* @returns con_handle or HCI_CON_HANDLE_INVALID
|
||||
*/
|
||||
uint16_t pb_gatt_create_link(const uint8_t * device_uuid){
|
||||
UNUSED(device_uuid);
|
||||
return HCI_CON_HANDLE_INVALID;
|
||||
}
|
||||
|
@ -339,6 +339,7 @@ static void provisioning_done(void){
|
||||
}
|
||||
|
||||
static void provisioning_handle_auth_value_output_oob(void * arg){
|
||||
UNUSED(arg);
|
||||
// limit auth value to single digit
|
||||
auth_value[15] = auth_value[15] % 9 + 1;
|
||||
|
||||
@ -564,7 +565,6 @@ static void provisioning_handle_public_key(uint8_t *packet, uint16_t size){
|
||||
}
|
||||
|
||||
static void provisioning_handle_confirmation_device_calculated(void * arg){
|
||||
|
||||
UNUSED(arg);
|
||||
|
||||
printf("ConfirmationDevice: ");
|
||||
@ -575,6 +575,8 @@ static void provisioning_handle_confirmation_device_calculated(void * arg){
|
||||
}
|
||||
|
||||
static void provisioning_handle_confirmation_random_device(void * arg){
|
||||
UNUSED(arg);
|
||||
|
||||
// re-use prov_confirmation_inputs buffer
|
||||
memcpy(&prov_confirmation_inputs[0], random_device, 16);
|
||||
memcpy(&prov_confirmation_inputs[16], auth_value, 16);
|
||||
@ -584,6 +586,8 @@ static void provisioning_handle_confirmation_random_device(void * arg){
|
||||
}
|
||||
|
||||
static void provisioning_handle_confirmation_k1_calculated(void * arg){
|
||||
UNUSED(arg);
|
||||
|
||||
printf("ConfirmationKey: ");
|
||||
printf_hexdump(confirmation_key, sizeof(confirmation_key));
|
||||
|
||||
@ -606,7 +610,6 @@ static void provisioning_handle_confirmation_s1_calculated(void * arg){
|
||||
}
|
||||
|
||||
static void provisioning_handle_confirmation(uint8_t *packet, uint16_t size){
|
||||
|
||||
UNUSED(size);
|
||||
UNUSED(packet);
|
||||
|
||||
@ -680,6 +683,8 @@ static void provisioning_handle_random(uint8_t *packet, uint16_t size){
|
||||
|
||||
// PROV_DATA
|
||||
static void provisioning_handle_network_dervived(void * arg){
|
||||
UNUSED(arg);
|
||||
|
||||
provisioning_timer_stop();
|
||||
|
||||
// notify client
|
||||
@ -691,6 +696,8 @@ static void provisioning_handle_network_dervived(void * arg){
|
||||
}
|
||||
|
||||
static void provisioning_handle_data_device_key(void * arg){
|
||||
UNUSED(arg);
|
||||
|
||||
// derive full network key
|
||||
mesh_network_key_derive(&prov_cmac_request, network_key, &provisioning_handle_network_dervived, NULL);
|
||||
}
|
||||
@ -732,11 +739,13 @@ static void provisioning_handle_data(uint8_t *packet, uint16_t size){
|
||||
}
|
||||
|
||||
static void provisioning_handle_unexpected_pdu(uint8_t *packet, uint16_t size){
|
||||
UNUSED(size);
|
||||
printf("Unexpected PDU #%u in state #%u\n", packet[0], (int) device_state);
|
||||
provisioning_handle_provisioning_error(0x03);
|
||||
}
|
||||
|
||||
static void provisioning_handle_pdu(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
UNUSED(channel);
|
||||
|
||||
if (size < 1) return;
|
||||
|
||||
@ -905,10 +914,10 @@ mesh_network_key_t * provisioning_device_data_get_network_key(void){
|
||||
return network_key;
|
||||
}
|
||||
|
||||
void provisioning_device_data_get(mesh_provisioning_data_t * provisioning_data){
|
||||
provisioning_data->unicast_address = unicast_address;
|
||||
provisioning_data->iv_index = iv_index;
|
||||
provisioning_data->flags = flags;
|
||||
memcpy(provisioning_data->device_key, device_key, 16);
|
||||
provisioning_data->network_key = network_key;
|
||||
void provisioning_device_data_get(mesh_provisioning_data_t * the_provisioning_data){
|
||||
the_provisioning_data->unicast_address = unicast_address;
|
||||
the_provisioning_data->iv_index = iv_index;
|
||||
the_provisioning_data->flags = flags;
|
||||
memcpy(the_provisioning_data->device_key, device_key, 16);
|
||||
the_provisioning_data->network_key = network_key;
|
||||
}
|
||||
|
@ -142,18 +142,18 @@ static void provisioning_attention_timer_set(void){
|
||||
}
|
||||
#endif
|
||||
|
||||
static void provisioning_emit_output_oob_event(uint16_t pb_adv_cid, uint32_t number){
|
||||
static void provisioning_emit_output_oob_event(uint16_t the_pb_adv_cid, uint32_t number){
|
||||
if (!prov_packet_handler) return;
|
||||
uint8_t event[9] = { HCI_EVENT_MESH_META, 7, MESH_SUBEVENT_PB_PROV_START_EMIT_OUTPUT_OOB};
|
||||
little_endian_store_16(event, 3, pb_adv_cid);
|
||||
little_endian_store_16(event, 3, the_pb_adv_cid);
|
||||
little_endian_store_16(event, 5, number);
|
||||
prov_packet_handler(HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||
}
|
||||
|
||||
static void provisioning_emit_event(uint8_t mesh_subevent, uint16_t pb_adv_cid){
|
||||
static void provisioning_emit_event(uint8_t mesh_subevent, uint16_t the_pb_adv_cid){
|
||||
if (!prov_packet_handler) return;
|
||||
uint8_t event[5] = { HCI_EVENT_MESH_META, 3, mesh_subevent};
|
||||
little_endian_store_16(event, 3, pb_adv_cid);
|
||||
little_endian_store_16(event, 3, the_pb_adv_cid);
|
||||
prov_packet_handler(HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||
}
|
||||
|
||||
@ -179,57 +179,57 @@ static void provisioning_timer_stop(void){
|
||||
|
||||
// Outgoing Provisioning PDUs
|
||||
|
||||
static void provisioning_send_invite(uint16_t pb_adv_cid){
|
||||
static void provisioning_send_invite(uint16_t the_pb_adv_cid){
|
||||
prov_buffer_out[0] = MESH_PROV_INVITE;
|
||||
prov_buffer_out[1] = prov_attention_timer;
|
||||
pb_adv_send_pdu(pb_adv_cid, prov_buffer_out, 2);
|
||||
pb_adv_send_pdu(the_pb_adv_cid, prov_buffer_out, 2);
|
||||
// collect confirmation_inputs
|
||||
memcpy(&prov_confirmation_inputs[0], &prov_buffer_out[1], 1);
|
||||
}
|
||||
|
||||
static void provisioning_send_start(uint16_t pb_adv_cid){
|
||||
static void provisioning_send_start(uint16_t the_pb_adv_cid){
|
||||
prov_buffer_out[0] = MESH_PROV_START;
|
||||
prov_buffer_out[1] = prov_start_algorithm;
|
||||
prov_buffer_out[2] = prov_start_public_key_used;
|
||||
prov_buffer_out[3] = prov_start_authentication_method;
|
||||
prov_buffer_out[4] = prov_start_authentication_action;
|
||||
prov_buffer_out[5] = prov_start_authentication_size;
|
||||
pb_adv_send_pdu(pb_adv_cid, prov_buffer_out, 6);
|
||||
pb_adv_send_pdu(the_pb_adv_cid, prov_buffer_out, 6);
|
||||
// store for confirmation inputs: len 5
|
||||
memcpy(&prov_confirmation_inputs[12], &prov_buffer_out[1], 5);
|
||||
}
|
||||
|
||||
static void provisioning_send_provisioning_error(void){
|
||||
static void provisioning_send_provisioning_error(uint16_t the_pb_adv_cid){
|
||||
prov_buffer_out[0] = MESH_PROV_FAILED;
|
||||
prov_buffer_out[1] = prov_error_code;
|
||||
pb_adv_send_pdu(pb_adv_cid, prov_buffer_out, 2);
|
||||
pb_adv_send_pdu(the_pb_adv_cid, prov_buffer_out, 2);
|
||||
}
|
||||
|
||||
static void provisioning_send_public_key(void){
|
||||
static void provisioning_send_public_key(uint16_t the_pb_adv_cid){
|
||||
prov_buffer_out[0] = MESH_PROV_PUB_KEY;
|
||||
memcpy(&prov_buffer_out[1], prov_ec_q, 64);
|
||||
pb_adv_send_pdu(pb_adv_cid, prov_buffer_out, 65);
|
||||
pb_adv_send_pdu(the_pb_adv_cid, prov_buffer_out, 65);
|
||||
// store for confirmation inputs: len 64
|
||||
memcpy(&prov_confirmation_inputs[17], &prov_buffer_out[1], 64);
|
||||
}
|
||||
|
||||
static void provisioning_send_confirm(void){
|
||||
static void provisioning_send_confirm(uint16_t the_pb_adv_cid){
|
||||
prov_buffer_out[0] = MESH_PROV_CONFIRM;
|
||||
memcpy(&prov_buffer_out[1], confirmation_provisioner, 16);
|
||||
pb_adv_send_pdu(pb_adv_cid, prov_buffer_out, 17);
|
||||
pb_adv_send_pdu(the_pb_adv_cid, prov_buffer_out, 17);
|
||||
}
|
||||
|
||||
static void provisioning_send_random(void){
|
||||
static void provisioning_send_random(uint16_t the_pb_adv_cid){
|
||||
prov_buffer_out[0] = MESH_PROV_RANDOM;
|
||||
memcpy(&prov_buffer_out[1], random_provisioner, 16);
|
||||
pb_adv_send_pdu(pb_adv_cid, prov_buffer_out, 17);
|
||||
pb_adv_send_pdu(the_pb_adv_cid, prov_buffer_out, 17);
|
||||
}
|
||||
|
||||
static void provisioning_send_data(void){
|
||||
static void provisioning_send_data(uint16_t the_pb_adv_cid){
|
||||
prov_buffer_out[0] = MESH_PROV_DATA;
|
||||
memcpy(&prov_buffer_out[1], enc_provisioning_data, 25);
|
||||
memcpy(&prov_buffer_out[26], provisioning_data_mic, 8);
|
||||
pb_adv_send_pdu(pb_adv_cid, prov_buffer_out, 34);
|
||||
pb_adv_send_pdu(the_pb_adv_cid, prov_buffer_out, 34);
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
@ -261,7 +261,7 @@ static void provisioning_run(void){
|
||||
switch (provisioner_state){
|
||||
case PROVISIONER_SEND_ERROR:
|
||||
start_timer = 0; // game over
|
||||
provisioning_send_provisioning_error();
|
||||
provisioning_send_provisioning_error(pb_adv_cid);
|
||||
break;
|
||||
case PROVISIONER_SEND_INVITE:
|
||||
provisioning_send_invite(pb_adv_cid);
|
||||
@ -281,7 +281,7 @@ static void provisioning_run(void){
|
||||
provisioning_emit_event(MESH_SUBEVENT_PB_PROV_START_RECEIVE_PUBLIC_KEY_OOB, 1);
|
||||
break;
|
||||
case PROVISIONER_SEND_PUB_KEY:
|
||||
provisioning_send_public_key();
|
||||
provisioning_send_public_key(pb_adv_cid);
|
||||
if (prov_start_public_key_used){
|
||||
provisioning_public_key_ready();
|
||||
} else {
|
||||
@ -289,15 +289,15 @@ static void provisioning_run(void){
|
||||
}
|
||||
break;
|
||||
case PROVISIONER_SEND_CONFIRM:
|
||||
provisioning_send_confirm();
|
||||
provisioning_send_confirm(pb_adv_cid);
|
||||
provisioner_state = PROVISIONER_W4_CONFIRM;
|
||||
break;
|
||||
case PROVISIONER_SEND_RANDOM:
|
||||
provisioning_send_random();
|
||||
provisioning_send_random(pb_adv_cid);
|
||||
provisioner_state = PROVISIONER_W4_RANDOM;
|
||||
break;
|
||||
case PROVISIONER_SEND_DATA:
|
||||
provisioning_send_data();
|
||||
provisioning_send_data(pb_adv_cid);
|
||||
provisioner_state = PROVISIONER_W4_COMPLETE;
|
||||
break;
|
||||
default:
|
||||
@ -331,11 +331,12 @@ static void provisioning_handle_provisioning_error(uint8_t error_code){
|
||||
provisioning_run();
|
||||
}
|
||||
|
||||
static void provisioning_handle_link_opened(uint16_t pb_adv_cid){
|
||||
static void provisioning_handle_link_opened(uint16_t the_pb_adv_cid){
|
||||
UNUSED(the_pb_adv_cid);
|
||||
provisioner_state = PROVISIONER_SEND_INVITE;
|
||||
}
|
||||
|
||||
static void provisioning_handle_capabilities(uint16_t pb_adv_cid, const uint8_t * packet_data, uint16_t packet_len){
|
||||
static void provisioning_handle_capabilities(uint16_t the_pb_adv_cid, const uint8_t * packet_data, uint16_t packet_len){
|
||||
|
||||
if (packet_len != 11) return;
|
||||
|
||||
@ -346,7 +347,7 @@ static void provisioning_handle_capabilities(uint16_t pb_adv_cid, const uint8_t
|
||||
|
||||
// notify client and wait for auth method selection
|
||||
uint8_t event[16] = { HCI_EVENT_MESH_META, 3, MESH_SUBEVENT_PB_PROV_CAPABILITIES};
|
||||
little_endian_store_16(event, 3, pb_adv_cid);
|
||||
little_endian_store_16(event, 3, the_pb_adv_cid);
|
||||
event[5] = packet_data[0];
|
||||
little_endian_store_16(event, 6, big_endian_read_16(packet_data, 1));
|
||||
event[8] = packet_data[3];
|
||||
@ -369,6 +370,8 @@ static void provisioning_handle_confirmation_provisioner_calculated(void * arg){
|
||||
}
|
||||
|
||||
static void provisioning_handle_random_provisioner(void * arg){
|
||||
UNUSED(arg);
|
||||
|
||||
printf("RandomProvisioner: ");
|
||||
printf_hexdump(random_provisioner, sizeof(random_provisioner));
|
||||
|
||||
@ -381,6 +384,8 @@ static void provisioning_handle_random_provisioner(void * arg){
|
||||
}
|
||||
|
||||
static void provisioning_handle_confirmation_k1_calculated(void * arg){
|
||||
UNUSED(arg);
|
||||
|
||||
printf("ConfirmationKey: ");
|
||||
printf_hexdump(confirmation_key, sizeof(confirmation_key));
|
||||
|
||||
@ -409,6 +414,7 @@ static void provisioning_handle_auth_value_ready(void){
|
||||
}
|
||||
|
||||
static void provisioning_handle_auth_value_input_oob(void * arg){
|
||||
UNUSED(arg);
|
||||
|
||||
// limit auth value to single digit
|
||||
auth_value[15] = auth_value[15] % 9 + 1;
|
||||
@ -430,7 +436,8 @@ static void provisioning_handle_auth_value_input_oob(void * arg){
|
||||
provisioner_state = PROVISIONER_W4_INPUT_COMPLETE;
|
||||
}
|
||||
|
||||
static void provisioning_handle_input_complete(uint16_t pb_adv_cid){
|
||||
static void provisioning_handle_input_complete(uint16_t the_pb_adv_cid){
|
||||
UNUSED(the_pb_adv_cid);
|
||||
provisioning_handle_auth_value_ready();
|
||||
}
|
||||
|
||||
@ -493,14 +500,13 @@ static void provisioning_public_key_ready(void){
|
||||
btstack_crypto_ecc_p256_calculate_dhkey(&prov_ecc_p256_request, remote_ec_q, dhkey, provisioning_handle_public_key_dhkey, NULL);
|
||||
}
|
||||
|
||||
static void provisioning_handle_public_key(uint16_t pb_adv_cid, const uint8_t *packet_data, uint16_t packet_len){
|
||||
|
||||
static void provisioning_handle_public_key(uint16_t the_pb_adv_cid, const uint8_t *packet_data, uint16_t packet_len){
|
||||
// validate public key
|
||||
if (packet_len != sizeof(remote_ec_q) || btstack_crypto_ecc_p256_validate_public_key(packet_data) != 0){
|
||||
printf("Public Key invalid, abort provisioning\n");
|
||||
|
||||
// disconnect provisioning link
|
||||
pb_adv_close_link(pb_adv_cid, 0x02); // reason: fail
|
||||
pb_adv_close_link(the_pb_adv_cid, 0x02); // reason: fail
|
||||
provisioning_timer_stop();
|
||||
return;
|
||||
}
|
||||
@ -526,8 +532,9 @@ static void provisioning_handle_public_key(uint16_t pb_adv_cid, const uint8_t *p
|
||||
provisioning_public_key_ready();
|
||||
}
|
||||
|
||||
static void provisioning_handle_confirmation(uint16_t pb_adv_cid, const uint8_t *packet_data, uint16_t packet_len){
|
||||
static void provisioning_handle_confirmation(uint16_t the_pb_adv_cid, const uint8_t *packet_data, uint16_t packet_len){
|
||||
|
||||
UNUSED(the_pb_adv_cid);
|
||||
UNUSED(packet_data);
|
||||
UNUSED(packet_len);
|
||||
|
||||
@ -610,9 +617,9 @@ static void provisioning_handle_provisioning_salt_calculated(void * arg){
|
||||
mesh_k1(&prov_cmac_request, dhkey, sizeof(dhkey), provisioning_salt, (const uint8_t*) "prsk", 4, session_key, &provisioning_handle_session_key_calculated, NULL);
|
||||
}
|
||||
|
||||
static void provisioning_handle_random(uint16_t pb_adv_cid, const uint8_t *packet_data, uint16_t packet_len){
|
||||
static void provisioning_handle_random(uint16_t the_pb_adv_cid, const uint8_t *packet_data, uint16_t packet_len){
|
||||
|
||||
UNUSED(packet_data);
|
||||
UNUSED(the_pb_adv_cid);
|
||||
UNUSED(packet_len);
|
||||
|
||||
// TODO: validate Confirmation
|
||||
@ -624,10 +631,12 @@ static void provisioning_handle_random(uint16_t pb_adv_cid, const uint8_t *packe
|
||||
btstack_crypto_aes128_cmac_zero(&prov_cmac_request, 48, prov_confirmation_inputs, provisioning_salt, &provisioning_handle_provisioning_salt_calculated, NULL);
|
||||
}
|
||||
|
||||
static void provisioning_handle_complete(uint16_t pb_adv_cid){
|
||||
static void provisioning_handle_complete(uint16_t the_pb_adv_cid){
|
||||
UNUSED(the_pb_adv_cid);
|
||||
}
|
||||
|
||||
static void provisioning_handle_pdu(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
UNUSED(channel);
|
||||
|
||||
if (size < 1) return;
|
||||
|
||||
@ -731,13 +740,14 @@ uint16_t provisioning_provisioner_start_provisioning(const uint8_t * device_uuid
|
||||
return pb_adv_cid;
|
||||
}
|
||||
|
||||
void provisioning_provisioner_set_static_oob(uint16_t pb_adv_cid, uint16_t static_oob_len, const uint8_t * static_oob_data){
|
||||
UNUSED(pb_adv_cid);
|
||||
void provisioning_provisioner_set_static_oob(uint16_t the_pb_adv_cid, uint16_t static_oob_len, const uint8_t * static_oob_data){
|
||||
UNUSED(the_pb_adv_cid);
|
||||
prov_static_oob_data = static_oob_data;
|
||||
prov_static_oob_len = btstack_min(static_oob_len, 16);
|
||||
}
|
||||
|
||||
uint8_t provisioning_provisioner_select_authentication_method(uint16_t pb_adv_cid, uint8_t algorithm, uint8_t public_key_used, uint8_t authentication_method, uint8_t authentication_action, uint8_t authentication_size){
|
||||
uint8_t provisioning_provisioner_select_authentication_method(uint16_t the_pb_adv_cid, uint8_t algorithm, uint8_t public_key_used, uint8_t authentication_method, uint8_t authentication_action, uint8_t authentication_size){
|
||||
UNUSED(the_pb_adv_cid);
|
||||
|
||||
if (provisioner_state != PROVISIONER_W4_AUTH_CONFIGURATION) return ERROR_CODE_COMMAND_DISALLOWED;
|
||||
|
||||
@ -751,7 +761,8 @@ uint8_t provisioning_provisioner_select_authentication_method(uint16_t pb_adv_ci
|
||||
return ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
uint8_t provisioning_provisioner_public_key_oob_received(uint16_t pb_adv_cid, const uint8_t * public_key){
|
||||
uint8_t provisioning_provisioner_public_key_oob_received(uint16_t the_pb_adv_cid, const uint8_t * public_key){
|
||||
UNUSED(the_pb_adv_cid);
|
||||
|
||||
if (provisioner_state != PROVISIONER_W4_PUB_KEY_OOB) return ERROR_CODE_COMMAND_DISALLOWED;
|
||||
|
||||
@ -768,8 +779,8 @@ uint8_t provisioning_provisioner_public_key_oob_received(uint16_t pb_adv_cid, co
|
||||
return ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
void provisioning_provisioner_input_oob_complete_numeric(uint16_t pb_adv_cid, uint32_t input_oob){
|
||||
UNUSED(pb_adv_cid);
|
||||
void provisioning_provisioner_input_oob_complete_numeric(uint16_t the_pb_adv_cid, uint32_t input_oob){
|
||||
UNUSED(the_pb_adv_cid);
|
||||
if (provisioner_state != PROVISIONER_W4_INPUT_OOK) return;
|
||||
|
||||
// store input_oob as auth value
|
||||
@ -777,8 +788,8 @@ void provisioning_provisioner_input_oob_complete_numeric(uint16_t pb_adv_cid, ui
|
||||
provisioning_handle_auth_value_ready();
|
||||
}
|
||||
|
||||
void provisioning_provisioner_input_oob_complete_alphanumeric(uint16_t pb_adv_cid, const uint8_t * input_oob_data, uint16_t input_oob_len){
|
||||
UNUSED(pb_adv_cid);
|
||||
void provisioning_provisioner_input_oob_complete_alphanumeric(uint16_t the_pb_adv_cid, const uint8_t * input_oob_data, uint16_t input_oob_len){
|
||||
UNUSED(the_pb_adv_cid);
|
||||
if (provisioner_state != PROVISIONER_W4_INPUT_OOK) return;
|
||||
|
||||
// store input_oob and fillup with zeros
|
||||
|
Loading…
x
Reference in New Issue
Block a user