Lines Matching refs:self
363 def __init__(self, event, data, time=None): argument
364 self.event = event;
365 self.data = data[:];
366 self.values = None;
367 self.errors = set([]);
368 self.time = time;
369 self.size = len(self.data);
370 …self.subEvent = struct.unpack('B', self.data[:1])[0] if self.size > 0 and self.event == Events.BT_…
372 def __asNumber(self, data): argument
379 def __checkSize(self, size): argument
380 if self.size != size:
381 if self.size == 4:
384 self.errors.add(ErrorCodes.BT_HCI_ERR_SIZE);
385 return self.size >= size;
387 def __checkMinSize(self, size): argument
388 if not self.size >= size:
389 self.errors.add(ErrorCodes.BT_HCI_ERR_SIZE);
390 return self.size >= size;
392 def __checkConnectionHandle(self, handle): argument
394 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_CONN_HANDLE);
396 def __checkEncryptionEnabled(self, enabled): argument
398 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_ENCRYPT_ENABLED);
400 def __checkEncryptionKeySize(self, key_size): argument
402 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_ENC_KEY_SIZE)
404 def __checkTXPowerLevel(self, level): argument
406 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_TX_POWER_LEVEL);
408 def __checkLESupportedHost(self, value): argument
410 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_LE_SUPPORTED_HOST);
412 def __checkLESimultaneousHost(self, value): argument
414 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_LE_SIMULTANEOUS_HOST);
416 def __checkPayloadTimeout(self, timeout): argument
418 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_PAYLOAD_TIMEOUT);
420 def __checkRSSI(self, rssi): argument
422 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_RSSI_VALUE);
424 def __checkAdvTXPowerLevel(self, level): argument
426 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_ADV_TX_POWER_LEVEL);
428 def __checkListSize(self, size): argument
430 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_LIST_SIZE);
432 def __checkMaxDataOctets(self, octets): argument
434 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_MAX_DATA_OCTETS);
436 def __checkMaxDataTransmitTime(self, time): argument
438 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_MAX_DATA_TRANSMIT_TIME);
440 def __checkChannelMap(self, map): argument
442 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_CHANNEL_MAP);
444 def __checkPhy(self, phy, legal=[1,2,3]): argument
446 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_PHY_CHANNEL);
448 def __checkSelectedTXPower(self, power, minPower=-127, maxPower=126): argument
450 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_SELECTED_TX_POWER);
452 def __checkMaxAdvDataLength(self, length): argument
454 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_MAX_DATA_LENGTH);
456 def __checkSupportedAdvSets(self, sets): argument
458 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_SUPPORTED_ADV_SETS);
460 def __checkRFPathCompensation(self, value): argument
462 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_RF_COMPENSATION_VALUE);
464 def __checkLinkType(self, linkType): argument
466 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_LINK_TYPE);
468 def __checkConnectionInterval(self, interval): argument
470 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_CONNECTION_INTERVAL);
472 def __checkConnectionLatency(self, latency): argument
474 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_CONNECTION_LATENCY);
476 def __checkSupervisionTimeout(self, timeout): argument
478 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_SUPERVISION_TIMEOUT);
480 def __checkCentralClockAccuracy(self, accuracy): argument
482 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_CENTRAL_CLOCK_ACCURACY);
484 def __checkConnectionRole(self, role): argument
486 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_CONNECTION_ROLE);
488 def __checkAddressType(self, type, legalTypes=[0,1,2,3]): argument
490 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_ADDRESS_TYPE);
492 def __checkAdvEvent(self, event, minEvent=0, maxEvent=4): argument
494 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_ADV_REPORT_EVENT);
496 def __checkAdvDataLength(self, length, maxLength=31): argument
498 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_ADV_DATA_LENGTH);
500 def __checkSid(self, sid, legal): argument
502 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_ADV_SID);
504 def __checkSyncHandle(self, handle): argument
506 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_SYNC_HANDLE);
508 def __checkPeriodicAdvInterval(self, interval): argument
510 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_PERIODIC_ADV_INTERVAL);
512 def __checkAdvDataStatus(self, status): argument
514 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_ADV_DATA_STATUS);
516 def __checkAdvertisingHandle(self, handle): argument
518 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_ADVERTISING_HANDLE);
520 def __checkChannelAlgorithm(self, algorithm): argument
522 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_CHANNEL_SEL_ALGORITHM);
524 def __checkPeerClockAccuracy(self, accuracy): argument
526 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_PEER_CLOCK_ACCURACY)
528 def __checkAdvertisingReports(self, reports, minReports=1, maxReports=25): argument
530 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_NO_ADVERTISING_REPORTS);
533 def __disconnectComplete(self): argument
534 if self.__checkSize(4):
535 status, handle, reason = struct.unpack('<BHB', self.data[:4]);
536 self.__checkConnectionHandle(handle);
541 def __encryptionChangeV1(self): argument
542 if self.__checkSize(4):
543 status, handle, enabled = struct.unpack('<BHB', self.data[:4]);
544 self.__checkConnectionHandle(handle);
545 self.__checkEncryptionEnabled(enabled);
551 def __encryptionChangeV2(self): argument
552 if self.__checkSize(5):
553 status, handle, enabled, key_size = struct.unpack('<BHBB', self.data[:5])
554 self.__checkConnectionHandle(handle)
555 self.__checkEncryptionEnabled(enabled)
556 self.__checkEncryptionKeySize(key_size)
562 def __RemoteVersionComplete(self): argument
563 if self.__checkSize(8):
564 … status, handle, version, manufacturer, subVersion = struct.unpack('<BHBHH', self.data[:8]);
565 self.__checkConnectionHandle(handle);
576 def __readTXPowerLevel(self): argument
577 if self.__checkSize(7):
578 handle, level = struct.unpack('<Hb', self.data[4:7]);
579 self.__checkConnectionHandle(handle);
580 self.__checkTXPowerLevel(level);
585 def __readLEHostSupport(self): argument
586 if self.__checkSize(6):
587 supported, simultaneous = struct.unpack('<BB', self.data[4:6]);
588 self.__checkLESupportedHost(supported);
589 self.__checkLESimultaneousHost(simultaneous);
594 def __readAuthPayloadTimeout(self): argument
595 if self.__checkSize(8):
596 handle, timeout = struct.unpack('<HH', self.data[4:8]);
597 self.__checkConnectionHandle(handle);
598 self.__checkPayloadTimeout(timeout);
599 self.__checkConnectionHandle(handle);
600 self.__checkPayloadTimeout(timeout);
605 def __writeAuthPayloadTimeout(self): argument
606 if self.__checkSize(6):
607 handle = struct.unpack('<H', self.data[4:6])[0];
608 self.__checkConnectionHandle(handle);
613 def __readLocalVersionInformation(self): argument
614 if self.__checkSize(12):
615 …n, hciRevision, lmpVersion, manufacturer, lmpSubversion = struct.unpack('<BHBHH', self.data[4:12]);
620 def __readLocalSupportedCommands(self): argument
621 if self.__checkSize(68):
622 commands = struct.unpack('<64B', self.data[4:68]);
627 def __readLocalSupportedFeatures(self): argument
628 if self.__checkSize(12):
629 features = struct.unpack('<8B', self.data[4:12]);
634 def __readBufferSize(self): argument
635 if self.__checkSize(11):
636 aclLength, synLength, aclPackets, synPackets = struct.unpack('<HBHH', self.data[4:11]);
641 def __readBDAddress(self): argument
642 if self.__checkSize(10):
643 address = struct.unpack('<6B', self.data[4:10]);
648 def __readRssi(self): argument
649 if self.__checkSize(7):
650 handle, rssi = struct.unpack('<Hb', self.data[4:7]);
651 self.__checkConnectionHandle(handle);
652 self.__checkRSSI(rssi);
657 def __leReadBufferSize(self): argument
658 if self.__checkSize(7):
659 dpLength, dpCount = struct.unpack('<HB', self.data[4:7]);
664 def __leReadBufferSizeV2(self): argument
665 if self.__checkSize(10):
666 dpLength, dpCount, isoLength, isoCount = struct.unpack('<HBHB', self.data[4:10]);
671 def __leReadLocalSupportedFeatures(self): argument
672 if self.__checkSize(12):
673 features = struct.unpack('<8B', self.data[4:12]);
678 def __leReadAdvChannelTXPower(self): argument
679 if self.__checkSize(5):
680 power = struct.unpack('<b', self.data[4:5])[0];
681 self.__checkAdvTXPowerLevel(power);
686 def __leReadListSize(self): argument
687 if self.__checkSize(5):
688 size = struct.unpack('<B', self.data[4:5])[0];
689 self.__checkListSize(size);
694 def __leReadChannelMap(self): argument
695 if self.__checkSize(11):
696 handle = struct.unpack('<H', self.data[4:6])[0];
697 chnMap = struct.unpack('<5B', self.data[6:11]);
698 chnMapNo = self.__asNumber(chnMap);
699 self.__checkConnectionHandle(handle);
700 self.__checkChannelMap(chnMapNo);
705 def __leEncrypt(self): argument
706 if self.__checkSize(20):
707 encData = struct.unpack('<16B', self.data[4:20]);
712 def __leRand(self): argument
713 if self.__checkSize(12):
714 number = struct.unpack('<8B', self.data[4:12]);
717 return (self.__asNumber(number),);
719 def __leLTKRequestReply(self): argument
720 if self.__checkSize(6):
721 handle = struct.unpack('<H', self.data[4:6])[0];
722 self.__checkConnectionHandle(handle);
727 def __leReadSupportedStates(self): argument
728 if self.__checkSize(12):
729 states = struct.unpack('<8B', self.data[4:12]);
732 return (self.__asNumber(states),);
734 def __leTestEnd(self): argument
735 if self.__checkSize(6):
736 packets = struct.unpack('<H', self.data[4:6])[0];
741 def __leRemoteConnectionParameterRequest(self): argument
742 if self.__checkSize(6):
743 handle = struct.unpack('<H', self.data[4:6])[0];
744 self.__checkConnectionHandle(handle);
749 def __leSetDataLength(self): argument
750 if self.__checkSize(6):
751 handle = struct.unpack('<H', self.data[4:6])[0];
752 self.__checkConnectionHandle(handle);
757 def __leReadDefaultDataLength(self): argument
758 if self.__checkSize(8):
759 maxOctets, maxTime = struct.unpack('<HH', self.data[4:8]);
760 self.__checkMaxDataOctets(maxOctets);
761 self.__checkMaxDataTransmitTime(maxTime);
766 def __leReadResolvingListSize(self): argument
767 if self.__checkSize(5):
768 size = struct.unpack('<B', self.data[4:5])[0];
773 def __leReadResolvableAddress(self): argument
774 if self.__checkSize(10):
775 address = struct.unpack('<6B', self.data[4:10]);
780 def __leReadMaximumDataLength(self): argument
781 if self.__checkSize(12):
782 … maxTXOctets, maxTXTime, maxRXOctets, maxRXTime = struct.unpack('<HHHH', self.data[4:12]);
783 self.__checkMaxDataOctets(maxTXOctets);
784 self.__checkMaxDataTransmitTime(maxTXTime);
785 self.__checkMaxDataOctets(maxRXOctets);
786 self.__checkMaxDataTransmitTime(maxRXTime);
791 def __leReadPHY(self): argument
792 if self.__checkSize(8):
793 handle, txPHY, rxPHY = struct.unpack('<HBB', self.data[4:8]);
794 self.__checkConnectionHandle(handle);
795 self.__checkPhy(txPHY);
796 self.__checkPhy(rxPHY);
801 def __leSetExtAdvParameters(self): argument
802 if self.__checkSize(5):
803 power = struct.unpack('<b', self.data[4:5])[0];
804 self.__checkSelectedTXPower(power);
809 def __leReadMaxAdvDataLength(self): argument
810 if self.__checkSize(6):
811 maxLength = struct.unpack('<H', self.data[4:6])[0];
812 self.__checkMaxAdvDataLength(maxLength);
817 def __leReadNoOfSupportedAdvSets(self): argument
818 if self.__checkSize(5):
819 maxSets = struct.unpack('<B', self.data[4:5])[0];
820 self.__checkSupportedAdvSets(maxSets);
825 def __leReadTransmitPower(self): argument
826 if self.__checkSize(6):
827 minPower, maxPower = struct.unpack('<bb', self.data[4:6]);
828 self.__checkSelectedTXPower(minPower);
829 self.__checkSelectedTXPower(maxPower);
834 def __leReadRFPathCompensation(self): argument
835 if self.__checkSize(8):
836 txPCValue, rxPCValue = struct.unpack('<hh', self.data[4:8]);
837 self.__checkRFPathCompensation(txPCValue);
838 self.__checkRFPathCompensation(rxPCValue);
843 def __leSetCigParameters(self): argument
844 if self.__checkMinSize(6):
845 cigId, cisCount = struct.unpack('<BB', self.data[4:6])
849 if self.__checkSize(6+cisCount*2):
850 connectionHandle = struct.unpack('<' + str(cisCount) + 'H', self.data[6:6+cisCount*2])
855 def __leSetCigParametersTest(self): argument
856 return self.__leSetCigParameters()
858 def __leRemoveCig(self): argument
859 if self.__checkSize(5):
860 cigId = struct.unpack('<B', self.data[4:5])[0]
865 def __leRejectCisRequest(self): argument
866 if self.__checkSize(6):
867 connectionHandle = struct.unpack('<H', self.data[4:6])[0]
868 self.__checkConnectionHandle(connectionHandle)
873 def __leSetupIsoPath(self): argument
874 if self.__checkSize(6):
875 connectionHandle = struct.unpack('<H', self.data[4:6])[0]
876 self.__checkConnectionHandle(connectionHandle)
881 def __leRemoveIsoPath(self): argument
882 if self.__checkSize(6):
883 connectionHandle = struct.unpack('<H', self.data[4:6])[0]
884 self.__checkConnectionHandle(connectionHandle)
889 def __leIsoTransmitTest(self): argument
890 if self.__checkSize(6):
891 connectionHandle = struct.unpack('<H', self.data[4:6])[0]
892 self.__checkConnectionHandle(connectionHandle)
897 def __leIsoReceiveTest(self): argument
898 if self.__checkSize(6):
899 connectionHandle = struct.unpack('<H', self.data[4:6])[0]
900 self.__checkConnectionHandle(connectionHandle)
905 def __leIsoReadTestCounters(self): argument
906 if self.__checkSize(18):
907 …nHandle, receivedSduCount, missedSduCount, failedSduCount = struct.unpack('<HIII', self.data[4:18])
908 self.__checkConnectionHandle(connectionHandle)
913 def __leIsoTestEnd(self): argument
914 return self.__leIsoReadTestCounters()
923 def __commandComplete(self): argument
924 if self.size >= 4:
925 numPackets, opCode, status = struct.unpack('<BHB', self.data[:4]);
926 if opCode in self.__cceFuncs__:
927 return (numPackets, opCode, status) + self.__cceFuncs__[opCode](self);
930 self.__checkSize(4);
933 def __commandStatus(self): argument
934 if self.__checkSize(4):
935 status, numPackets, opCode = struct.unpack('<BBH', self.data[:4]);
937 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_COMMAND_STATUS_OPCODE);
942 def __hardwareError(self): argument
943 if self.__checkSize(1):
944 error = struct.unpack('<B', self.data[:1])[0];
949 def __completedPackets(self): argument
950 numHandles = struct.unpack('<B', self.data[:1])[0] if self.size > 0 else 0;
953 if self.__checkSize(1 + 4*numHandles):
955 handles.append(struct.unpack_from('<H', self.data, 1+i*4)[0])
956 packets.append(struct.unpack_from('<H', self.data, 3+i*4)[0])
958 self.__checkConnectionHandle(handle);
961 def __dataBufferOverflow(self): argument
962 if self.__checkSize(1):
963 linkType = struct.unpack('<B', self.data[:1])[0];
964 self.__checkLinkType(linkType);
969 def __encryptionKeyRefreshComplete(self): argument
970 if self.__checkSize(3):
971 status, handle = struct.unpack('<BH', self.data[:3]);
972 self.__checkConnectionHandle(handle);
977 def __authenticatedPayloadTimeout(self): argument
978 if self.__checkSize(2):
979 handle = struct.unpack('<H', self.data[:2])[0];
980 self.__checkConnectionHandle(handle);
985 def __connectionComplete(self): argument
986 if self.__checkSize(19):
987 status, handle, role, addressType = struct.unpack('<BHBB', self.data[1:6]);
988 address = struct.unpack('<6B', self.data[6:12]);
989 interval, latency, timeout, accuracy = struct.unpack('<HHHB', self.data[12:19]);
990 self.__checkConnectionHandle(handle);
991 self.__checkConnectionRole(role);
992 self.__checkAddressType(addressType, [0,1]);
993 self.__checkConnectionInterval(interval);
994 self.__checkConnectionLatency(latency);
995 self.__checkSupervisionTimeout(timeout);
996 self.__checkCentralClockAccuracy(accuracy);
1002 def __advertisingReport(self): argument
1003 if self.__checkMinSize(12):
1004 reports, event, addressType = struct.unpack('<BBB', self.data[1:4]);
1005 address = struct.unpack('<6B', self.data[4:10]);
1006 dataSize = struct.unpack('<B', self.data[10:11])[0];
1007 if self.__checkSize(12 + dataSize):
1009 … data = list(struct.unpack('<' + str(dataSize) + 'B', self.data[11:11+dataSize]));
1012 rssi = struct.unpack('b', self.data[11+dataSize:12+dataSize])[0];
1015 self.__checkAdvEvent(event);
1016 self.__checkAddressType(addressType);
1017 self.__checkAdvDataLength(dataSize);
1018 self.__checkRSSI(rssi);
1023 def __connectionUpdateComplete(self): argument
1024 if self.__checkSize(10):
1025 status, handle, interval, latency, timeout = struct.unpack('<BHHHH', self.data[1:10]);
1026 self.__checkConnectionHandle(handle);
1027 self.__checkConnectionInterval(interval);
1028 self.__checkConnectionLatency(latency);
1029 self.__checkSupervisionTimeout(timeout);
1034 def __remoteFeaturesComplete(self): argument
1035 if self.__checkSize(12):
1036 status, handle = struct.unpack('<BH', self.data[1:4]);
1037 features = struct.unpack('<8B', self.data[4:12]);
1038 self.__checkConnectionHandle(handle);
1041 return status, handle, self.__asNumber(features);
1043 def __leLTKRequest(self): argument
1044 if self.__checkSize(13):
1045 handle = struct.unpack('<H', self.data[1:3])[0];
1046 number = struct.unpack('<8B', self.data[3:11]);
1047 diversifier = struct.unpack('<H', self.data[11:13])[0];
1048 self.__checkConnectionHandle(handle);
1051 return handle, self.__asNumber(number), diversifier;
1053 def __connectionParameterRequest(self): argument
1054 if self.__checkSize(11):
1055 … handle, minInterval, maxInterval, latency, timeout = struct.unpack('<HHHHH', self.data[1:11]);
1056 self.__checkConnectionHandle(handle);
1057 self.__checkConnectionInterval(minInterval);
1058 self.__checkConnectionInterval(maxInterval);
1059 self.__checkConnectionLatency(latency);
1060 self.__checkSupervisionTimeout(timeout);
1062 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_PARAMETER_INTERRELATION);
1067 def __dataLengthChange(self): argument
1068 if self.__checkSize(11):
1069 … handle, maxTxOctets, maxTxTime, maxRxOctets, maxRxTime = struct.unpack('<HHHHH', self.data[1:11]);
1070 self.__checkConnectionHandle(handle);
1071 self.__checkMaxDataOctets(maxTxOctets);
1072 self.__checkMaxDataTransmitTime(maxTxTime);
1073 self.__checkMaxDataOctets(maxRxOctets);
1074 self.__checkMaxDataTransmitTime(maxRxTime);
1079 def __publicKeyComplete(self): argument
1080 if self.__checkSize(66):
1081 status = struct.unpack('<B', self.data[1:2])[0];
1082 key = struct.unpack('<64B', self.data[2:66]);
1085 return status, self.__asNumber(key);
1087 def __generateDHKeyComplete(self): argument
1088 if self.__checkSize(34):
1089 status = struct.unpack('<B', self.data[1:2])[0];
1090 key = struct.unpack('<32B', self.data[2:34]);
1093 return status, self.__asNumber(key);
1095 def __enhancedConnectionComplete(self): argument
1096 if self.__checkSize(31):
1097 status, handle, role, addressType = struct.unpack('<BHBB', self.data[1:6]);
1098 peerAddress = struct.unpack('<6B', self.data[6:12]);
1099 localResolvableAddress = struct.unpack('<6B', self.data[12:18]);
1100 peerResolvableAddress = struct.unpack('<6B', self.data[18:24]);
1101 interval, latency, timeout, accuracy = struct.unpack('<HHHB', self.data[24:31]);
1103 self.__checkConnectionHandle(handle);
1104 self.__checkConnectionRole(role);
1105 self.__checkAddressType(addressType);
1106 self.__checkConnectionInterval(interval);
1107 self.__checkConnectionLatency(latency);
1108 self.__checkSupervisionTimeout(timeout);
1109 self.__checkCentralClockAccuracy(accuracy);
1116 def __directAdvertisingReport(self): argument
1117 if self.__checkSize(18):
1118 reports, event, addressType = struct.unpack('<BBB', self.data[1:4]);
1119 address = struct.unpack('<6B', self.data[4:10]);
1120 directAddressType = struct.unpack('<B', self.data[10:11])[0];
1121 directAddress = struct.unpack('<6B', self.data[11:17]);
1122 rssi = struct.unpack('<b', self.data[17:18])[0];
1123 self.__checkAdvertisingReports(reports);
1124 self.__checkAdvEvent(event, 1, 1);
1125 self.__checkAddressType(addressType);
1126 self.__checkAddressType(directAddressType, [1]);
1127 self.__checkRSSI(rssi);
1133 def __phyUpdateComplete(self): argument
1134 if self.__checkSize(6):
1135 status, handle, txPhysical, rxPhysical = struct.unpack('<BHBB', self.data[1:6]);
1136 self.__checkConnectionHandle(handle);
1137 self.__checkPhy(txPhysical);
1138 self.__checkPhy(rxPhysical);
1143 def __extendedAdvertisingReport(self): argument
1144 if self.__checkMinSize(26):
1145 reports, eventType, addressType = struct.unpack('<BHB', self.data[1:5]);
1146 address = struct.unpack('<6B', self.data[5:11]);
1147 …secPHY, sid, txPower, rssi, interval, dirAddressType = struct.unpack('<BBBbbHB', self.data[11:19]);
1148 dirAddress = struct.unpack('<6B', self.data[19:25]);
1149 dataSize = struct.unpack('<B', self.data[25:26])[0];
1150 if self.__checkSize(26 + dataSize):
1152 … data = list(struct.unpack('<' + str(dataSize) + 'B', self.data[26:26+dataSize]));
1157 self.__checkAdvertisingReports(reports, 1, 10);
1158 self.__checkAdvEvent(eventType, 0, 0x7F);
1159 self.__checkAddressType(addressType, [0,1,2,3,255]);
1160 self.__checkPhy(priPHY, [1,3]);
1161 self.__checkPhy(secPHY, [0,1,2,3]);
1162 self.__checkSid(sid, [_ for _ in range(16)] + [255]);
1163 self.__checkSelectedTXPower(txPower, -127, 127);
1164 self.__checkRSSI(rssi);
1165 self.__checkPeriodicAdvInterval(interval);
1166 self.__checkAddressType(dirAddressType, [0,1,2,3,254]);
1167 self.__checkAdvDataLength(dataSize, 229);
1173 def __periodicAdvertisingSync(self): argument
1174 if self.__checkSize(16):
1175 status, handle, sid, addressType = struct.unpack('<BHBB', self.data[1:6]);
1176 address = struct.unpack('<6B', self.data[6:12]);
1177 phy, interval, accuracy = struct.unpack('<BHB', self.data[12:16]);
1178 self.__checkSyncHandle(handle);
1179 self.__checkSid(sid, [_ for _ in range(16)]);
1180 self.__checkAddressType(addressType);
1181 self.__checkPhy(phy);
1182 self.__checkPeriodicAdvInterval(interval);
1183 self.__checkCentralClockAccuracy(accuracy);
1189 def __periodicAdvertisingReport(self): argument
1190 if self.__checkMinSize(8):
1191 … handle, txPower, rssi, unUsed, dataStatus, dataSize = struct.unpack('<HbbBBB', self.data[1:8]);
1192 if self.__checkSize(8 + dataSize):
1194 data = list(struct.unpack('<' + str(dataSize) + 'B', self.data[8:8+dataSize]));
1197 self.__checkSyncHandle(handle);
1198 self.__checkSelectedTXPower(txPower, -127, 127);
1199 self.__checkRSSI(rssi);
1200 self.__checkAdvDataStatus(dataStatus);
1201 self.__checkAdvDataLength(dataSize, 248);
1203 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_ADV_UNUSED_VALUE);
1210 def __periodicAdvertisingSyncLost(self): argument
1211 if self.__checkSize(3):
1212 handle = struct.unpack('<H', self.data[1:3])[0];
1213 self.__checkSyncHandle(handle);
1218 def __scanTimeout(self): argument
1219 self.__checkSize(1);
1222 def __advertiseSetTerminated(self): argument
1223 if self.__checkSize(6):
1224 …tatus, advertiseHandle, connectionHandle, completedEvents = struct.unpack('<BBHB', self.data[1:6]);
1225 self.__checkAdvertisingHandle(advertiseHandle);
1227 self.__checkConnectionHandle(connectionHandle)
1232 def __scanRequestReceived(self): argument
1233 if self.__checkSize(9):
1234 handle, addressType = struct.unpack('<BB', self.data[1:3]);
1235 address = struct.unpack('<6B', self.data[3:9]);
1236 self.__checkAdvertisingHandle(handle);
1237 self.__checkAddressType(addressType);
1242 def __channnelSelectionAlgorithm(self): argument
1243 if self.__checkSize(4):
1244 handle, algorithm = struct.unpack('<HB', self.data[1:4]);
1245 self.__checkConnectionHandle(handle);
1246 self.__checkChannelAlgorithm(algorithm);
1251 def __cisEstablished(self): argument
1252 if self.__checkSize(29):
1253 status, connectionHandle = struct.unpack('<BH', self.data[1:4])
1254 cigSyncDelay = struct.unpack('<3B', self.data[4:7])
1255 cisSyncDelay = struct.unpack('<3B', self.data[7:10])
1256 transportLatencyMToS = struct.unpack('<3B', self.data[10:13])
1257 transportLatencySToM = struct.unpack('<3B', self.data[13:16])
1258 phyMToS, phySToM, nse = struct.unpack('<BBB', self.data[16:19])
1259 bNMToS, bNSToM, fTMToS, fTSToM = struct.unpack('<BBBB', self.data[19:23])
1260 maxPduMToS, maxPduSToM, isoInterval = struct.unpack('<HHH', self.data[23:29])
1263 self.__checkConnectionHandle(connectionHandle)
1264 self.__checkPhy(phyMToS)
1265 self.__checkPhy(phySToM)
1273 def __cisRequest(self): argument
1274 if self.__checkSize(7):
1275 … aclConnectionHandle, cisConnectionHandle, cigId, cisId = struct.unpack('<HHBB', self.data[1:7])
1277 self.__checkConnectionHandle(aclConnectionHandle)
1278 self.__checkConnectionHandle(cisConnectionHandle)
1284 def __request_peer_sca_complete(self): argument
1285 if self.__checkSize(5):
1286 status, connectionHandle, peerClockAccuracy = struct.unpack('<BHB', self.data[1:5])
1289 self.__checkConnectionHandle(connectionHandle)
1290 self.__checkPeerClockAccuracy(peerClockAccuracy)
1297 def __metaEvent(self): argument
1298 if self.subEvent in self.__metaFuncs__:
1299 return self.__metaFuncs__[self.subEvent](self);
1301 raise Exception('LE Meta Event with invalid sub-event 0x%02X' % self.subEvent)
1303 def decode(self): argument
1304 if not self.values is None:
1305 return self.values;
1306 elif self.event in self.__eventFuncs__:
1307 self.values = self.__eventFuncs__[self.event](self);
1308 if not len(self.errors) == 0:
1309 …al values in event data! Event: 0x%02X,0x%02X Errors: %s' % (self.event, self.subEvent, self.error…
1310 return self.values;
1312 self.errors.add(ErrorCodes.BT_HCI_ERR_BAD_EVENT);
1313 raise Exception('Illegal Event with event code 0x%02X' % self.event);
1315 def isCommandComplete(self): argument
1316 return self.event == Events.BT_HCI_EVT_CMD_COMPLETE;
1318 def isCommandStatus(self): argument
1319 return self.event == Events.BT_HCI_EVT_CMD_STATUS;
1321 def __str__(self): argument
1322 if self.event in self.__eventFormats__:
1323 if self.values is None:
1324 self.decode();
1325 if Events.BT_HCI_EVT_LE_META_EVENT != self.event:
1326 … if Events.BT_HCI_EVT_CMD_COMPLETE == self.event and self.values[1] in self.__cceFormats__:
1327 return self.__cceFormats__[self.values[1]].format(*self.values);
1328 … elif Events.BT_HCI_EVT_CMD_STATUS == self.event and self.values[1] in self.__cseFormats__:
1329 return self.__cseFormats__[self.values[1]].format(*self.values);
1331 return self.__eventFormats__[self.event].format(*self.values);
1333 if self.subEvent in self.__metaFormats__:
1334 return self.__metaFormats__[self.subEvent].format(*self.values);
1336 raise Exception('LE Meta Event with invalid sub-event 0x%02X' % self.subEvent);