Posts

Android App Version with Delphi

Wednesday 8 November 2017, 19:44
ivan.revelli@synaptica.info

Using the JPackageInfo class is simple to retrive the version of your Android application.

This class is already wrapped by Embarcadero in the following unit:
Androidapi.JNI.GraphicsContentViewText

{code}

{$IFDEF ANDROID}

var
PackageManager: JPackageManager;
PackageInfo: JPackageInfo;
begin
PackageManager := SharedActivityContext.getPackageManager;
PackageInfo := PackageManager.getPackageInfo
(SharedActivityContext.getPackageName, 0);
result := JStringToString(PackageInfo.versionName);
End;
{$ENDIF}

Delphi Android WiFi Manager

Friday 29 September 2017, 18:34
ivan.revelli@synaptica.info

L’obiettivo era quello di connettersi a livello programmatico ad una specifica WiFi da qui è sorta l’esigenza di gestire in modo completo la classe Java WifiManager.

Nei tre metodi principali riportati di seguito avremo:

  1. riconoscimento dell’IP Address assegnato alla porta wifi
  2. Elenco delle Wifi disponibili (quelle che il dispositivo riconosce)
  3. Elenco delle configurazioni WiFi salvate sul dispositivo
  4. Possibilità di connettersi ad una specifica Wifi creandone la configurazione se la stessa non esiste

 

Turn Raspberry PI3 into WI-FI router with HOSTAPD

Wednesday 20 September 2017, 13:13
ivan.revelli@synaptica.info

Following this tutorial you’ll be able to configure your RaspBerryPi model 3 to accept incoming connections using its built-it WiFi antenna and to forward the requests to the Ethernet port.

Requirements

  • 1x RaspBerryPi model 3 (earlier versions will not work unless you have a WiFi dongle. In that case, just follow this Adafruit tutorial)
  • 1x Ethernet cable
  • Ethernet access

Context

My current ISP provided me with an old, locked WiFi router that is only capable to broadcast 20mb/s, which is not great for my nominal 100mb/s connection. Furthermore, it messes up my home devices assigning them to different subnets (and sometimes, it mixes local devices with ipv4 and ipv6). Using a Chromecast or a simple Plex server is therefore becoming a bit of an hassle and I thought for a moment that I needed a new WiFi router. Then I realised that most WiFi routers are basically tiny Linux computers with firmware sugar on top of them: so why not turning my RPI into a more useful WiFi router? Please note that this project is basically a proof of concept: the on-board WiFi antenna hasn’t a great range and the top-speed goes barely over 30mb/s. However, seen that this method works, I’ll try to run it with a powerful WiFi USB dongle with AP support to see if the PI can be converted to a more serious 300mb/s router.

Also, this tutorial is a slight modification from this Adafruit tutorial that is meant for RaspBerryPi < v3 and requires a WiFi dongle.

Let’s get on with it, shall we?

Initial checks

Once logged in to your Pi (via Terminal, on another computer), check that everything is setup:

Generally, eth0 is the ethernet connection and wlan0 the WiFi connection. If both are there, we’re good to go.

Software setup

We’ll install and configure 2 programs:

  • hostapd
  • isc-dhcp-server

DHCP server

Now, with this configuration we are assigning the subnet192.168.42.10–50(40 devices in total) and we are configuring our WiFi local IP address to be 192.168.42.1. While we’re at it, we’re assigning Google’s public DNS: 8.8.8.8, 8.8.4.4.

Next, let’s specify on what interface should the DHCP server servce DHCP requests (wlan0 in this case):

Let’s setup wlan0 for static IP:

Hostapd

Some tutorials requires you to set a driver ID. If you need to do that, in order to check what is your current driver ID, run:

…but even though my driver ID reads brcmfmac_sdio, if I put it into the hostapd.conf file I still got an error, but commenting out does the trick.

We aren’t quite done yet, because we also need to tell hostapd where to look for the config file when it starts up on boot. Open up the default configuration file with sudo nano /etc/default/hostapd and find the line #DAEMON_CONF="" and replace it with DAEMON_CONF="/etc/hostapd/hostapd.conf".

Next, let’s configure the network address translation:

Let’s test our access point by running:

You should now be able to see your pi WiFi, connect to it and access internet to it. As a quick comparison, streaming 4k videos will consume about 10% of the pi CPU so… use it accordingly.

As a bonus, if you want to check what’s happening on your WiFi hotspot, check the log file:

If you really feel naughty, (or if you want to prevent naughty behaviour from your connected devices…) let me know in the comments below if you’re interested in a tutorial on how to configure a honeypot with your pi.

ADB Android Shell Find Files

Tuesday 11 July 2017, 18:12
ivan.revelli@synaptica.info

To find a file in the Android Shell “ADB” you can use this command:

you can do the same with

but you can’t see the directory where is the file

DKLang for Delphi

Tuesday 2 May 2017, 16:24
ivan.revelli@synaptica.info

DKLang è un package per Delphi relativo alla gestione dell’internazionalizzazione delle applicazioni.

E’ composto da un insieme di componenti, classi e tools veramente ridotto ma efficace, il tool è open source e compatibile con tutte le piattaforme di sviluppo di Delphi (Windows,MacOSX,iOS,Android e Linux) sia per Firemonkey che VCL.

Le versioni del tool sono scaricabile da github all’indirizzo: https://github.com/yktoo/dklang
Home page del progetto: https://yktoo.com/en/software/dklang
Documentazione: https://github.com/yktoo/dklang/wiki

qualche accortezza nell’uso:

1) nel file di progetto deve essere compresa la direttiva {$R *.dkl_const.res} come da esempio:

Change TextSettings to TTreeVievItem in Firemonkey

Monday 3 April 2017, 22:23
ivan.revelli@synaptica.info

Changing the text property of a tree item in Firemonkey is really simple, you only need to do this:

Discover what we can do for your business
Our languages