testo / tjf

Schema definitions of the Testo JSON format (tjf). Used in t300 / t330 / t330i / t400 / t420 / SmartProbes / t550 / t557 / t550s / t557s / testo Smart
https://www.testo.com
Apache License 2.0
6 stars 3 forks source link

Help needed: App2App Testo Combustion app with Microsoft Field Service #2

Open robbertvdijk opened 2 years ago

robbertvdijk commented 2 years ago

Hello,

For a customer I work for I try to use the App2App interface in order to receive measurement data. However, I am a bit stuck. I hope you can help me.

I use: testot330://start?bundleid=com.microsoft.crm.crmphone.fieldServices in order to open the Testo Combustion app, as described in the section Workflow. I try this with a Field Service app by Microsoft. Once I execute the code the testo app will open and connect to a Testo 330 device. However, nothing seems to happen afterwards. Not automatically, nor when I manually save a measurement. In the readme it says select export via JSON/JTF. I do not see an export button or something similar. How does the caller app receives the url?

How does this step work exactly? Do you maybe have an example?

Thanks in advance.

gwaldvogel commented 2 years ago

Hello @RobbertvDijk,

when the testo Combustion App is called via the App2App interface the export button (bottom right of the screen) should give you the option to export the JSON back to the caller app, which then in your case will try to call the following URL: testoapp+com.microsoft.crm.crmphone.fieldServices://data?json=[base64_encoded_json_data].

On Android the caller app needs to register an intent-filter in the AndroidManifest.xml: <data android:scheme="testoapp+androiddatareceiverdemo" />

Full example AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="de.testo.androiddatareceiverdemo" android:versionName="1.1" android:versionCode="1" >

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".AndroidDataReceiverDemo" android:launchMode="singleTask">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter>
                <data android:scheme="testoapp+androiddatareceiverdemo" />
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            </intent-filter>
            <intent-filter>
                <data android:scheme="file"/>
                <data android:host="*"/>
                <data android:mimeType="application/json" />
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.BROWSABLE" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
    </application>
    <supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
</manifest>

If you have any further questions please let us know.

robbertvdijk commented 2 years ago

Hello @gwaldvogel ,

Thank you very much for your answer. For me it is now clear what should be done. Unfortunately the Android app we are using is developed and managed by Microsoft. We do not have the possibility to change things like the AndroidManifest.xml. Do we have another option to receive data from the Testo device to our Field Service App? Some details:

Thanks again!

spandey1988 commented 2 years ago

Hello @gwaldvogel

Is there also no way to directly connect using JS through an API for Testo 330 ?

Thanks, Suyash

gwaldvogel commented 2 years ago

Is there also no way to directly connect using JS through an API for Testo 330 ?

You could try accessing the Device2Device API by sending a GET Request to http://localhost:53757/data while the testo Combustion App is running in the background. If you use a different app you will have to adapt the port accordingly. This might work, but can be unreliable on some devices that are more trigger happy with closing apps that are running in the background.

@RobbertvDijk this might also be a possible solution for your problem.

spandey1988 commented 2 years ago

Hello @gwaldvogel ,

Indeed we get a JSON response back. However, when we try to make the request from our App, we get CORS origin issues. Any suggestions?

gwaldvogel commented 2 years ago

The testo Combustion app sends Access-Control-Allow-Origin: *, you shouldn't have any issues with CORS. Are you using the most recent version of the testo Combustion app?

spandey1988 commented 2 years ago

Hey @gwaldvogel : I think we have the latest version of the app i.e. 2.20. Let me know if this might not be the right version.

spandey1988 commented 2 years ago

Hey @gwaldvogel : Any suggestions on how we can get it working ? We are almost there in retrieving the data. Only the CORS issue is blocking us. Apparenlty with browsers it works but with the app it is not allowed.

gwaldvogel commented 2 years ago

@spandey1988 The testo App should send you the correct CORS header, can you verify that the issue is not due to your http library?

GuzmanHrz commented 2 years ago

Is there also no way to directly connect using JS through an API for Testo 330 ?

You could try accessing the Device2Device API by sending a GET Request to http://localhost:53757/data while the testo Combustion App is running in the background. If you use a different app you will have to adapt the port accordingly. This might work, but can be unreliable on some devices that are more trigger happy with closing apps that are running in the background.

@robbertvdijk this might also be a possible solution for your problem.

Hello @gwaldvogel , Is anywhere more documentation about this JS API? I'm intending to get the data from Dynamics 365 Field Service Mobile app and looks like the only way to personalize it is adding client side scripts

@robbertvdijk Were you able to make it work ? What was your approach ?

robbertvdijk commented 2 years ago

Hi @GuzmanHrz , I've got a working solution now. Eventually what I did was create a button in our Field Service app which opens the Testo app. Then we have a manual step where the user saves a measurement (the app will copy a JSON with measurement data to the clipboard automatically. This is a feature of the Testo app). Now this JSON message can be pasted in our Field Service system and a Javascript function will read the message and the measurement data is further processed in our system.

This works quite well, but as you can read it is not totally automated.

GuzmanHrz commented 2 years ago

Hey @gwaldvogel : Any suggestions on how we can get it working ? We are almost there in retrieving the data. Only the CORS issue is blocking us. Apparenlty with browsers it works but with the app it is not allowed.

Hello! Did you find a way to access the data from the app?

GuzmanHrz commented 2 years ago

Hi @GuzmanHrz , I've got a working solution now. Eventually what I did was create a button in our Field Service app which opens the Testo app. Then we have a manual step where the user saves a measurement (the app will copy a JSON with measurement data to the clipboard automatically. This is a feature of the Testo app). Now this JSON message can be pasted in our Field Service system and a Javascript function will read the message and the measurement data is further processed in our system.

This works quite well, but as you can read it is not totally automated.

Thanks for your reply @robbertvdijk unfortunately looks like my customer doesn't like that approach and are looking for something fully automated still I'm not sure if is possible.

By the way were you trying to integrate this to the Dynamics 365 Field Service app or to the Field Service app (Xamarin) ?

How do you open the testo app from the JS? All examples I could find talk about open an app with JS from the browser but not idea if from a client script in Field Service app would be the same

gwaldvogel commented 2 years ago

Hello @gwaldvogel , Is anywhere more documentation about this JS API? I'm intending to get the data from Dynamics 365 Field Service Mobile app and looks like the only way to personalize it is adding client side scripts

We have an OpenAPI description here: https://github.com/testo/tjf/blob/public/api/testoApi.yaml Most of the endpoints tagged with t300 should work on the testo Combustion App & testo 330 too.