Example #1
0
	def readByGroupType(self,packet):
		if self.getStage() == BLEMitmStage.ACTIVE_MITM:
			io.info("Read By Group Type Request (from master) : startHandle = "+hex(packet.startHandle)+
			" / endHandle = "+hex(packet.endHandle)+" / uuid = "+hex(packet.uuid))
			io.info("Redirecting to slave ...")
			self.a2sEmitter.sendp(ble.BLEReadByGroupTypeRequest( 	startHandle=packet.startHandle,
										endHandle=packet.endHandle,
										uuid=packet.uuid))
Example #2
0
    def servicesDiscovery(self, uuid, startHandle=0x0001, endHandle=0xffff):
        start, end, continuer = startHandle, endHandle, True
        services = []
        while continuer:

            request = ble.BLEReadByGroupTypeRequest(startHandle=start,
                                                    endHandle=end,
                                                    uuid=uuid)

            self.emitter.sendp(request)

            p = self.receive(
                [ble.BLEReadByGroupTypeResponse, ble.BLEErrorResponse],
                retry=request)

            if isinstance(p, ble.BLEReadByGroupTypeResponse):

                for i in p.attributes:

                    service = ble.Service(data=i['value'][::-1])

                    serviceStruct = {
                        "startHandle": i["attributeHandle"],
                        "endHandle": i["endGroupHandle"],
                        "uuid": service.UUID
                    }

                    if serviceStruct not in services:
                        services.append(serviceStruct)
                start = p.attributes[-1]["endGroupHandle"] + 1
                continuer = (start <= 0xFFFF)
            elif isinstance(p, ble.BLEErrorResponse):
                continuer = False
            else:
                pass
        return services