diff --git a/README.md b/README.md index 3237672..f506ffb 100644 --- a/README.md +++ b/README.md @@ -1 +1,6 @@ -# ic-705-tools \ No newline at end of file +# ic-705-tools +Set of tools writen in different programming language based on what i really want to do. Sometimes it's python because i like to do things in console, sometimes it will be PHP for some dynamic websites. +Most of them will be proof-of-concept to show possibility with open source and this radio. Any software that is not poc will be in seperate repository on my github. + +------------ +[Image transfer over WiFi to Icom IC-705 and it's called wit. ](https://github.com/sq5t/ic-705-tools/wit/ "Image transfer over WiFi to Icom IC-705 and it's called wit. ") diff --git a/wit/README.md b/wit/README.md new file mode 100644 index 0000000..176bd08 --- /dev/null +++ b/wit/README.md @@ -0,0 +1,23 @@ +## wit - WiFi Image Transfer (for Icom IC-705). +'wit' is simple utility to send picture directly to radio over WiFi. IC-705 need to be accessible over IP with TCP port 60000 to work with this tool. + +#### How it works? +In gimp or any other software create jpeg file with resolution 640x480 and disabled interlace. In script change IP (line 17) and change filename (line 22). After that run script, acknowledge transfer on radio and wait :) + +#### Simple protocol specification. +Create tcp connection to radio to port 60000 and send command: +`\x01\x00\x00\x00\x00\x04\x00\x00\x00` + file size in hex (2 bytes) +Radio will answer with command ack: +`\x01\x01\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00` +and receive ack: +`\x01\x02\x00\x00\x00\x02\x00\x00\x04\x00` +Now we can send header: +`\x01\x03\x00\x00\x04\x03\x00\x00\x01` + size of data + 1024 bytes of data +and wait for receive ack. +On last package of data we need to send: +`\x01\x03\x00\x00\x00\x74\x00\x00\x01` + size of data (2 bytes) + last part of data (<= 1024B). + +------------ + +Yes, on test photo is my hedgehog :) +No, this tool is not some kind of wit, it's only acronym :) diff --git a/wit/test.jpg b/wit/test.jpg new file mode 100644 index 0000000..a1fdcd9 Binary files /dev/null and b/wit/test.jpg differ diff --git a/wit/wit.py b/wit/wit.py new file mode 100755 index 0000000..8e4e13c --- /dev/null +++ b/wit/wit.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python3.6 +# -*- coding: utf-8 -*- + +import socket +import struct + +# Function to convert +def listToString(s): + + # initialize an empty string + str1 = " " + + # return string + return (str1.join(s)) + +# ip address of IC-705 connected to WiFi +tcp_ip = '10.155.0.157' +# standard tcp port for this transsmision +tcp_port = 60000 + +# open test.jpg +f = open("test.jpg", 'rb') +f.seek(0,2) +file_size = f.tell().to_bytes(3, byteorder='big') +f.seek(0) + +command = b'\x01\x00\x00\x00\x00\x04\x00\x00\x00' # command for file transfer to radio +cmd_ack = b'\x01\x01\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00' # command acknowledge +rcv_ack = b'\x01\x02\x00\x00\x00\x02\x00\x00\x04\x00' # receive acknowledge +send_next = b'\x01\x03\x00\x00\x04\x03\x00\x00\x01' # header of next part of picture +send_last = b'\x01\x03\x00\x00\x00\x74\x00\x00\x01' # header of last part of picture + +s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +s.connect((tcp_ip, tcp_port)) +message_tmp = command + file_size +s.send(message_tmp) +s.setblocking(1) + +data = s.recv(22) +answer = cmd_ack + rcv_ack + +if(data == cmd_ack): + data = s.recv(22) + if(data != rcv_ack): + print("No 'receive ack' received from radio") + exit() +elif(data != answer): + if(data != cmd_ack): + print("No 'command ack' received from radio") + print(data) + exit() + +while True: + piece = f.read(1024) + if not piece: + break + piece_size = len(piece).to_bytes(2, byteorder='big') + if(len(piece)==1024): + to_send = send_next + piece_size + piece + s.send(to_send) + data = s.recv(10) + while (len(data) == 0): + data = s.recv(10) + if(data != rcv_ack): + print("Error, 'receive ack' not received.") + exit() + else: + to_send = send_last + piece_size + piece + s.send(to_send) +f.close() +s.close()