phyphox / phyphox-android

Physical Phone Experiments
GNU General Public License v3.0
303 stars 39 forks source link

Cant connect to MQTT server if experiment is loaded via QR Code #57

Open aamiel1 opened 12 months ago

aamiel1 commented 12 months ago

Hi,

I create this MXL and load it to the Editor, In the Editor i go to the XLM tab to preview the XML, but I see it without the "" section. I also try to use this experiment in the app, but no MQTT message was sent.

<phyphox version="1.11" locale="en">
  <title>MQTT/JSON</title> 
  <category>Net examples</category>
  <icon>://</icon>
  <description>Test for mqtt/json.</description>
  <data-containers>
    <container size="1">accX</container>
    <container size="1">accY</container>
    <container size="1">accZ</container>
  </data-containers>
  <network>
    <connection address="1.1.1.1:1234" autoConnect="true" service="mqtts/json" password="mqttpass" username="mqttusername" sendTopic="phyphox/acc" id="test" privacy="https://phyphox.org/disclaimer/" conversion="json">
        <send id="x" type="buffer" datatype="number">accX</send>
        <send id="y" type="buffer" datatype="number">accY</send>
        <send id="z" type="buffer" datatype="number">accZ</send>
    </connection>
  </network>
  <input>
    <sensor type="accelerometer" rate="10">
      <output component="x">accX</output>
      <output component="y">accY</output>
      <output component="z">accZ</output>
    </sensor>
  </input>
  <views>
    <view label="Test">
      <value label="Accelerometer x" size="2" precision="2" unit="m/s²">
        <input>accX</input>
      </value>
      <value label="Accelerometer y" size="2" precision="2" unit="m/s²">
        <input>accY</input>
      </value>
      <value label="Accelerometer z" size="2" precision="2" unit="m/s²">
        <input>accZ</input>
      </value>
      <button label="Submit">
        <trigger>test</trigger>
      </button>
    </view>
  </views>
</phyphox>
Staacks commented 12 months ago

The first part of your question is not surprising: MQTT or network connections in general are part of the bold warning when opening the editor. The current webeditor dies not support it and just ignores it when loading the configuration. So, unfortunately you will have to edit the XML with a text editor or wait for our new editor which should be published in its first test version in a few weeks.

The question why the XML is not working when loaded directly into phyphox might be trickier, because I don't have a test setup ready taht uses MQTTS with authentication - only basic MQTT. I assume address and credentials were replaced with your values before testing? MQTTS was actually not even implemented by ourselves and it is a rather niche usecase for phyphox. Since it also has never been implemented for the iOS version it is not even yet officially been documented, so at least for testing you might want to try plain MQTT first.