jrowberg / bglib

BGLib implementation for Bluegiga BLE Bluetooth Smart modules
Other
240 stars 170 forks source link

Python 3.6 - xrange not defined #47

Open Eriobis opened 6 years ago

Eriobis commented 6 years ago

the xrange is not defined in python 3, you need to use range instead. Since the division gives a float output, need to cast it into an int Line 387 to 395 :

                                if this_field[0] == 0x02 or this_field[0] == 0x03: # partial or complete list of 16-bit UUIDs
                                    for i in range(int((len(this_field) - 1) / 2)):
                                        ad_services.append(this_field[-1 - i*2 : -3 - i*2 : -1])
                                if this_field[0] == 0x04 or this_field[0] == 0x05: # partial or complete list of 32-bit UUIDs
                                    for i in range(int((len(this_field) - 1) / 4)):
                                        ad_services.append(this_field[-1 - i*4 : -5 - i*4 : -1])
                                if this_field[0] == 0x06 or this_field[0] == 0x07: # partial or complete list of 128-bit UUIDs
                                    for i in range(int((len(this_field) - 1) / 16)):
                                        ad_services.append(this_field[-1 - i*16 : -17 - i*16 : -1])