diff --git a/port/stm32-sx1280/README.md b/port/stm32-sx1280/README.md index 5f028195b..b2acf8c78 100644 --- a/port/stm32-sx1280/README.md +++ b/port/stm32-sx1280/README.md @@ -16,12 +16,11 @@ Uses 32.768 kHz crytstal as LSE for timing Support for Broadcaster and Peripheral roles. -The current Makefile project compiles the gatt_counter.c example. +The Makefile project compiles gatt_counter, gatt_streamer_server, hog_mouse and hog_keyboard examples. ## Limitation ### Advertising State: -- Only advertises on Channel 37 - Advertises as fast as possible, back to back - Only Connectable Advertising supported - Only fixed public BD_ADDR of 33:33:33:33:33:33 is used @@ -50,8 +49,8 @@ For the FMLR-80-P-STL4E module, just run make. You can upload the .elf file crea ## TODO ### General -- advertise on all configured channels - only advertise with advertising interval +- support other adv types - indicate random address in adertising pdus - allow to set random BD_ADDR via HCI command - handle Connection Param Update diff --git a/port/stm32-sx1280/controller/controller.c b/port/stm32-sx1280/controller/controller.c index 3fb8eb19a..2924def41 100644 --- a/port/stm32-sx1280/controller/controller.c +++ b/port/stm32-sx1280/controller/controller.c @@ -108,6 +108,18 @@ static void controller_handle_hci_command(uint8_t * packet, uint16_t size){ case HCI_OPCODE_HCI_LE_READ_BUFFER_SIZE: send_command_complete(opcode, 0, read_buffer_size_result, 8); break; + case HCI_OPCODE_HCI_LE_SET_ADVERTISING_PARAMETERS: + status = ll_set_advertising_parameters( + little_endian_read_16(packet,3), + little_endian_read_16(packet,5), + packet[7], + packet[8], + packet[9], + &packet[10], + packet[16], + packet[17]); + send_command_complete(opcode, status, NULL, 0); + break; case HCI_OPCODE_HCI_LE_SET_ADVERTISING_DATA: status = ll_set_advertising_data(packet[3], &packet[4]); send_command_complete(opcode, status, NULL, 0); diff --git a/port/stm32-sx1280/controller/ll.h b/port/stm32-sx1280/controller/ll.h index badbece5e..5bd3bd657 100644 --- a/port/stm32-sx1280/controller/ll.h +++ b/port/stm32-sx1280/controller/ll.h @@ -67,6 +67,10 @@ uint8_t ll_set_scan_enable(uint8_t le_scan_enable, uint8_t filter_duplicates); uint8_t ll_set_advertise_enable(uint8_t le_adv_enable); +uint8_t ll_set_advertising_parameters(uint16_t advertising_interval_min, uint16_t advertising_interval_max, + uint8_t advertising_type, uint8_t own_address_type, uint8_t peer_address_types, uint8_t * peer_address, + uint8_t advertising_channel_map, uint8_t advertising_filter_policy); + uint8_t ll_set_advertising_data(uint8_t adv_len, const uint8_t * adv_data); bool ll_reserve_acl_packet(void); diff --git a/port/stm32-sx1280/controller/ll_sx1280.c b/port/stm32-sx1280/controller/ll_sx1280.c index a59d3ebc4..91b28cb88 100644 --- a/port/stm32-sx1280/controller/ll_sx1280.c +++ b/port/stm32-sx1280/controller/ll_sx1280.c @@ -905,7 +905,7 @@ uint8_t ll_set_scan_enable(uint8_t le_scan_enable, uint8_t filter_duplicates){ static uint8_t ll_start_advertising(void){ // COMMAND DISALLOWED if wrong state. if (ll_state != LL_STATE_STANDBY) return ERROR_CODE_COMMAND_DISALLOWED; - printf("Start Advertising on channels 0x0x\n", ctx.adv_map); + printf("Start Advertising on channels 0x%0x\n", ctx.adv_map); start_advertising(); return ERROR_CODE_SUCCESS; } @@ -926,6 +926,19 @@ uint8_t ll_set_advertise_enable(uint8_t le_adv_enable){ } } +uint8_t ll_set_advertising_parameters(uint16_t advertising_interval_min, uint16_t advertising_interval_max, + uint8_t advertising_type, uint8_t own_address_type, uint8_t peer_address_types, uint8_t * peer_address, + uint8_t advertising_channel_map, uint8_t advertising_filter_policy){ + if (advertising_channel_map == 0) return ERROR_CODE_INVALID_HCI_COMMAND_PARAMETERS; + if ((advertising_channel_map & 0xf8) != 0) return ERROR_CODE_INVALID_HCI_COMMAND_PARAMETERS; + ctx.adv_map = advertising_channel_map; + + // TODO: validate other params + // TODO: process other params + + return ERROR_CODE_SUCCESS; +} + uint8_t ll_set_advertising_data(uint8_t adv_len, const uint8_t * adv_data){ // COMMAND DISALLOWED if wrong state. if (ll_state == LL_STATE_ADVERTISING) return ERROR_CODE_COMMAND_DISALLOWED;