I have a RPi 4 + Sixfab Base HAT + Quectel EC25 4G LTE modem + Picam and I am trying to develop a program to take pictures from picam and send them over 4G using TCP/IP protocol and then receive and display the picture on Linux Socket Server.

I don't have alot of experience with this, and have seen some Socket programming information but it does not completely fit for me because I am using Quectel 4G modem instead of wifi or ethernet - which means I can't use socket. functions, but only AT commands.

So far, I can send a small 20x20 png encoded with base64 from Rpi with 4G and receive it in socket server but cannot reconstruct the small image.

But if the data gets larger I need to define a protocol (File size, start - end - etc. ) . I have seen some custom protocols but they are only for socket servers and not incorporate the use of 4G modems. I would appreciate if anyone can guide me in the right direction. .

if ser.isOpen(): # if modem is open
try:
        ser.flushInput() 
        ser.flushOutput()

        BG96 = bg96_init()  # initialize function for the Modem

        i = 0
    encoded = ""
        #start = time.time()
        while BG96:# 
                if i==0:# does something the first time but not relevant here << 
            print(i)
        encoded = base64.b64encode(open('testingimg.png', 'rb').read())
                print("Data size to send to 4G module:" , sys.getsizeof(encoded))
        print("The Image String: " , encoded)
        bg96_msg(encoded) # This is a function that sends the data via TCP with AT commands 

        encoded=""
        
        ser.flushInput() 
        ser.flushOutput()
        i = i+
        time.sleep(0.33)
1

There are 1 best solutions below

6
On

how do you connect EC25 to rpi? if you use USB you don't have to use AT command set and you pi connects to the internet directly over 4g modem.