Created
January 5, 2025 22:57
-
-
Save amattu2/a59b941a7110cf8d100700cdd88ad008 to your computer and use it in GitHub Desktop.
A proof of concept for implementing a Blink Home Sync Module simulator. This piece connects to the Blink CS endpoint.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This script demonstrates how to connect to the Blink servers using a TCP socket. | |
More information coming soon. | |
""" | |
import socket | |
import ssl | |
import json | |
# Define the server and port | |
server = 'cs-prod.immedia-semi.com' | |
port = 443 | |
cert_file = 'ca_root.pem' | |
# Create a TCP socket | |
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
# Wrap the socket with SSL | |
context = ssl.SSLContext(protocol=ssl.PROTOCOL_TLS_CLIENT) | |
context.load_verify_locations(cafile=cert_file) | |
context.verify_mode = ssl.CERT_REQUIRED | |
ssl_sock = context.wrap_socket(sock, server_hostname=server) | |
try: | |
ssl_sock.connect((server, port)) | |
data = "ack" # TODO: Figure out what to send here | |
ssl_sock.sendall(json.dumps(data).encode('utf-8')) | |
# Wait for the response | |
response = b"" | |
while True: | |
data = ssl_sock.recv(4096) | |
if data: | |
response += data | |
break | |
print(f"Response: {response.decode('utf-8')}") | |
finally: | |
ssl_sock.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-----BEGIN CERTIFICATE----- | |
MIIECTCCAvGgAwIBAgIJANiVYtwQer2wMA0GCSqGSIb3DQEBCwUAMIGaMQswCQYD | |
VQQGEwJVUzEWMBQGA1UECAwNTWFzc2FjaHVzZXR0czEPMA0GA1UEBwwGQm9zdG9u | |
MQ8wDQYDVQQKDAZBbWF6b24xDjAMBgNVBAsMBUJsaW5rMRswGQYDVQQDDBIqLmlt | |
bWVkaWEtc2VtaS5jb20xJDAiBgkqhkiG9w0BCQEWFWFkbWluQGltbWVkaWFzZW1p | |
LmNvbTAeFw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| |
mXrwcThQR2DtREu31kd9+M/CUqzO7mjIIsTygQ/rLAgJLVlpm/2Drsy3vh6Nj9Ng | |
blpUmW3ZPdnqJ1YyDXkLPe2Mo+MgXNhsl4fAq7k= | |
-----END CERTIFICATE----- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment