Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #17 from tkbstudios/rewrite
Browse files Browse the repository at this point in the history
Rewrite
  • Loading branch information
alessiodam authored Feb 24, 2024
2 parents 6c2082e + 51d9a59 commit fe89c4e
Show file tree
Hide file tree
Showing 9 changed files with 180 additions and 479 deletions.
68 changes: 0 additions & 68 deletions .github/workflows/build-release-master.yml

This file was deleted.

27 changes: 27 additions & 0 deletions .github/workflows/build-windows-executable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
on:
push:

jobs:
build:
runs-on: ['windows-latest']

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.11

- run: pip install -r requirements.txt pyinstaller
- run: pyinstaller --onefile --icon=tkbstudios.ico tinet-bridge.py
- uses: actions/upload-artifact@v4
with:
name: tinet-bridge
path: dist/tinet-bridge.exe

- name: Release
uses: softprops/action-gh-release@v1
if: "contains(github.event.head_commit.message, 'release')"
with:
files: dist/tinet-bridge.exe
tag_name: V${{ github.run_number }}
token: ${{ secrets.CUSTOM_GITHUB_TOKEN }}
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# TINET Bridge
# [DEPRECATED] TINET Bridge
## Why?
TINET Bridge IS DEPRECATED. We are using [lwip-ce](https://google.com) for communication.
lwip-ce is great because it literally is an ethernet cable or a WiFi adapter supporting WPS,
which makes it better in terms of communication and protocol support.

The [documentation](https://tinetdocs.tkbstudios.com/) is updated.

## Old README
This program makes the connection between your calculator and our main servers possible!
[![wakatime](https://wakatime.com/badge/github/tkbstudios/tinet-bridge.svg)](https://wakatime.com/badge/github/tkbstudios/tinet-bridge)
[![.github/workflows/build-windows-executable.yml](https://github.com/tkbstudios/tinet-bridge/actions/workflows/build-windows-executable.yml/badge.svg)](https://github.com/tkbstudios/tinet-bridge/actions/workflows/build-windows-executable.yml)

> ⚠️ please ALWAYS update the bridge to the latest version!
> by doing this you make sure that you have the latest security updates available!
Expand Down
12 changes: 12 additions & 0 deletions plugins/testplugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# this is a test plugin

class TINETBridgePlugin:
def __init__(self):
self.plugin_name = "TestPlugin"
print(f"Successfully loaded {self.plugin_name}")

def custom_print(self, message):
print(f"[{self.plugin_name}]: {message}")

def log_call(self, log_message):
self.custom_print(log_message)
2 changes: 0 additions & 2 deletions pyinstaller.py

This file was deleted.

6 changes: 2 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
pyserial>=3.5
python-dotenv>=1.0.0
colorama>=0.4.6
requests>=2.31.0
pyserial==3.5
pyserial-asyncio==0.6
54 changes: 54 additions & 0 deletions testing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import math
import time
import serial
import serial.tools.list_ports

#--- bridge config ---#

# enable HTTP requests, be careful only using with programs you trust!
ENABLE_HTTP = False

#---------------------#


def find_serial_port():
while True:
time.sleep(0.2)
ports = list(serial.tools.list_ports.comports())
for port in ports:
if "USB Serial Device" in port.description or "TI-84" in port.description:
return port


if __name__ == "__main__":
serial_port = find_serial_port()
time.sleep(2)
serial_connection = serial.Serial(serial_port.device, 115200, timeout=0.2)
serial_connection.write(b"BRIDGE_CONNECTED\n")
username = ""
while True:
data = serial_connection.readline()
if data:
decoded_data = data.decode(errors='ignore').strip()
if decoded_data == "CONNECT_TCP":
print("Connect to TCP server")
serial_connection.write(b"TCP_CONNECTED\n")
elif decoded_data.startswith("LOGIN:"):
login_data = decoded_data.replace("LOGIN:", "").split(":", 2)
# hides the key from the console
login_data[2] = login_data[2][:4] + ("*" * 50) + login_data[2][-4:]
username = login_data[1]
print(f"Login data: {login_data}")
serial_connection.write(b"LOGIN_SUCCESS\n")
elif decoded_data == "BRIDGE_PING":
serial_connection.write(b"BRIDGE_PONG\n")
elif decoded_data.startswith("RTC_CHAT:"):
chat_data = decoded_data.replace("RTC_CHAT:", "").split(":", 1)
print(f"Chat data: {chat_data}")
recipient, message = chat_data
chat_broadcast_str = f"RTC_CHAT:{recipient}:{math.floor(time.time())}:{username}:{message}"
serial_connection.write(chat_broadcast_str.encode())
time.sleep(2)
serial_connection.write(b"RTC_CHAT:global:0:testuser:long message that should be parsed entirely..")
else:
print(decoded_data)
Loading

0 comments on commit fe89c4e

Please sign in to comment.