Mobile app for particle photon


#1

hello! i’m new. i’ve start to study and use particle photon at school and i try to create a very simple mobile app. at the beguinning i’ve created a web app or html page to interact with my photon. with this app i can turn on led d0,d7 make a beep or start nyan on d0. the html works fine. i’ve tried to make a simply mobile app with adobe PhoneGap build. i’ve created my github repository with html and find on github a repository with xlm code. i’ve created the app and installed on my android. but when i try to lanch a command it give me an error page. it say webpage not available. impossible to connect: https:api.particle.io/v1…
why: net::ERR_INVALID_RESPONSE.
i copy my code. if someone can help me i’ll really apriciated the help. thank you in advance.

–xml code:

<?xml version="1.0" encoding="UTF-8" ?>
<widget xmlns   = "http://www.w3.org/ns/widgets"
    xmlns:gap   = "http://phonegap.com/ns/1.0"
    id          = "com.yoursite.basicparticle"
    version     = "1.03.06" >      

  <name>Photon-WebApp-Onide</name>
  <description>
      Web app creata da onide
  </description>
<gap:plugin name="cordova-plugin-whitelist" source="npm"/> 
  <plugin name="cordova-plugin-whitelist" spec="1.3.2" />
  <preference name='phonegap-version' value='cli-8.1.1' />
  <preference name='pgb-builder-version' value='2' />   
  <preference name='phonegap-version' value='cli-7.0.1' />
  <preference name="phonegap-version" value="cli-6.5.0" />  
  <preference name="orientation" value="default" />
  <preference name="fullscreen" value="true" />
  <preference name="android-installLocation" value="auto" />
</widget>

#2

–html code:

<html lang="en">
<head>
<meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Progetto Rutilio ITS 2019</title>
</head>
<body>
<form action="https://api.particle.io/v1/devices/***/nyan?access_token=***" method="POST">
<label for="stato"&gt;Stato &lt;/label><input id='stato' type="text" name="arg">
<button type="submit">NYAN!!</button>
</form>
<form action="https://api.particle.io/v1/devices/***/rgbLed?access_token=***" method="POST">
<label for="stato">Stato </label>
<input id='stato' type="text" name="arg">
<button type="submit">LED D0</button>
</form>
<form action="https://api.particle.io/v1/devices/***/d7?access_token=***" method="POST">
<label for="stato">Stato </label>
<input id='stato' type="text" name="arg">
<button type="submit">LED D7</button>
</form>
<form action="https://api.particle.io/v1/devices/***/setalarm?access_token=***" method="POST">
<label for="stato">Stato</label>
<input id='stato' type="number" name="arg">
<button type="submit">BEEP </button>
</form></body></html> 

#3

no one knows why?


#4

Hi @onide! I wish I could help, but I’m unfamiliar with Adobe PhoneGap. As your html appears to be working without issue, I don’t suspect that this is an issue with the Particle API or with the call itself. I recommend bringing the issue to the PhoneGap Community. I’m happy to give any advice I can from the Particle side during that process.


#5

HI,
I don’t have a clue about this but I did some research and I was able to run my function on photon just from WordPad. I just changed and added one thing:
instead of :

<form action="https://api.particle.io/v1/devices/***/nyan?access_token=***" method="POST">
<label for="stato"&gt;Stato &lt;/label><input id='stato' type="text" name="arg">
<button type="submit">NYAN!!</button>

try this:

<form action="https://api.particle.io/v1/devices/your_device_label/your_function_name?" method="POST"> 
<input type="hidden" name="access_token" value="your_access_token"/>
<label for="stato"&gt;Stato &lt;/label><input id='stato' type="text" name="arg">
<button type="submit">NYAN!!</button>
</form>

results:
light on comand


light on resp.

light off comand

light off response

also I disabled Two-Factor Authentication to test this, i’m not sure if will work with mfa enabled


#6

It should work with 2FA without issue! I’m happy to hear you were able to make this work through another means.


#7

It’s my pleasure :smile:
harder challenge, better challenge :open_hands:
I hope I helped somehow by the way , i’m learned today that I can run my functions get variables just with notepad on my phone :+1:


#8

thank you all. i’ll try when i return in office.