This post continues from our last entry on how to utilise Intents within Tasker for Android and builds on those examples to demonstrate how to automate functionality on the Flipper Zero.
The examples featured on this page will demonstrate functions such as: the ability to automatically connect to the Flipper Zero, to trigger the playback for files from the Flipper via a task with Tasker.
Table of Contents
Flipper Connectivity Query
Requires a third-party application Gadgetbridge (Links to application on F-Droid).
This Task uses an intent: nodomain.freeyourgadget.gadgetbridge.BLUETOOTH_CONNECT
to test connectivity via Gadgetbridge. Will trigger: android.bluetooth.device.action.ACL_CONNECTED
if connected.
In this example the intent uses an extra variable (string): EXTRA_DEVICE_ADDRESS
which should be the MAC address of the Bluetooth device (this should be the FlipperZero) you are trying to test for.
Tasker Details
Download the XML for: GitLab: Tasker – Flipper Zero Examples to import on your device.
Tasker Profile description
Task: Flipper Connectivity Query
A1: Variable Set [
Name: %FLIPPER_CONNECTED
To: 0
Structure Output (JSON, etc): On ]
A2: Java Function [
Return: intent
Class Or Object: Intent
Function: new
{Intent} () ]
A3: Java Function [
Return: intent
Class Or Object: intent
Function: setAction
{Intent} (String)
Param 1 (String): nodomain.freeyourgadget.gadgetbridge.BLUETOOTH_CONNECT ]
A4: Java Function [
Return: intent
Class Or Object: intent
Function: putExtra
{Intent} (String, String)
Param 1 (String): EXTRA_DEVICE_ADDRESS
Param 2 (String): 00:E1:00:12:00:01]
A5: Java Function [
Class Or Object: CONTEXT
Function: sendBroadcast
{} (Intent)
Param 1 (Intent): intent
Param: "class" ]
Android Java equivalent
This example demonstrates the same functionality in Java.
String deviceAddress = '00:E1:00:12:00:01'; // Replace with your device address
Intent intent = new Intent('nodomain.freeyourgadget.gadgetbridge.BLUETOOTH_CONNECT');
intent.putExtra('EXTRA_DEVICE_ADDRESS', deviceAddress);
// Send the intent to an activity
// startActivity(intent);
// Send the intent to another app,
// context.startActivity(intent);
Flipper Trigger/Play a specific file
Requires a third-party application Gadgetbridge.
This Task uses an intent: nodomain.freeyourgadget.gadgetbridge.flipper.zero.PLAY_FILE
to test connectivity via Gadgetbridge. Will trigger: android.bluetooth.device.action.ACL_CONNECTED
if connected.
This task is intended to be ran from other tasks with parameters: 1 required and 1 optional argument explained below:
%par1
will be the file you wish to play.%par2
will represent a custom app name.
In this example the intent uses 3 extra variables:
- The extra variable (string):
EXTRA_FILE_PATH
which should be the path to the file to playback on the Flipper devices. - The extra variable (string):
EXTRA_APP_NAME
, defaults tosubghz
below you should replace:APP_NAME
with the chosen protocol, examples: subghz, infrared, nfc. - Flipper devices.
- The extra variable (string):
EXTRA_DURATION
, this will default to 3250ms and represents how long the file should be played for.
Tasker Details
Download the XML for: GitLab: Tasker – Flipper Zero Examples to import on your device.
Tasker Task description
Task: Flipper Trigger Task - Example
Settings: Run Both Together
Variables: [ %flipper_file:not set ]
<Default command duration>
A1: Variable Set [
Name: %duration
To: 2500
Structure Output (JSON, etc): On ]
A2: Variable Set [
Name: %wait_duration
To: %duration + 750
Do Maths: On
Max Rounding Digits: 3
Structure Output (JSON, etc): On ]
A3: Java Function [
Return: intent
Class Or Object: Intent
Function: new
{Intent} () ]
A4: Java Function [
Return: intent
Class Or Object: intent
Function: setPackage
{Intent} (String)
Param 1 (String): nodomain.freeyourgadget.gadgetbridge ]
A5: Java Function [
Return: intent
Class Or Object: intent
Function: setAction
{Intent} (String)
Param 1 (String): nodomain.freeyourgadget.gadgetbridge.flipper.zero.PLAY_FILE ]
<Path to the file on the flipper.>
A6: Java Function [
Return: intent
Class Or Object: intent
Function: putExtra
{Intent} (String, String)
Param 1 (String): EXTRA_FILE_PATH
Param 2 (String): PATH_TO_FILE_ON_FLIPPER ]
<Optional App Name: Subghz>
A7: Java Function [
Return: intent
Class Or Object: intent
Function: putExtra
{Intent} (String, String)
Param 1 (String): EXTRA_APP_NAME
Param 2 (String): APP_NAME ]
A8: Java Function [
Return: intent
Class Or Object: intent
Function: putExtra
{Intent} (String, String)
Param 1 (String): EXTRA_DURATION
Param 2 (String): %duration ]
A9: Java Function [
Class Or Object: CONTEXT
Function: sendBroadcast
{} (Intent)
Param 1 (Intent): intent
Param: "class" ]
A10: Flash [
Text: Flipper running: %flipper_file
Continue Task Immediately: On
Dismiss On Click: On ]
A11: Wait [
MS: %wait_duration
Seconds: 0
Minutes: 0
Hours: 0
Days: 0 ]
Android Java equivalent
This example demonstrates the same functionality in Java.
String action = 'nodomain.freeyourgadget.gadgetbridge.flipper.zero.PLAY_FILE';
String filePath = '/ext/subghz/test.sub';
String appName = 'subghz';
int duration = 3250; // in milliseconds
Intent intent = new Intent(action);
intent.putExtra('EXTRA_FILE_PATH', filePath);
intent.putExtra('EXTRA_APP_NAME', appName);
intent.putExtra('EXTRA_DURATION', duration);
// Send the intent to an activity
// startActivity(intent);
// Send the intent to another app,
// context.startActivity(intent);
Monitor Bluetooth device connected
This Profile will monitor for intents broadcasts on action: android.bluetooth.device.action.ACL_CONNECTED
when this event triggers the connected device MAC address will be in the EXTRA_DEVICE
variable which in Tasker is accessed with: %android_bluetooth_device_extra_device
.
In this example the variable: %BLUEMAC_CONNECTED
is set to the value of %android_bluetooth_device_extra_device
. You can add your own requirement here.
Tasker Details
Download the XML for: Profile: Bluetooth Connected Monitor – Example from GitLab to import on your device.
Tasker Profile description
Profile: Bluetooth Connected Monitor - Example
Event: Intent Received [ Action:android.bluetooth.device.action.ACL_CONNECTED Cat:Default Cat:None Scheme:* Mime Type:* ]
Enter Task: Bluetooth Device Connect Events - Example
A1: Variable Set [
Name: %BLUEMAC_CONNECTED
To: %android_bluetooth_device_extra_device
Structure Output (JSON, etc): On ]
Android Java equivalent
This example demonstrates the same functionality in Java.
public class MainActivity extends AppCompatActivity {
private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(BluetoothDevice.ACTION_ACL_CONNECTED)) {
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
String deviceName = device.getName();
Log.d('Bluetooth', 'Device connected: ' + deviceName);
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED);
registerReceiver(mBroadcastReceiver, intentFilter);
}
@Override
protected void onDestroy() {
super.onDestroy();
unregisterReceiver(mBroadcastReceiver);
}
}
Hello! I’ve been following your web site for a long time now and finally got the courage to go ahead and give you a shout out from Austin Tx! Just wanted to tell you keep up the excellent job!
Thank you for the feedback and apologises for only now responding to your comment. All the best and glad to have you here.