.csv file transfer and receive (Android and Beaglebone(Debian 10))

Hello,
I have a 6 types of .csv files in my android device. I want to send them to beaglebone using a wifi. and also send to android device. pls suggest the solution for it.

thanks.

  • You can connect the phone to the BB through which you can interactively transfer the files
  • Setup a FTP server on the BB
  • use adb(android debug bridge)->either add shell or add push

This are a few ways I can think of for now

FTP is supported on beaglebone?

Yep!
As long as a device has networking capabilities with 2 free ports
a FTP server could be hosted there…

This is really old school and you should be able to implement this using python, I don’t do python so you will have to puzzle that out. Set up an smtp client on bbb and just email it to and from any device with email. That creates common ground so you can deploy on any os that has internet and smtp services.

Thanks, But i want to do it automatically.
In our application, we are looking for two way communication approach. In which, suppose 1. a file is updated first on beaglebone - it should be sent to android device automatically.
2. a file is updated on android device - user will send this to beaglebone.

How can i do it? I am waiting for your feedback.
Thanks.

There is not enough detail.

Does the Android device have mobile data, or just bluetooth & wireless ?
Do the file transfers need to be done over the internet ?
Do you need multiple Android devices connected to the Beaglebone ?
Does the Android device support external USB memory plugged into its USB port ?

Ok, I will provide detailed information.

  1. Does the Android device have mobile data, or just bluetooth & wireless ?
    We are using Tablet for it, it have wifi and bluetooth. But we can able to connect it to internet using wifi.

  2. Do the file transfers need to be done over the internet ?
    – No, via wifi or ble.

  3. Do you need multiple Android devices connected to the Beaglebone ?
    – No, Single device we are connecting to Beaglebone.

  4. Does the Android device support external USB memory plugged into its USB port ?
    No.

For receiving files, I have written python script. But i am facing a issue regarding dbus-session.
Script - `

import os
import sys
import dbus
import dbus.service
import dbus.mainloop.glib
from gi.repository import GLib

BUS_NAME = 'org.bluez.obex'
PATH = '/org/bluez/obex'
AGENT_MANAGER_INTERFACE = 'org.bluez.obex.AgentManager1'
AGENT_INTERFACE = 'org.bluez.obex.Agent1'
TRANSFER_INTERFACE = 'org.bluez.obex.Transfer1'

bus = None
transfers = {}

class Transfer:
	def __init__(self, watch, path, file, size=0):
		self.watch = watch
		self.path  = path
		self.file  = file
		self.size  = size

	def progress(self,amount):
		percent = (amount / self.size) * 100
		print("Progress: "+str(round(percent))+"%\r",end="")

	def finish(self):
		print("Cleaning up for "+self.file)
		self.watch.remove()
		# FIXME: obexd path is hardcoded, could be extracted from Session interface
		os.rename(os.path.expanduser("~/.cache/obexd/")+self.file,
		#	GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DOWNLOAD)+"/"+self.file)
                "/home/debian/BLER/"+self.file)
		transfers.pop(self.path)

def signal_handler(name,properties,ignore,path=""):
	if "Size" in properties:
		transfers[path].size = properties["Size"]
	if "Status" in properties:
		if properties["Status"] == "complete":
			transfers[path].finish()
	if "Transferred" in properties:
		transfers[path].progress(properties["Transferred"])

class Agent(dbus.service.Object):
	def __init__(self, conn=None, obj_path=None):
		dbus.service.Object.__init__(self, conn, obj_path)

	@dbus.service.method(AGENT_INTERFACE, in_signature="o", out_signature="s")
	def AuthorizePush(self, path):
		transfer = dbus.Interface(bus.get_object(BUS_NAME, path), 'org.freedesktop.DBus.Properties')
		properties = transfer.GetAll(TRANSFER_INTERFACE)
		filename = properties["Name"]

		print("Incoming transfer: "+filename)

		watch = bus.add_signal_receiver(signal_handler,path=path,path_keyword="path")
		transfers[path] = Transfer(watch,path,filename)

		return filename

	@dbus.service.method(AGENT_INTERFACE, in_signature="", out_signature="")
	def Cancel(self):
		print("Authorization Canceled")

if __name__ == '__main__':
	dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)

	bus = dbus.SessionBus()
	manager = dbus.Interface(bus.get_object(BUS_NAME, PATH), AGENT_MANAGER_INTERFACE)

	path = "/test/agent"
	agent = Agent(bus, path)

	mainloop = GLib.MainLoop()

	manager.RegisterAgent(path)
	print("Agent registered")

	mainloop.run()

`

when i run above script without sudo it works but when i run above script with sudo it shows error as below-

pls take a look on it.
Thanks…

Yeah the whole Bluetooth stack is complicated. I have avoided it where possible,

I would suggest using normal networking but that at least involves setting up the Beaglebone as an access point, or the better option would be to connect the Beaglebone via ethernet cable to a WiFi hub.

If I was going to use Bluetooth I would look at a Bluetooth to serial bridge setup using something like the HC-05 modules. That way to can drop the whole Bluetooth stack. Just run some software on the Beaglebone when it powers up and connect to the UART port so no need to worry about DBus.

You would of course also need to write some Android software that can talk Bluetooth serial. I know it is supported on Android, but have never had cause to use it so no idea how simple it is to implement, but I am sure there are probably some examples out there.

That very last line might be fixed using

$export DISPLAY=:0

Before doing that

$env >> original.env.txt

Just noticed you are on a beaglebone, what board ?

my beaglebone have inbuilt wifi/ble module.

I am using Beaglebone black wireless with Debian GNU/Linux 11 (bullseye).

Sorry, I dont have clear idea about your last response.