Transmit text file through wifi aka broadcast to your localn
Mar 20, 2024 3:17:15 GMT
AnthroHeart likes this
Post by nathanmyersc on Mar 20, 2024 3:17:15 GMT
Now im not running a server on any device im just repeatedly sending the contents of a text file over wifi.
Its pretty much the intention repeater except it actually transmits a radio signal of the intention. might be interesting. A new toy to try incase you guys already dont do something like that.
I ponder if it works better to transmit it via wifi. it becomes kind of like a rife machine. i have the spooky2 rife generators and i feel like its a similar principal.
TRANSMIT INTENTION VIA WIFI TO EVERYTHING
TRANSMIT TEXT FILE VIA WIFI TO EVERYTHING
Its pretty much the intention repeater except it actually transmits a radio signal of the intention. might be interesting. A new toy to try incase you guys already dont do something like that.
I ponder if it works better to transmit it via wifi. it becomes kind of like a rife machine. i have the spooky2 rife generators and i feel like its a similar principal.
TRANSMIT INTENTION VIA WIFI TO EVERYTHING
import os
import socket
import time
import ctypes
def set_title(title):
ctypes.windll.kernel32.SetConsoleTitleW(title)
def transmit_text_to_device(text, broadcast_port, chunk_size=1024):
try:
lastNumBroadcasts = 0
numBroadcasts = 0
# Convert the input text into bytes
text_bytes = text.encode()
# Create a UDP socket
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
# Enable broadcasting
s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
# Split the content into chunks
chunks_bytes = [text_bytes[i:i+chunk_size] for i in range(0, len(text_bytes), chunk_size)]
while True:
# Send encoded chunks
for chunk_bytes in chunks_bytes:
s.sendto(chunk_bytes, ('<broadcast>', broadcast_port))
numBroadcasts += 1
if(numBroadcasts > lastNumBroadcasts + 100):
set_title("Number Of Broadcasts: " + str(numBroadcasts))
lastNumBroadcasts = numBroadcasts
#time.sleep(1) # Wait for 1 second before sending the file again
except OSError as e:
print(f"Error occurred while transmitting text: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")
# Function to get a string from the user
def get_valid_text():
return input("Enter the text to broadcast: ")
# Example usage:
broadcast_port = 12345 # Choose a port number for broadcasting
text = get_valid_text()
transmit_text_to_device(text, broadcast_port)
TRANSMIT TEXT FILE VIA WIFI TO EVERYTHING
import os
import socket
import time
import ctypes
def set_title(title):
ctypes.windll.kernel32.SetConsoleTitleW(title)
def transmit_text_file_to_device(file_path, broadcast_port, chunk_size=1024):
try:
lastNumBroadcasts = 0;
numBroadcasts = 0;
# Check if the file exists
if not os.path.isfile(file_path):
raise FileNotFoundError("File not found.")
with open(file_path, 'r') as file:
content = file.read()
# Create a UDP socket
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
# Enable broadcasting
s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
# Split the content into chunks
chunks = [content[i:i+chunk_size] for i in range(0, len(content), chunk_size)]
chunks_bytes = [chunk.encode() for chunk in chunks]
while True:
#send encoded chunks
for chunk_bytes in chunks_bytes:
s.sendto(chunk_bytes, ('<broadcast>', broadcast_port))
numBroadcasts += 1
if(numBroadcasts > lastNumBroadcasts + 100):
set_title("Number Of Broadcasts: " + str(numBroadcasts))
lastNumBroadcasts = numBroadcasts
#time.sleep(1) # Wait for 1 second before sending the file again
except FileNotFoundError as e:
print(e)
except OSError as e:
print(f"Error occurred while transmitting file: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")
# Function to get a valid text file path from the user
def get_valid_text_file():
while True:
file_path = input("Enter the path to the text file: ")
if os.path.isfile(file_path) and file_path.lower().endswith('.txt'):
return file_path
print("Invalid file path or not a text file. Please try again.")
# Example usage:
broadcast_port = 12345 # Choose a port number for broadcasting
file_path = get_valid_text_file()
transmit_text_file_to_device(file_path, broadcast_port)
Attachments:
TransmitTextFileToLocalNetworkDevice.py (2.13 KB)
TransmitIntentionToLocalNetworkDevice.py (1.68 KB)