bumble 0.0.159__py3-none-any.whl → 0.0.161__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bumble/_version.py +2 -2
- bumble/controller.py +73 -55
- bumble/core.py +74 -3
- bumble/device.py +30 -22
- bumble/gatt.py +23 -22
- bumble/l2cap.py +210 -122
- bumble/smp.py +105 -71
- {bumble-0.0.159.dist-info → bumble-0.0.161.dist-info}/METADATA +1 -1
- {bumble-0.0.159.dist-info → bumble-0.0.161.dist-info}/RECORD +13 -13
- {bumble-0.0.159.dist-info → bumble-0.0.161.dist-info}/WHEEL +1 -1
- {bumble-0.0.159.dist-info → bumble-0.0.161.dist-info}/LICENSE +0 -0
- {bumble-0.0.159.dist-info → bumble-0.0.161.dist-info}/entry_points.txt +0 -0
- {bumble-0.0.159.dist-info → bumble-0.0.161.dist-info}/top_level.txt +0 -0
bumble/_version.py
CHANGED
bumble/controller.py
CHANGED
|
@@ -654,7 +654,7 @@ class Controller:
|
|
|
654
654
|
|
|
655
655
|
def on_hci_create_connection_command(self, command):
|
|
656
656
|
'''
|
|
657
|
-
See Bluetooth spec Vol
|
|
657
|
+
See Bluetooth spec Vol 4, Part E - 7.1.5 Create Connection command
|
|
658
658
|
'''
|
|
659
659
|
|
|
660
660
|
if self.link is None:
|
|
@@ -685,7 +685,7 @@ class Controller:
|
|
|
685
685
|
|
|
686
686
|
def on_hci_disconnect_command(self, command):
|
|
687
687
|
'''
|
|
688
|
-
See Bluetooth spec Vol
|
|
688
|
+
See Bluetooth spec Vol 4, Part E - 7.1.6 Disconnect Command
|
|
689
689
|
'''
|
|
690
690
|
# First, say that the disconnection is pending
|
|
691
691
|
self.send_hci_packet(
|
|
@@ -719,7 +719,7 @@ class Controller:
|
|
|
719
719
|
|
|
720
720
|
def on_hci_accept_connection_request_command(self, command):
|
|
721
721
|
'''
|
|
722
|
-
See Bluetooth spec Vol
|
|
722
|
+
See Bluetooth spec Vol 4, Part E - 7.1.8 Accept Connection Request command
|
|
723
723
|
'''
|
|
724
724
|
|
|
725
725
|
if self.link is None:
|
|
@@ -735,7 +735,7 @@ class Controller:
|
|
|
735
735
|
|
|
736
736
|
def on_hci_switch_role_command(self, command):
|
|
737
737
|
'''
|
|
738
|
-
See Bluetooth spec Vol
|
|
738
|
+
See Bluetooth spec Vol 4, Part E - 7.2.8 Switch Role command
|
|
739
739
|
'''
|
|
740
740
|
|
|
741
741
|
if self.link is None:
|
|
@@ -751,21 +751,21 @@ class Controller:
|
|
|
751
751
|
|
|
752
752
|
def on_hci_set_event_mask_command(self, command):
|
|
753
753
|
'''
|
|
754
|
-
See Bluetooth spec Vol
|
|
754
|
+
See Bluetooth spec Vol 4, Part E - 7.3.1 Set Event Mask Command
|
|
755
755
|
'''
|
|
756
756
|
self.event_mask = command.event_mask
|
|
757
757
|
return bytes([HCI_SUCCESS])
|
|
758
758
|
|
|
759
759
|
def on_hci_reset_command(self, _command):
|
|
760
760
|
'''
|
|
761
|
-
See Bluetooth spec Vol
|
|
761
|
+
See Bluetooth spec Vol 4, Part E - 7.3.2 Reset Command
|
|
762
762
|
'''
|
|
763
763
|
# TODO: cleanup what needs to be reset
|
|
764
764
|
return bytes([HCI_SUCCESS])
|
|
765
765
|
|
|
766
766
|
def on_hci_write_local_name_command(self, command):
|
|
767
767
|
'''
|
|
768
|
-
See Bluetooth spec Vol
|
|
768
|
+
See Bluetooth spec Vol 4, Part E - 7.3.11 Write Local Name Command
|
|
769
769
|
'''
|
|
770
770
|
local_name = command.local_name
|
|
771
771
|
if len(local_name):
|
|
@@ -780,7 +780,7 @@ class Controller:
|
|
|
780
780
|
|
|
781
781
|
def on_hci_read_local_name_command(self, _command):
|
|
782
782
|
'''
|
|
783
|
-
See Bluetooth spec Vol
|
|
783
|
+
See Bluetooth spec Vol 4, Part E - 7.3.12 Read Local Name Command
|
|
784
784
|
'''
|
|
785
785
|
local_name = bytes(self.local_name, 'utf-8')[:248]
|
|
786
786
|
if len(local_name) < 248:
|
|
@@ -790,19 +790,19 @@ class Controller:
|
|
|
790
790
|
|
|
791
791
|
def on_hci_read_class_of_device_command(self, _command):
|
|
792
792
|
'''
|
|
793
|
-
See Bluetooth spec Vol
|
|
793
|
+
See Bluetooth spec Vol 4, Part E - 7.3.25 Read Class of Device Command
|
|
794
794
|
'''
|
|
795
795
|
return bytes([HCI_SUCCESS, 0, 0, 0])
|
|
796
796
|
|
|
797
797
|
def on_hci_write_class_of_device_command(self, _command):
|
|
798
798
|
'''
|
|
799
|
-
See Bluetooth spec Vol
|
|
799
|
+
See Bluetooth spec Vol 4, Part E - 7.3.26 Write Class of Device Command
|
|
800
800
|
'''
|
|
801
801
|
return bytes([HCI_SUCCESS])
|
|
802
802
|
|
|
803
803
|
def on_hci_read_synchronous_flow_control_enable_command(self, _command):
|
|
804
804
|
'''
|
|
805
|
-
See Bluetooth spec Vol
|
|
805
|
+
See Bluetooth spec Vol 4, Part E - 7.3.36 Read Synchronous Flow Control Enable
|
|
806
806
|
Command
|
|
807
807
|
'''
|
|
808
808
|
if self.sync_flow_control:
|
|
@@ -813,7 +813,7 @@ class Controller:
|
|
|
813
813
|
|
|
814
814
|
def on_hci_write_synchronous_flow_control_enable_command(self, command):
|
|
815
815
|
'''
|
|
816
|
-
See Bluetooth spec Vol
|
|
816
|
+
See Bluetooth spec Vol 4, Part E - 7.3.37 Write Synchronous Flow Control Enable
|
|
817
817
|
Command
|
|
818
818
|
'''
|
|
819
819
|
ret = HCI_SUCCESS
|
|
@@ -825,41 +825,59 @@ class Controller:
|
|
|
825
825
|
ret = HCI_INVALID_HCI_COMMAND_PARAMETERS_ERROR
|
|
826
826
|
return bytes([ret])
|
|
827
827
|
|
|
828
|
+
def on_hci_set_controller_to_host_flow_control_command(self, _command):
|
|
829
|
+
'''
|
|
830
|
+
See Bluetooth spec Vol 4, Part E - 7.3.38 Set Controller To Host Flow Control
|
|
831
|
+
Command
|
|
832
|
+
'''
|
|
833
|
+
# For now we just accept the command but ignore the values.
|
|
834
|
+
# TODO: respect the passed in values.
|
|
835
|
+
return bytes([HCI_SUCCESS])
|
|
836
|
+
|
|
837
|
+
def on_hci_host_buffer_size_command(self, _command):
|
|
838
|
+
'''
|
|
839
|
+
See Bluetooth spec Vol 4, Part E - 7.3.39 Host Buffer Size Command
|
|
840
|
+
'''
|
|
841
|
+
# For now we just accept the command but ignore the values.
|
|
842
|
+
# TODO: respect the passed in values.
|
|
843
|
+
return bytes([HCI_SUCCESS])
|
|
844
|
+
|
|
828
845
|
def on_hci_write_extended_inquiry_response_command(self, _command):
|
|
829
846
|
'''
|
|
830
|
-
See Bluetooth spec Vol
|
|
847
|
+
See Bluetooth spec Vol 4, Part E - 7.3.56 Write Extended Inquiry Response
|
|
848
|
+
Command
|
|
831
849
|
'''
|
|
832
850
|
return bytes([HCI_SUCCESS])
|
|
833
851
|
|
|
834
852
|
def on_hci_write_simple_pairing_mode_command(self, _command):
|
|
835
853
|
'''
|
|
836
|
-
See Bluetooth spec Vol
|
|
854
|
+
See Bluetooth spec Vol 4, Part E - 7.3.59 Write Simple Pairing Mode Command
|
|
837
855
|
'''
|
|
838
856
|
return bytes([HCI_SUCCESS])
|
|
839
857
|
|
|
840
858
|
def on_hci_set_event_mask_page_2_command(self, command):
|
|
841
859
|
'''
|
|
842
|
-
See Bluetooth spec Vol
|
|
860
|
+
See Bluetooth spec Vol 4, Part E - 7.3.69 Set Event Mask Page 2 Command
|
|
843
861
|
'''
|
|
844
862
|
self.event_mask_page_2 = command.event_mask_page_2
|
|
845
863
|
return bytes([HCI_SUCCESS])
|
|
846
864
|
|
|
847
865
|
def on_hci_read_le_host_support_command(self, _command):
|
|
848
866
|
'''
|
|
849
|
-
See Bluetooth spec Vol
|
|
867
|
+
See Bluetooth spec Vol 4, Part E - 7.3.78 Write LE Host Support Command
|
|
850
868
|
'''
|
|
851
869
|
return bytes([HCI_SUCCESS, 1, 0])
|
|
852
870
|
|
|
853
871
|
def on_hci_write_le_host_support_command(self, _command):
|
|
854
872
|
'''
|
|
855
|
-
See Bluetooth spec Vol
|
|
873
|
+
See Bluetooth spec Vol 4, Part E - 7.3.79 Write LE Host Support Command
|
|
856
874
|
'''
|
|
857
875
|
# TODO / Just ignore for now
|
|
858
876
|
return bytes([HCI_SUCCESS])
|
|
859
877
|
|
|
860
878
|
def on_hci_write_authenticated_payload_timeout_command(self, command):
|
|
861
879
|
'''
|
|
862
|
-
See Bluetooth spec Vol
|
|
880
|
+
See Bluetooth spec Vol 4, Part E - 7.3.94 Write Authenticated Payload Timeout
|
|
863
881
|
Command
|
|
864
882
|
'''
|
|
865
883
|
# TODO
|
|
@@ -867,7 +885,7 @@ class Controller:
|
|
|
867
885
|
|
|
868
886
|
def on_hci_read_local_version_information_command(self, _command):
|
|
869
887
|
'''
|
|
870
|
-
See Bluetooth spec Vol
|
|
888
|
+
See Bluetooth spec Vol 4, Part E - 7.4.1 Read Local Version Information Command
|
|
871
889
|
'''
|
|
872
890
|
return struct.pack(
|
|
873
891
|
'<BBHBHH',
|
|
@@ -881,19 +899,19 @@ class Controller:
|
|
|
881
899
|
|
|
882
900
|
def on_hci_read_local_supported_commands_command(self, _command):
|
|
883
901
|
'''
|
|
884
|
-
See Bluetooth spec Vol
|
|
902
|
+
See Bluetooth spec Vol 4, Part E - 7.4.2 Read Local Supported Commands Command
|
|
885
903
|
'''
|
|
886
904
|
return bytes([HCI_SUCCESS]) + self.supported_commands
|
|
887
905
|
|
|
888
906
|
def on_hci_read_local_supported_features_command(self, _command):
|
|
889
907
|
'''
|
|
890
|
-
See Bluetooth spec Vol
|
|
908
|
+
See Bluetooth spec Vol 4, Part E - 7.4.3 Read Local Supported Features Command
|
|
891
909
|
'''
|
|
892
910
|
return bytes([HCI_SUCCESS]) + self.lmp_features
|
|
893
911
|
|
|
894
912
|
def on_hci_read_bd_addr_command(self, _command):
|
|
895
913
|
'''
|
|
896
|
-
See Bluetooth spec Vol
|
|
914
|
+
See Bluetooth spec Vol 4, Part E - 7.4.6 Read BD_ADDR Command
|
|
897
915
|
'''
|
|
898
916
|
bd_addr = (
|
|
899
917
|
self._public_address.to_bytes()
|
|
@@ -904,14 +922,14 @@ class Controller:
|
|
|
904
922
|
|
|
905
923
|
def on_hci_le_set_event_mask_command(self, command):
|
|
906
924
|
'''
|
|
907
|
-
See Bluetooth spec Vol
|
|
925
|
+
See Bluetooth spec Vol 4, Part E - 7.8.1 LE Set Event Mask Command
|
|
908
926
|
'''
|
|
909
927
|
self.le_event_mask = command.le_event_mask
|
|
910
928
|
return bytes([HCI_SUCCESS])
|
|
911
929
|
|
|
912
930
|
def on_hci_le_read_buffer_size_command(self, _command):
|
|
913
931
|
'''
|
|
914
|
-
See Bluetooth spec Vol
|
|
932
|
+
See Bluetooth spec Vol 4, Part E - 7.8.2 LE Read Buffer Size Command
|
|
915
933
|
'''
|
|
916
934
|
return struct.pack(
|
|
917
935
|
'<BHB',
|
|
@@ -922,49 +940,49 @@ class Controller:
|
|
|
922
940
|
|
|
923
941
|
def on_hci_le_read_local_supported_features_command(self, _command):
|
|
924
942
|
'''
|
|
925
|
-
See Bluetooth spec Vol
|
|
943
|
+
See Bluetooth spec Vol 4, Part E - 7.8.3 LE Read Local Supported Features
|
|
926
944
|
Command
|
|
927
945
|
'''
|
|
928
946
|
return bytes([HCI_SUCCESS]) + self.le_features
|
|
929
947
|
|
|
930
948
|
def on_hci_le_set_random_address_command(self, command):
|
|
931
949
|
'''
|
|
932
|
-
See Bluetooth spec Vol
|
|
950
|
+
See Bluetooth spec Vol 4, Part E - 7.8.4 LE Set Random Address Command
|
|
933
951
|
'''
|
|
934
952
|
self.random_address = command.random_address
|
|
935
953
|
return bytes([HCI_SUCCESS])
|
|
936
954
|
|
|
937
955
|
def on_hci_le_set_advertising_parameters_command(self, command):
|
|
938
956
|
'''
|
|
939
|
-
See Bluetooth spec Vol
|
|
957
|
+
See Bluetooth spec Vol 4, Part E - 7.8.5 LE Set Advertising Parameters Command
|
|
940
958
|
'''
|
|
941
959
|
self.advertising_parameters = command
|
|
942
960
|
return bytes([HCI_SUCCESS])
|
|
943
961
|
|
|
944
962
|
def on_hci_le_read_advertising_physical_channel_tx_power_command(self, _command):
|
|
945
963
|
'''
|
|
946
|
-
See Bluetooth spec Vol
|
|
964
|
+
See Bluetooth spec Vol 4, Part E - 7.8.6 LE Read Advertising Physical Channel
|
|
947
965
|
Tx Power Command
|
|
948
966
|
'''
|
|
949
967
|
return bytes([HCI_SUCCESS, self.advertising_channel_tx_power])
|
|
950
968
|
|
|
951
969
|
def on_hci_le_set_advertising_data_command(self, command):
|
|
952
970
|
'''
|
|
953
|
-
See Bluetooth spec Vol
|
|
971
|
+
See Bluetooth spec Vol 4, Part E - 7.8.7 LE Set Advertising Data Command
|
|
954
972
|
'''
|
|
955
973
|
self.advertising_data = command.advertising_data
|
|
956
974
|
return bytes([HCI_SUCCESS])
|
|
957
975
|
|
|
958
976
|
def on_hci_le_set_scan_response_data_command(self, command):
|
|
959
977
|
'''
|
|
960
|
-
See Bluetooth spec Vol
|
|
978
|
+
See Bluetooth spec Vol 4, Part E - 7.8.8 LE Set Scan Response Data Command
|
|
961
979
|
'''
|
|
962
980
|
self.le_scan_response_data = command.scan_response_data
|
|
963
981
|
return bytes([HCI_SUCCESS])
|
|
964
982
|
|
|
965
983
|
def on_hci_le_set_advertising_enable_command(self, command):
|
|
966
984
|
'''
|
|
967
|
-
See Bluetooth spec Vol
|
|
985
|
+
See Bluetooth spec Vol 4, Part E - 7.8.9 LE Set Advertising Enable Command
|
|
968
986
|
'''
|
|
969
987
|
if command.advertising_enable:
|
|
970
988
|
self.start_advertising()
|
|
@@ -975,7 +993,7 @@ class Controller:
|
|
|
975
993
|
|
|
976
994
|
def on_hci_le_set_scan_parameters_command(self, command):
|
|
977
995
|
'''
|
|
978
|
-
See Bluetooth spec Vol
|
|
996
|
+
See Bluetooth spec Vol 4, Part E - 7.8.10 LE Set Scan Parameters Command
|
|
979
997
|
'''
|
|
980
998
|
self.le_scan_type = command.le_scan_type
|
|
981
999
|
self.le_scan_interval = command.le_scan_interval
|
|
@@ -986,7 +1004,7 @@ class Controller:
|
|
|
986
1004
|
|
|
987
1005
|
def on_hci_le_set_scan_enable_command(self, command):
|
|
988
1006
|
'''
|
|
989
|
-
See Bluetooth spec Vol
|
|
1007
|
+
See Bluetooth spec Vol 4, Part E - 7.8.11 LE Set Scan Enable Command
|
|
990
1008
|
'''
|
|
991
1009
|
self.le_scan_enable = command.le_scan_enable
|
|
992
1010
|
self.filter_duplicates = command.filter_duplicates
|
|
@@ -994,7 +1012,7 @@ class Controller:
|
|
|
994
1012
|
|
|
995
1013
|
def on_hci_le_create_connection_command(self, command):
|
|
996
1014
|
'''
|
|
997
|
-
See Bluetooth spec Vol
|
|
1015
|
+
See Bluetooth spec Vol 4, Part E - 7.8.12 LE Create Connection Command
|
|
998
1016
|
'''
|
|
999
1017
|
|
|
1000
1018
|
if not self.link:
|
|
@@ -1027,40 +1045,40 @@ class Controller:
|
|
|
1027
1045
|
|
|
1028
1046
|
def on_hci_le_create_connection_cancel_command(self, _command):
|
|
1029
1047
|
'''
|
|
1030
|
-
See Bluetooth spec Vol
|
|
1048
|
+
See Bluetooth spec Vol 4, Part E - 7.8.13 LE Create Connection Cancel Command
|
|
1031
1049
|
'''
|
|
1032
1050
|
return bytes([HCI_SUCCESS])
|
|
1033
1051
|
|
|
1034
1052
|
def on_hci_le_read_filter_accept_list_size_command(self, _command):
|
|
1035
1053
|
'''
|
|
1036
|
-
See Bluetooth spec Vol
|
|
1054
|
+
See Bluetooth spec Vol 4, Part E - 7.8.14 LE Read Filter Accept List Size
|
|
1037
1055
|
Command
|
|
1038
1056
|
'''
|
|
1039
1057
|
return bytes([HCI_SUCCESS, self.filter_accept_list_size])
|
|
1040
1058
|
|
|
1041
1059
|
def on_hci_le_clear_filter_accept_list_command(self, _command):
|
|
1042
1060
|
'''
|
|
1043
|
-
See Bluetooth spec Vol
|
|
1061
|
+
See Bluetooth spec Vol 4, Part E - 7.8.15 LE Clear Filter Accept List Command
|
|
1044
1062
|
'''
|
|
1045
1063
|
return bytes([HCI_SUCCESS])
|
|
1046
1064
|
|
|
1047
1065
|
def on_hci_le_add_device_to_filter_accept_list_command(self, _command):
|
|
1048
1066
|
'''
|
|
1049
|
-
See Bluetooth spec Vol
|
|
1067
|
+
See Bluetooth spec Vol 4, Part E - 7.8.16 LE Add Device To Filter Accept List
|
|
1050
1068
|
Command
|
|
1051
1069
|
'''
|
|
1052
1070
|
return bytes([HCI_SUCCESS])
|
|
1053
1071
|
|
|
1054
1072
|
def on_hci_le_remove_device_from_filter_accept_list_command(self, _command):
|
|
1055
1073
|
'''
|
|
1056
|
-
See Bluetooth spec Vol
|
|
1074
|
+
See Bluetooth spec Vol 4, Part E - 7.8.17 LE Remove Device From Filter Accept
|
|
1057
1075
|
List Command
|
|
1058
1076
|
'''
|
|
1059
1077
|
return bytes([HCI_SUCCESS])
|
|
1060
1078
|
|
|
1061
1079
|
def on_hci_le_read_remote_features_command(self, command):
|
|
1062
1080
|
'''
|
|
1063
|
-
See Bluetooth spec Vol
|
|
1081
|
+
See Bluetooth spec Vol 4, Part E - 7.8.21 LE Read Remote Features Command
|
|
1064
1082
|
'''
|
|
1065
1083
|
|
|
1066
1084
|
# First, say that the command is pending
|
|
@@ -1083,13 +1101,13 @@ class Controller:
|
|
|
1083
1101
|
|
|
1084
1102
|
def on_hci_le_rand_command(self, _command):
|
|
1085
1103
|
'''
|
|
1086
|
-
See Bluetooth spec Vol
|
|
1104
|
+
See Bluetooth spec Vol 4, Part E - 7.8.23 LE Rand Command
|
|
1087
1105
|
'''
|
|
1088
1106
|
return bytes([HCI_SUCCESS]) + struct.pack('Q', random.randint(0, 1 << 64))
|
|
1089
1107
|
|
|
1090
1108
|
def on_hci_le_enable_encryption_command(self, command):
|
|
1091
1109
|
'''
|
|
1092
|
-
See Bluetooth spec Vol
|
|
1110
|
+
See Bluetooth spec Vol 4, Part E - 7.8.24 LE Enable Encryption Command
|
|
1093
1111
|
'''
|
|
1094
1112
|
|
|
1095
1113
|
# Check the parameters
|
|
@@ -1122,13 +1140,13 @@ class Controller:
|
|
|
1122
1140
|
|
|
1123
1141
|
def on_hci_le_read_supported_states_command(self, _command):
|
|
1124
1142
|
'''
|
|
1125
|
-
See Bluetooth spec Vol
|
|
1143
|
+
See Bluetooth spec Vol 4, Part E - 7.8.27 LE Read Supported States Command
|
|
1126
1144
|
'''
|
|
1127
1145
|
return bytes([HCI_SUCCESS]) + self.le_states
|
|
1128
1146
|
|
|
1129
1147
|
def on_hci_le_read_suggested_default_data_length_command(self, _command):
|
|
1130
1148
|
'''
|
|
1131
|
-
See Bluetooth spec Vol
|
|
1149
|
+
See Bluetooth spec Vol 4, Part E - 7.8.34 LE Read Suggested Default Data Length
|
|
1132
1150
|
Command
|
|
1133
1151
|
'''
|
|
1134
1152
|
return struct.pack(
|
|
@@ -1140,7 +1158,7 @@ class Controller:
|
|
|
1140
1158
|
|
|
1141
1159
|
def on_hci_le_write_suggested_default_data_length_command(self, command):
|
|
1142
1160
|
'''
|
|
1143
|
-
See Bluetooth spec Vol
|
|
1161
|
+
See Bluetooth spec Vol 4, Part E - 7.8.35 LE Write Suggested Default Data Length
|
|
1144
1162
|
Command
|
|
1145
1163
|
'''
|
|
1146
1164
|
self.suggested_max_tx_octets, self.suggested_max_tx_time = struct.unpack(
|
|
@@ -1150,33 +1168,33 @@ class Controller:
|
|
|
1150
1168
|
|
|
1151
1169
|
def on_hci_le_read_local_p_256_public_key_command(self, _command):
|
|
1152
1170
|
'''
|
|
1153
|
-
See Bluetooth spec Vol
|
|
1171
|
+
See Bluetooth spec Vol 4, Part E - 7.8.36 LE Read P-256 Public Key Command
|
|
1154
1172
|
'''
|
|
1155
1173
|
# TODO create key and send HCI_LE_Read_Local_P-256_Public_Key_Complete event
|
|
1156
1174
|
return bytes([HCI_SUCCESS])
|
|
1157
1175
|
|
|
1158
1176
|
def on_hci_le_add_device_to_resolving_list_command(self, _command):
|
|
1159
1177
|
'''
|
|
1160
|
-
See Bluetooth spec Vol
|
|
1178
|
+
See Bluetooth spec Vol 4, Part E - 7.8.38 LE Add Device To Resolving List
|
|
1161
1179
|
Command
|
|
1162
1180
|
'''
|
|
1163
1181
|
return bytes([HCI_SUCCESS])
|
|
1164
1182
|
|
|
1165
1183
|
def on_hci_le_clear_resolving_list_command(self, _command):
|
|
1166
1184
|
'''
|
|
1167
|
-
See Bluetooth spec Vol
|
|
1185
|
+
See Bluetooth spec Vol 4, Part E - 7.8.40 LE Clear Resolving List Command
|
|
1168
1186
|
'''
|
|
1169
1187
|
return bytes([HCI_SUCCESS])
|
|
1170
1188
|
|
|
1171
1189
|
def on_hci_le_read_resolving_list_size_command(self, _command):
|
|
1172
1190
|
'''
|
|
1173
|
-
See Bluetooth spec Vol
|
|
1191
|
+
See Bluetooth spec Vol 4, Part E - 7.8.41 LE Read Resolving List Size Command
|
|
1174
1192
|
'''
|
|
1175
1193
|
return bytes([HCI_SUCCESS, self.resolving_list_size])
|
|
1176
1194
|
|
|
1177
1195
|
def on_hci_le_set_address_resolution_enable_command(self, command):
|
|
1178
1196
|
'''
|
|
1179
|
-
See Bluetooth spec Vol
|
|
1197
|
+
See Bluetooth spec Vol 4, Part E - 7.8.44 LE Set Address Resolution Enable
|
|
1180
1198
|
Command
|
|
1181
1199
|
'''
|
|
1182
1200
|
ret = HCI_SUCCESS
|
|
@@ -1190,7 +1208,7 @@ class Controller:
|
|
|
1190
1208
|
|
|
1191
1209
|
def on_hci_le_set_resolvable_private_address_timeout_command(self, command):
|
|
1192
1210
|
'''
|
|
1193
|
-
See Bluetooth spec Vol
|
|
1211
|
+
See Bluetooth spec Vol 4, Part E - 7.8.45 LE Set Resolvable Private Address
|
|
1194
1212
|
Timeout Command
|
|
1195
1213
|
'''
|
|
1196
1214
|
self.le_rpa_timeout = command.rpa_timeout
|
|
@@ -1198,7 +1216,7 @@ class Controller:
|
|
|
1198
1216
|
|
|
1199
1217
|
def on_hci_le_read_maximum_data_length_command(self, _command):
|
|
1200
1218
|
'''
|
|
1201
|
-
See Bluetooth spec Vol
|
|
1219
|
+
See Bluetooth spec Vol 4, Part E - 7.8.46 LE Read Maximum Data Length Command
|
|
1202
1220
|
'''
|
|
1203
1221
|
return struct.pack(
|
|
1204
1222
|
'<BHHHH',
|
|
@@ -1211,7 +1229,7 @@ class Controller:
|
|
|
1211
1229
|
|
|
1212
1230
|
def on_hci_le_read_phy_command(self, command):
|
|
1213
1231
|
'''
|
|
1214
|
-
See Bluetooth spec Vol
|
|
1232
|
+
See Bluetooth spec Vol 4, Part E - 7.8.47 LE Read PHY Command
|
|
1215
1233
|
'''
|
|
1216
1234
|
return struct.pack(
|
|
1217
1235
|
'<BHBB',
|
|
@@ -1223,7 +1241,7 @@ class Controller:
|
|
|
1223
1241
|
|
|
1224
1242
|
def on_hci_le_set_default_phy_command(self, command):
|
|
1225
1243
|
'''
|
|
1226
|
-
See Bluetooth spec Vol
|
|
1244
|
+
See Bluetooth spec Vol 4, Part E - 7.8.48 LE Set Default PHY Command
|
|
1227
1245
|
'''
|
|
1228
1246
|
self.default_phy = {
|
|
1229
1247
|
'all_phys': command.all_phys,
|
|
@@ -1234,6 +1252,6 @@ class Controller:
|
|
|
1234
1252
|
|
|
1235
1253
|
def on_hci_le_read_transmit_power_command(self, _command):
|
|
1236
1254
|
'''
|
|
1237
|
-
See Bluetooth spec Vol
|
|
1255
|
+
See Bluetooth spec Vol 4, Part E - 7.8.74 LE Read Transmit Power Command
|
|
1238
1256
|
'''
|
|
1239
1257
|
return struct.pack('<BBB', HCI_SUCCESS, 0, 0)
|
bumble/core.py
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
# -----------------------------------------------------------------------------
|
|
18
18
|
from __future__ import annotations
|
|
19
19
|
import struct
|
|
20
|
-
from typing import List, Optional, Tuple, Union, cast
|
|
20
|
+
from typing import List, Optional, Tuple, Union, cast, Dict
|
|
21
21
|
|
|
22
22
|
from .company_ids import COMPANY_IDENTIFIERS
|
|
23
23
|
|
|
@@ -53,7 +53,7 @@ def bit_flags_to_strings(bits, bit_flag_names):
|
|
|
53
53
|
return names
|
|
54
54
|
|
|
55
55
|
|
|
56
|
-
def name_or_number(dictionary, number, width=2):
|
|
56
|
+
def name_or_number(dictionary: Dict[int, str], number: int, width: int = 2) -> str:
|
|
57
57
|
name = dictionary.get(number)
|
|
58
58
|
if name is not None:
|
|
59
59
|
return name
|
|
@@ -562,11 +562,82 @@ class DeviceClass:
|
|
|
562
562
|
PERIPHERAL_HANDHELD_GESTURAL_INPUT_DEVICE_MINOR_DEVICE_CLASS: 'Handheld gestural input device'
|
|
563
563
|
}
|
|
564
564
|
|
|
565
|
+
WEARABLE_UNCATEGORIZED_MINOR_DEVICE_CLASS = 0x00
|
|
566
|
+
WEARABLE_WRISTWATCH_MINOR_DEVICE_CLASS = 0x01
|
|
567
|
+
WEARABLE_PAGER_MINOR_DEVICE_CLASS = 0x02
|
|
568
|
+
WEARABLE_JACKET_MINOR_DEVICE_CLASS = 0x03
|
|
569
|
+
WEARABLE_HELMET_MINOR_DEVICE_CLASS = 0x04
|
|
570
|
+
WEARABLE_GLASSES_MINOR_DEVICE_CLASS = 0x05
|
|
571
|
+
|
|
572
|
+
WEARABLE_MINOR_DEVICE_CLASS_NAMES = {
|
|
573
|
+
WEARABLE_UNCATEGORIZED_MINOR_DEVICE_CLASS: 'Uncategorized',
|
|
574
|
+
WEARABLE_WRISTWATCH_MINOR_DEVICE_CLASS: 'Wristwatch',
|
|
575
|
+
WEARABLE_PAGER_MINOR_DEVICE_CLASS: 'Pager',
|
|
576
|
+
WEARABLE_JACKET_MINOR_DEVICE_CLASS: 'Jacket',
|
|
577
|
+
WEARABLE_HELMET_MINOR_DEVICE_CLASS: 'Helmet',
|
|
578
|
+
WEARABLE_GLASSES_MINOR_DEVICE_CLASS: 'Glasses',
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
TOY_UNCATEGORIZED_MINOR_DEVICE_CLASS = 0x00
|
|
582
|
+
TOY_ROBOT_MINOR_DEVICE_CLASS = 0x01
|
|
583
|
+
TOY_VEHICLE_MINOR_DEVICE_CLASS = 0x02
|
|
584
|
+
TOY_DOLL_ACTION_FIGURE_MINOR_DEVICE_CLASS = 0x03
|
|
585
|
+
TOY_CONTROLLER_MINOR_DEVICE_CLASS = 0x04
|
|
586
|
+
TOY_GAME_MINOR_DEVICE_CLASS = 0x05
|
|
587
|
+
|
|
588
|
+
TOY_MINOR_DEVICE_CLASS_NAMES = {
|
|
589
|
+
TOY_UNCATEGORIZED_MINOR_DEVICE_CLASS: 'Uncategorized',
|
|
590
|
+
TOY_ROBOT_MINOR_DEVICE_CLASS: 'Robot',
|
|
591
|
+
TOY_VEHICLE_MINOR_DEVICE_CLASS: 'Vehicle',
|
|
592
|
+
TOY_DOLL_ACTION_FIGURE_MINOR_DEVICE_CLASS: 'Doll/Action figure',
|
|
593
|
+
TOY_CONTROLLER_MINOR_DEVICE_CLASS: 'Controller',
|
|
594
|
+
TOY_GAME_MINOR_DEVICE_CLASS: 'Game',
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
HEALTH_UNDEFINED_MINOR_DEVICE_CLASS = 0x00
|
|
598
|
+
HEALTH_BLOOD_PRESSURE_MONITOR_MINOR_DEVICE_CLASS = 0x01
|
|
599
|
+
HEALTH_THERMOMETER_MINOR_DEVICE_CLASS = 0x02
|
|
600
|
+
HEALTH_WEIGHING_SCALE_MINOR_DEVICE_CLASS = 0x03
|
|
601
|
+
HEALTH_GLUCOSE_METER_MINOR_DEVICE_CLASS = 0x04
|
|
602
|
+
HEALTH_PULSE_OXIMETER_MINOR_DEVICE_CLASS = 0x05
|
|
603
|
+
HEALTH_HEART_PULSE_RATE_MONITOR_MINOR_DEVICE_CLASS = 0x06
|
|
604
|
+
HEALTH_HEALTH_DATA_DISPLAY_MINOR_DEVICE_CLASS = 0x07
|
|
605
|
+
HEALTH_STEP_COUNTER_MINOR_DEVICE_CLASS = 0x08
|
|
606
|
+
HEALTH_BODY_COMPOSITION_ANALYZER_MINOR_DEVICE_CLASS = 0x09
|
|
607
|
+
HEALTH_PEAK_FLOW_MONITOR_MINOR_DEVICE_CLASS = 0x0A
|
|
608
|
+
HEALTH_MEDICATION_MONITOR_MINOR_DEVICE_CLASS = 0x0B
|
|
609
|
+
HEALTH_KNEE_PROSTHESIS_MINOR_DEVICE_CLASS = 0x0C
|
|
610
|
+
HEALTH_ANKLE_PROSTHESIS_MINOR_DEVICE_CLASS = 0x0D
|
|
611
|
+
HEALTH_GENERIC_HEALTH_MANAGER_MINOR_DEVICE_CLASS = 0x0E
|
|
612
|
+
HEALTH_PERSONAL_MOBILITY_DEVICE_MINOR_DEVICE_CLASS = 0x0F
|
|
613
|
+
|
|
614
|
+
HEALTH_MINOR_DEVICE_CLASS_NAMES = {
|
|
615
|
+
HEALTH_UNDEFINED_MINOR_DEVICE_CLASS: 'Undefined',
|
|
616
|
+
HEALTH_BLOOD_PRESSURE_MONITOR_MINOR_DEVICE_CLASS: 'Blood Pressure Monitor',
|
|
617
|
+
HEALTH_THERMOMETER_MINOR_DEVICE_CLASS: 'Thermometer',
|
|
618
|
+
HEALTH_WEIGHING_SCALE_MINOR_DEVICE_CLASS: 'Weighing Scale',
|
|
619
|
+
HEALTH_GLUCOSE_METER_MINOR_DEVICE_CLASS: 'Glucose Meter',
|
|
620
|
+
HEALTH_PULSE_OXIMETER_MINOR_DEVICE_CLASS: 'Pulse Oximeter',
|
|
621
|
+
HEALTH_HEART_PULSE_RATE_MONITOR_MINOR_DEVICE_CLASS: 'Heart/Pulse Rate Monitor',
|
|
622
|
+
HEALTH_HEALTH_DATA_DISPLAY_MINOR_DEVICE_CLASS: 'Health Data Display',
|
|
623
|
+
HEALTH_STEP_COUNTER_MINOR_DEVICE_CLASS: 'Step Counter',
|
|
624
|
+
HEALTH_BODY_COMPOSITION_ANALYZER_MINOR_DEVICE_CLASS: 'Body Composition Analyzer',
|
|
625
|
+
HEALTH_PEAK_FLOW_MONITOR_MINOR_DEVICE_CLASS: 'Peak Flow Monitor',
|
|
626
|
+
HEALTH_MEDICATION_MONITOR_MINOR_DEVICE_CLASS: 'Medication Monitor',
|
|
627
|
+
HEALTH_KNEE_PROSTHESIS_MINOR_DEVICE_CLASS: 'Knee Prosthesis',
|
|
628
|
+
HEALTH_ANKLE_PROSTHESIS_MINOR_DEVICE_CLASS: 'Ankle Prosthesis',
|
|
629
|
+
HEALTH_GENERIC_HEALTH_MANAGER_MINOR_DEVICE_CLASS: 'Generic Health Manager',
|
|
630
|
+
HEALTH_PERSONAL_MOBILITY_DEVICE_MINOR_DEVICE_CLASS: 'Personal Mobility Device',
|
|
631
|
+
}
|
|
632
|
+
|
|
565
633
|
MINOR_DEVICE_CLASS_NAMES = {
|
|
566
634
|
COMPUTER_MAJOR_DEVICE_CLASS: COMPUTER_MINOR_DEVICE_CLASS_NAMES,
|
|
567
635
|
PHONE_MAJOR_DEVICE_CLASS: PHONE_MINOR_DEVICE_CLASS_NAMES,
|
|
568
636
|
AUDIO_VIDEO_MAJOR_DEVICE_CLASS: AUDIO_VIDEO_MINOR_DEVICE_CLASS_NAMES,
|
|
569
|
-
PERIPHERAL_MAJOR_DEVICE_CLASS: PERIPHERAL_MINOR_DEVICE_CLASS_NAMES
|
|
637
|
+
PERIPHERAL_MAJOR_DEVICE_CLASS: PERIPHERAL_MINOR_DEVICE_CLASS_NAMES,
|
|
638
|
+
WEARABLE_MAJOR_DEVICE_CLASS: WEARABLE_MINOR_DEVICE_CLASS_NAMES,
|
|
639
|
+
TOY_MAJOR_DEVICE_CLASS: TOY_MINOR_DEVICE_CLASS_NAMES,
|
|
640
|
+
HEALTH_MAJOR_DEVICE_CLASS: HEALTH_MINOR_DEVICE_CLASS_NAMES,
|
|
570
641
|
}
|
|
571
642
|
|
|
572
643
|
# fmt: on
|
bumble/device.py
CHANGED
|
@@ -2851,18 +2851,22 @@ class Device(CompositeEventEmitter):
|
|
|
2851
2851
|
method = methods[peer_io_capability][io_capability]
|
|
2852
2852
|
|
|
2853
2853
|
async def reply() -> None:
|
|
2854
|
-
|
|
2855
|
-
await
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
else:
|
|
2861
|
-
await self.host.send_command(
|
|
2862
|
-
HCI_User_Confirmation_Request_Negative_Reply_Command( # type: ignore[call-arg]
|
|
2863
|
-
bd_addr=connection.peer_address
|
|
2854
|
+
try:
|
|
2855
|
+
if await connection.abort_on('disconnection', method()):
|
|
2856
|
+
await self.host.send_command(
|
|
2857
|
+
HCI_User_Confirmation_Request_Reply_Command( # type: ignore[call-arg]
|
|
2858
|
+
bd_addr=connection.peer_address
|
|
2859
|
+
)
|
|
2864
2860
|
)
|
|
2861
|
+
return
|
|
2862
|
+
except Exception as error:
|
|
2863
|
+
logger.warning(f'exception while confirming: {error}')
|
|
2864
|
+
|
|
2865
|
+
await self.host.send_command(
|
|
2866
|
+
HCI_User_Confirmation_Request_Negative_Reply_Command( # type: ignore[call-arg]
|
|
2867
|
+
bd_addr=connection.peer_address
|
|
2865
2868
|
)
|
|
2869
|
+
)
|
|
2866
2870
|
|
|
2867
2871
|
AsyncRunner.spawn(reply())
|
|
2868
2872
|
|
|
@@ -2874,21 +2878,25 @@ class Device(CompositeEventEmitter):
|
|
|
2874
2878
|
pairing_config = self.pairing_config_factory(connection)
|
|
2875
2879
|
|
|
2876
2880
|
async def reply() -> None:
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
if number is not None:
|
|
2881
|
-
await self.host.send_command(
|
|
2882
|
-
HCI_User_Passkey_Request_Reply_Command( # type: ignore[call-arg]
|
|
2883
|
-
bd_addr=connection.peer_address, numeric_value=number
|
|
2884
|
-
)
|
|
2881
|
+
try:
|
|
2882
|
+
number = await connection.abort_on(
|
|
2883
|
+
'disconnection', pairing_config.delegate.get_number()
|
|
2885
2884
|
)
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2885
|
+
if number is not None:
|
|
2886
|
+
await self.host.send_command(
|
|
2887
|
+
HCI_User_Passkey_Request_Reply_Command( # type: ignore[call-arg]
|
|
2888
|
+
bd_addr=connection.peer_address, numeric_value=number
|
|
2889
|
+
)
|
|
2890
2890
|
)
|
|
2891
|
+
return
|
|
2892
|
+
except Exception as error:
|
|
2893
|
+
logger.warning(f'exception while asking for pass-key: {error}')
|
|
2894
|
+
|
|
2895
|
+
await self.host.send_command(
|
|
2896
|
+
HCI_User_Passkey_Request_Negative_Reply_Command( # type: ignore[call-arg]
|
|
2897
|
+
bd_addr=connection.peer_address
|
|
2891
2898
|
)
|
|
2899
|
+
)
|
|
2892
2900
|
|
|
2893
2901
|
AsyncRunner.spawn(reply())
|
|
2894
2902
|
|