Example #1
0
rounds = 100
i = 0
data = bytearray()
while rounds > i:
    internalblue.logger.info("RNG round %i..." % i)

    # launch assembly snippet
    internalblue.launchRam(ASM_LOCATION_RNG)

    # wait until we set the global variable that everything is done
    while not internalblue.rnd_done:
        continue
    internalblue.rnd_done = False

    # and now read and save the random
    random = internalblue.readMem(MEM_RNG, MEM_ROUNDS * 5)
    data.extend(random)

    i = i + 1

internalblue.logger.info("Finished acquiring random data!")

# every 5th byte i 0x42
check = data[4::5]
for c in check:
    if c != 0x42:
        internalblue.logger.error("Data was corrupted by another process!")

# uhm and for deleting every 5th let's take numpy (oh why??)
data = np.delete(data, np.arange(4, data.__len__(), 5))
Example #2
0
addrlmin = 0x20118a
lmax = "\x01"
addrlmax = 0x20118b
internalblue.writeMem(addrlmin, lmin)
internalblue.writeMem(addrlmax, lmax)

# btadd in little endian
btadd_le = "\x5f\xbf\xa8\x36\x4e\x40"
internalblue.sendHciCommand(0xfc01, btadd_le)

btname = "Name\x00"
addrbtname = 0x200f48
internalblue.writeMem(addrbtname, btname)

# LMP_version
specSupport = struct.unpack("<I", internalblue.readMem(0x200f12, 4))[0]
specSupport &= 0xfffffe00
lmpver = 9
if lmpver == 10:  # Bluetooth 5.1
    specSupport |= 0x100
elif lmpver == 9:  # Bluetooth 5.0?
    specSupport |= 0x80
elif lmpver == 8:  # Bluetooth 4.2?
    specSupport |= 0x40
elif lmpver == 7:  # Bluetooth 4.1
    specSupport |= 0x20
elif lmpver == 6:  # Bluetooth 4.0
    specSupport |= 0x10
elif lmpver == 4:
    specSupport |= 0x4
elif lmpver == 3: