redis test 4
This commit is contained in:
1 parent
f8b11003e3
commit
aaccbbe668
3 files changed
+22
-2
No files matched your search
@@ -182,9 +182,9 @@ The Python code is split across multiple files with different files having code
|
||||
ble-scanner/
|
||||
├─ app.py # Flask + Scheduler + API
|
||||
├─ ble.py # BLE helper functions to read temp+humidity data
|
||||
├─ ble-redis.py # Redis functions for Websocket support
|
||||
├─ scanner.py # Async BLE scan + cache logic
|
||||
├─ config.py # Shared constants (prefix, interval, etc.)
|
||||
├─ redis.py # Redis functions for Websocket support
|
||||
├─ requirements.txt # Python VENV requirements
|
||||
├─ run.sh # Run API from shell
|
||||
├─ scanner.py # Handles scanning for Mii sensors, other helper functions
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
import redis
|
||||
import json
|
||||
from config import *
|
||||
|
||||
####################################################
|
||||
### Redis Functions
|
||||
####################################################
|
||||
if enable_redis:
|
||||
r = redis.Redis(host=bind_ip, port=redis_port)
|
||||
|
||||
def update_redis(data):
|
||||
# push data to redis
|
||||
# Publish to the Redis channel that the WS server is listening on
|
||||
r.publish('temp_hum', json.dumps(data))
|
||||
if debug_output:
|
||||
print("=== Stats Redis Update ===")
|
||||
print(json.dumps(data, indent=2))
|
||||
return True
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ from typing import Set, Iterable
|
||||
from config import *
|
||||
from sensors import *
|
||||
from ble import *
|
||||
from redis import *
|
||||
from ble-redis import *
|
||||
|
||||
# In-memory cache + thread-safe lock
|
||||
_mac_cache: Set[str] = set()
|
||||
|
||||
Reference in new issue
Block a user