Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mattd committed Nov 26, 2024
0 parents commit ab23611
Show file tree
Hide file tree
Showing 2,125 changed files with 389,276 additions and 0 deletions.
18 changes: 18 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<h1 align = "center">🌟LilyGo T-Wristband🌟</h1>

- LSM9DS1 is an alternative sensor for MPU9250. How to distinguish the version you purchased, please see the upper right part of the board below to distinguish

- LSM9DS1 为MPU9250的替代传感器,如何分辨你购买的版本,请看下图板子的右上半部分,进行区分

![](image/3.jpg)



<h2 align = "left">📷 Product:</h2>

| Examples | Product Link | Schematic | Status |
| :---------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------: | :----: |
| [Click to view LSM9DS1 Version(点击查看)](./examples/T-Wristband-LSM9DS1/README.MD) | [Click to view product link](https://pt.aliexpress.com/item/4000527495064.html?spm=a2g0o.store_home.hotSpots_1000010030514.0) | [Click to view](./schematic/T_Wristband_lsm9ds1_20200306.pdf) ||
| [Click to view MPU9250 Version(点击查看)](./examples/T-Wristband-MPU9250/README.MD) | Obsolete | [Click to view](./schematic/T_Wristband_mpu9250.pdf) ||
| [Click to view MAX3010X (点击查看)](./examples/T-Wristband-MAX3010X/README.MD) | [Click to view product link](https://pt.aliexpress.com/item/4000527495064.html?spm=a2g0o.store_home.hotSpots_1000010030514.0) | [Click to view](./schematic/T_Wristband_MAX30102.pdf) ||

32 changes: 32 additions & 0 deletions arduhost/bluetooth/acceptpair.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/env python3

import bluetooth
import pdb


pdb.set_trace()
uuid = "94f39d29-7d6d-437d-973b-fba39e49d4ee"

server_sock=bluetooth.BluetoothSocket( bluetooth.RFCOMM )
server_sock.bind(("",bluetooth.PORT_ANY))
server_sock.listen(1)

port = server_sock.getsockname()[1]

bluetooth.advertise_service( server_sock, "SampleServer", service_id = uuid,
service_classes=[uuid, bluetooth.SERIAL_PORT_CLASS],
profiles=[bluetooth.SERIAL_PORT_PROFILE],
)

print("Waiting for connection on RFCOMM channel %d" % port)

client_sock, client_info = server_sock.accept()
print("Accepted connection from ", client_info)

# Automatically accept pairing
#client_sock.set_security(bluetooth.BT_SECURITY_LOW)

while True:
data = client_sock.recv(1024)
if not data: break
print("received [%s]" % data)
25 changes: 25 additions & 0 deletions arduhost/bluetooth/btc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

# https://raspberrypi.stackexchange.com/questions/50496/automatically-accept-bluetooth-pairings#55589

sudo hciconfig hci0 reset
sudo hciconfig hci0 up
sudo hciconfig hci0 piscan
sudo hciconfig hci0 sspmode 1

exit 0

cat << CMDS |
power on
discoverable on
pairable on
trust 24:29:34:93:39:AB
pair 24:29:34:93:39:AB
agent NoInputNoOutput
default-agent
quit
CMDS

while read line; do
bluetoothctl ${line}
done
16 changes: 16 additions & 0 deletions arduhost/bluetooth/bts2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/env python3
import bluetooth

server_sock=bluetooth.BluetoothSocket(bluetooth.RFCOMM)
port = 1
server_sock.bind(("",port))
server_sock.listen(1)

client_sock,address = server_sock.accept()
print("Accepted connection from ",address)

data = client_sock.recv(1024)
print("received [%s]" % data)

client_sock.close()
server_sock.close()
32 changes: 32 additions & 0 deletions arduhost/bluetooth/btserial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/env python3

import socket
import pdb
import pydbus

pdb.set_trace()
bus = pydbus.SystemBus()
adapter = bus.get('org.bluez', '/org/bluez/hci0')

adapter_addr = adapter.Address
port = 3 # Normal port for rfcomm?
buf_size = 1024

s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM)
#s.bind((adapter_addr, port))
s.bind((socket.BDADDR_ANY, port))
s.listen(1)
try:
print('Listening for connection...')
client, address = s.accept()
print(f'Connected to {address}')

while True:
client.send('hi')
data = client.recv(buf_size)
if data:
print(data)
except Exception as e:
print(f'Something went wrong: {e}')
client.close()
s.close()
32 changes: 32 additions & 0 deletions arduhost/bluetooth/expect.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/env python3

import pdb
import pexpect
import subprocess
import sys


def main():
pdb.set_trace()

shcommands = ['power on','agent off','default-agent','pairable on','discoverable on']
[ subprocess.run(f'bluetoothctl {x}'.split()) for x in shcommands ]
bc = pexpect.spawn('/usr/bin/bluetoothctl')
# bc.logfile = sys.stdout.buffer
# bc.sendline('power on')
# bc.expect('succeeded')
# bc.sendline('agent off')
# bc.expect('unregistered')
# bc.sendline('default-agent')
# bc.expect('registered')
# bc.sendline('pairable on')
# bc.expect('succeeded')
# bc.sendline('discoverable on')
# bc.expect('succeeded')
bc.expect_exact('[New]')
bc.expect_exact('Confirm passkey')
bc.sendline('yes')
bc.expect_exact('yes/no')
bc.sendline('yes')

main()
30 changes: 30 additions & 0 deletions arduhost/bluetooth/expect.xp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/expect -f

#hciconfig hci0 sspmode 1

set prompt "#"
#timeout 10

spawn /usr/bin/bluetoothctl
send -- "power on\n"
expect succeeded
sleep 1
send -- "agent off\n"
expect unregistered
sleep 1
send -- "default-agent\n"
expect registered
sleep 1
send -- "pairable on\n"
expect succeeded
sleep 1
send -- "discoverable on\n"
expect succeeded
sleep 4
expect "Confirm passkey"
send -- "yes\r"
sleep 1
expect yes/no
send -- "yes\r"
sleep 1
expect eof
10 changes: 10 additions & 0 deletions arduhost/bluetooth/parse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/env python3

import pdb
import re

msg='WIFI:S:yfinity;T:WPA;P:24HoursADay;H:false;;'
pdb.set_trace()
data = re.match('WIFI:S:(\w+);T:(\w+);P:(\w+);', msg)
pass

15 changes: 15 additions & 0 deletions arduhost/bluetooth/popen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/env python3

import pdb
import subprocess

def main():
pdb.set_trace()
sp = subprocess.Popen(['ls'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
print(sp.stdout.read())
sp.stdin.write(b'pwd\n')
print(sp.stdout.read())
sp.terminate()


main()
Loading

0 comments on commit ab23611

Please sign in to comment.