giech / arduinotaskerbluetooth

Android Tasker plugin for sending serial messages over Bluetooth. Example Arduino code for turning a switch on/off
20 stars 9 forks source link

passing text variable from tasker #2

Closed sagaruday closed 7 years ago

sagaruday commented 7 years ago

How to send the text variable from tasker via bluetooth ??

manu-t commented 7 years ago

Hi, I modified the android app to do that (TaskerPlugin.Setting.setVariableReplaceKeys) :

    // Method that returns the bundle to be saved
    @Override
    public Bundle getResultBundle() {
        String mac = macText.getText().toString();
        String msg = ((EditText) findViewById(R.id.msg)).getText().toString();
        boolean crlf = ((CheckBox) findViewById(R.id.checkbox)).isChecked();

        Bundle bundle = new Bundle();
        bundle = BundleManager.generateBundle(mac, msg, crlf);;

        if (TaskerPlugin.Setting.hostSupportsOnFireVariableReplacement(this))
            TaskerPlugin.Setting.setVariableReplaceKeys(bundle, new String[]{"com.giechaskiel.ilias.bluetoothserialfromtasker.STRING_MSG"});

        //return BundleManager.generateBundle(mac, msg, crlf);
        return bundle;
    }

in the PluginActivity.java file.

You also have to add the TaskerPlugin. java file to the project. It's my first test with java and android studio, so I hope there is no stupid mistake...

giech commented 7 years ago

Thank you both for this issue. I have updated the code to allow for variable use in both the Bluetooth MAC field and the message field (but not the CRLF boolean). Both the code and the APK have been updated to reflect this.

manu-t commented 7 years ago

You're welcome.