Added a script that sends junk to the websocket to act as a node
This commit is contained in:
33
server/bullshitSender.py
Normal file
33
server/bullshitSender.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import asyncio
|
||||
import websockets
|
||||
import json
|
||||
import random
|
||||
import time
|
||||
|
||||
async def send_data(uri):
|
||||
async with websockets.connect(uri) as websocket:
|
||||
print("Connected to WebSocket server")
|
||||
|
||||
while True:
|
||||
data = {
|
||||
"node": "69:42:08:F5:00:00",
|
||||
"Temp": str(round(random.uniform(0, 25), 2)),
|
||||
"Humi": str(round(random.uniform(0, 90), 2)),
|
||||
"eCO2": str(round(random.uniform(350, 2000), 0)),
|
||||
"TVOC": str(round(random.uniform(100, 1200), 0))
|
||||
}
|
||||
await websocket.send(json.dumps(data))
|
||||
print("Data sent")
|
||||
|
||||
response = await websocket.recv()
|
||||
print("Received message:", response)
|
||||
|
||||
await asyncio.sleep(2) # Wait a bit before sending the next message
|
||||
|
||||
# Start the WebSocket connection
|
||||
while True:
|
||||
try:
|
||||
asyncio.get_event_loop().run_until_complete(send_data("ws://145.92.8.114/ws"))
|
||||
except Exception as e:
|
||||
print("Exception:", e)
|
||||
time.sleep(1) # Wait a bit before trying to reconnect
|
Reference in New Issue
Block a user