-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from 0day1day/main
Raspberry PIco W - Micropython support.
- Loading branch information
Showing
17 changed files
with
839 additions
and
0 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
Pico_Pi_W_MicroPython/Standalone Pair New Device Notifications/airpods.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import bluetooth | ||
import time | ||
import random | ||
|
||
def advertise(): | ||
print("Starting AirPod advertising") | ||
# Combine all the data fields | ||
complete_data = data1 + left_speaker + right_speaker + case + data2 | ||
ble.gap_advertise(interval, adv_data=bytes(complete_data)) | ||
|
||
# Initialize BLE | ||
print("Initializing BLE...") | ||
ble = bluetooth.BLE() | ||
ble.active(True) | ||
|
||
if ble.active(): | ||
print("BLE is active") | ||
else: | ||
print("Failed to activate BLE") | ||
|
||
# Parameters | ||
interval = 200 | ||
|
||
# Static data fields | ||
data1 = (0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x02, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45) | ||
data2 = (0xda, 0x29, 0x58, 0xab, 0x8d, 0x29, 0x40, 0x3d, 0x5c, 0x1b, 0x93, 0x3a) | ||
|
||
# Dynamic data fields (initial values) | ||
left_speaker = (random.randint(1, 100),) | ||
right_speaker = (random.randint(1, 100),) | ||
case = (random.randint(128, 228),) | ||
|
||
# Counter for BLE reset | ||
ble_reset_counter = 0 | ||
ble_reset_threshold = 10 | ||
|
||
# Main Loop | ||
while True: | ||
if ble_reset_counter >= ble_reset_threshold: | ||
# Stop and restart BLE | ||
print("Resetting BLE...") | ||
ble.active(False) | ||
time.sleep(1) | ||
ble.active(True) | ||
|
||
# Update the dynamic data fields | ||
left_speaker = (random.randint(1, 100),) | ||
right_speaker = (random.randint(1, 100),) | ||
case = (random.randint(128, 228),) | ||
|
||
ble_reset_counter = 0 | ||
|
||
advertise() | ||
time.sleep(2) | ||
ble_reset_counter += 1 |
55 changes: 55 additions & 0 deletions
55
Pico_Pi_W_MicroPython/Standalone Pair New Device Notifications/airpods_max.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import bluetooth | ||
import time | ||
import random | ||
|
||
def advertise(): | ||
print("Starting AirPods Max advertising") | ||
# Combine all the data fields | ||
complete_data = data1 + left_speaker + right_speaker + case + data2 | ||
ble.gap_advertise(interval, adv_data=bytes(complete_data)) | ||
|
||
# Initialize BLE | ||
print("Initializing BLE...") | ||
ble = bluetooth.BLE() | ||
ble.active(True) | ||
|
||
if ble.active(): | ||
print("BLE is active") | ||
else: | ||
print("Failed to activate BLE") | ||
|
||
# Parameters | ||
interval = 200 | ||
|
||
# Static data fields | ||
data1 = (0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x0a, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45) | ||
data2 = (0xda, 0x29, 0x58, 0xab, 0x8d, 0x29, 0x40, 0x3d, 0x5c, 0x1b, 0x93, 0x3a) | ||
|
||
# Dynamic data fields (initial values) | ||
left_speaker = (random.randint(1, 100),) | ||
right_speaker = (random.randint(1, 100),) | ||
case = (random.randint(128, 228),) | ||
|
||
# Counter for BLE reset | ||
ble_reset_counter = 0 | ||
ble_reset_threshold = 10 | ||
|
||
# Main Loop | ||
while True: | ||
if ble_reset_counter >= ble_reset_threshold: | ||
# Stop and restart BLE | ||
print("Resetting BLE...") | ||
ble.active(False) | ||
time.sleep(1) | ||
ble.active(True) | ||
|
||
# Update the dynamic data fields | ||
left_speaker = (random.randint(1, 100),) | ||
right_speaker = (random.randint(1, 100),) | ||
case = (random.randint(128, 228),) | ||
|
||
ble_reset_counter = 0 | ||
|
||
advertise() | ||
time.sleep(2) | ||
ble_reset_counter += 1 |
55 changes: 55 additions & 0 deletions
55
Pico_Pi_W_MicroPython/Standalone Pair New Device Notifications/airpods_pro.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import bluetooth | ||
import time | ||
import random | ||
|
||
def advertise(): | ||
print("Starting AirPods Pro advertising") | ||
# Combine all the data fields | ||
complete_data = data1 + left_speaker + right_speaker + case + data2 | ||
ble.gap_advertise(interval, adv_data=bytes(complete_data)) | ||
|
||
# Initialize BLE | ||
print("Initializing BLE...") | ||
ble = bluetooth.BLE() | ||
ble.active(True) | ||
|
||
if ble.active(): | ||
print("BLE is active") | ||
else: | ||
print("Failed to activate BLE") | ||
|
||
# Parameters | ||
interval = 200 | ||
|
||
# Static data fields | ||
data1 = (0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x0e, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45) | ||
data2 = (0xda, 0x29, 0x58, 0xab, 0x8d, 0x29, 0x40, 0x3d, 0x5c, 0x1b, 0x93, 0x3a) | ||
|
||
# Dynamic data fields (initial values) | ||
left_speaker = (random.randint(1, 100),) | ||
right_speaker = (random.randint(1, 100),) | ||
case = (random.randint(128, 228),) | ||
|
||
# Counter for BLE reset | ||
ble_reset_counter = 0 | ||
ble_reset_threshold = 10 | ||
|
||
# Main Loop | ||
while True: | ||
if ble_reset_counter >= ble_reset_threshold: | ||
# Stop and restart BLE | ||
print("Resetting BLE...") | ||
ble.active(False) | ||
time.sleep(1) | ||
ble.active(True) | ||
|
||
# Update the dynamic data fields | ||
left_speaker = (random.randint(1, 100),) | ||
right_speaker = (random.randint(1, 100),) | ||
case = (random.randint(128, 228),) | ||
|
||
ble_reset_counter = 0 | ||
|
||
advertise() | ||
time.sleep(2) | ||
ble_reset_counter += 1 |
42 changes: 42 additions & 0 deletions
42
Pico_Pi_W_MicroPython/Standalone Pair New Device Notifications/appletv_appleid.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import bluetooth | ||
import time | ||
|
||
def advertise(): | ||
print("Starting AppleTV Pairing Notification Advertising") | ||
# Use the single data1 field | ||
ble.gap_advertise(interval, adv_data=bytes(data1)) | ||
|
||
# Initialize BLE | ||
print("Initializing BLE...") | ||
ble = bluetooth.BLE() | ||
ble.active(True) | ||
|
||
if ble.active(): | ||
print("BLE is active") | ||
else: | ||
print("Failed to activate BLE") | ||
|
||
# Parameters | ||
interval = 200 | ||
|
||
# Static data field for AppleTV Pairing Notification | ||
data1 = (0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x2b, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00) | ||
|
||
# Counter for BLE reset | ||
ble_reset_counter = 0 | ||
ble_reset_threshold = 10 | ||
|
||
# Main Loop | ||
while True: | ||
if ble_reset_counter >= ble_reset_threshold: | ||
# Stop and restart BLE | ||
print("Resetting BLE...") | ||
ble.active(False) | ||
time.sleep(1) | ||
ble.active(True) | ||
|
||
ble_reset_counter = 0 | ||
|
||
advertise() | ||
time.sleep(2) | ||
ble_reset_counter += 1 |
42 changes: 42 additions & 0 deletions
42
Pico_Pi_W_MicroPython/Standalone Pair New Device Notifications/appletv_audiosync.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import bluetooth | ||
import time | ||
|
||
def advertise(): | ||
print("Starting AppleTV Wireless Audio Sync Advertising") | ||
# Use the single data1 field | ||
ble.gap_advertise(interval, adv_data=bytes(data1)) | ||
|
||
# Initialize BLE | ||
print("Initializing BLE...") | ||
ble = bluetooth.BLE() | ||
ble.active(True) | ||
|
||
if ble.active(): | ||
print("BLE is active") | ||
else: | ||
print("Failed to activate BLE") | ||
|
||
# Parameters | ||
interval = 200 | ||
|
||
# Static data field for AppleTV Wireless Audio Sync | ||
data1 = (0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc0, 0x19, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00) | ||
|
||
# Counter for BLE reset | ||
ble_reset_counter = 0 | ||
ble_reset_threshold = 10 | ||
|
||
# Main Loop | ||
while True: | ||
if ble_reset_counter >= ble_reset_threshold: | ||
# Stop and restart BLE | ||
print("Resetting BLE...") | ||
ble.active(False) | ||
time.sleep(1) | ||
ble.active(True) | ||
|
||
ble_reset_counter = 0 | ||
|
||
advertise() | ||
time.sleep(2) | ||
ble_reset_counter += 1 |
40 changes: 40 additions & 0 deletions
40
Pico_Pi_W_MicroPython/Standalone Pair New Device Notifications/appletv_homekit.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import bluetooth | ||
import time | ||
|
||
def advertise(): | ||
print("Starting Set Up Airplay and Homekit on Apple TV Advertising") | ||
ble.gap_advertise(interval, adv_data=bytes(data1)) | ||
|
||
# Initialize BLE | ||
print("Initializing BLE...") | ||
ble = bluetooth.BLE() | ||
ble.active(True) | ||
|
||
if ble.active(): | ||
print("BLE is active") | ||
else: | ||
print("Failed to activate BLE") | ||
|
||
# Parameters | ||
interval = 200 | ||
|
||
# Static data field | ||
data1 = (0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc0, 0x0D, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00) | ||
|
||
# Counter for BLE reset | ||
ble_reset_counter = 0 | ||
ble_reset_threshold = 10 | ||
|
||
# Main Loop | ||
while True: | ||
if ble_reset_counter >= ble_reset_threshold: | ||
print("Resetting BLE...") | ||
ble.active(False) | ||
time.sleep(1) | ||
ble.active(True) | ||
|
||
ble_reset_counter = 0 | ||
|
||
advertise() | ||
time.sleep(2) | ||
ble_reset_counter += 1 |
40 changes: 40 additions & 0 deletions
40
Pico_Pi_W_MicroPython/Standalone Pair New Device Notifications/appletv_keyboard.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import bluetooth | ||
import time | ||
|
||
def advertise(): | ||
print("Starting AppleTV Keyboard Password Autofill Prompt Advertising") | ||
ble.gap_advertise(interval, adv_data=bytes(data1)) | ||
|
||
# Initialize BLE | ||
print("Initializing BLE...") | ||
ble = bluetooth.BLE() | ||
ble.active(True) | ||
|
||
if ble.active(): | ||
print("BLE is active") | ||
else: | ||
print("Failed to activate BLE") | ||
|
||
# Parameters | ||
interval = 200 | ||
|
||
# Static data field | ||
data1 = (0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x13, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00) | ||
|
||
# Counter for BLE reset | ||
ble_reset_counter = 0 | ||
ble_reset_threshold = 10 | ||
|
||
# Main Loop | ||
while True: | ||
if ble_reset_counter >= ble_reset_threshold: | ||
print("Resetting BLE...") | ||
ble.active(False) | ||
time.sleep(1) | ||
ble.active(True) | ||
|
||
ble_reset_counter = 0 | ||
|
||
advertise() | ||
time.sleep(2) | ||
ble_reset_counter += 1 |
42 changes: 42 additions & 0 deletions
42
Pico_Pi_W_MicroPython/Standalone Pair New Device Notifications/appletv_network.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import bluetooth | ||
import time | ||
|
||
def advertise(): | ||
print("Starting 'Connecting... Apple Tv requires additional information to connect to this network' Advertising") | ||
# Use the single data1 field for advertising | ||
ble.gap_advertise(interval, adv_data=bytes(data1)) | ||
|
||
# Initialize BLE | ||
print("Initializing BLE...") | ||
ble = bluetooth.BLE() | ||
ble.active(True) | ||
|
||
if ble.active(): | ||
print("BLE is active") | ||
else: | ||
print("Failed to activate BLE") | ||
|
||
# Parameters | ||
interval = 200 | ||
|
||
# Static data field for the specific AppleTV message | ||
data1 = (0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc0, 0x27, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00) | ||
|
||
# Counter for BLE reset | ||
ble_reset_counter = 0 | ||
ble_reset_threshold = 10 | ||
|
||
# Main Loop | ||
while True: | ||
if ble_reset_counter >= ble_reset_threshold: | ||
# Stop and restart BLE | ||
print("Resetting BLE...") | ||
ble.active(False) | ||
time.sleep(1) | ||
ble.active(True) | ||
|
||
ble_reset_counter = 0 | ||
|
||
advertise() | ||
time.sleep(2) | ||
ble_reset_counter += 1 |
Oops, something went wrong.