This issue happened to both my photon and argon. I really don’t think it’s my code’s problem since I was testing with the code that I have tested multiple times. Basically I will be able to connect to API for the first few minutes and then it will get disconnected. When I run diagnostic test on them, it said the device cloud is healthy but the device vital is having problems “can’t fetch device metadata”
I have also tried to enter safe mode then flash tinker code to the device but even that failed and returned a hard fault.
Here’s the simple code I flashed that changes the delay time
int t = 0;
void setup()
{
Particle.function("setT", setTime);
Particle.variable("getT", &t, INT);
}
void loop()
{
Particle.publish("time delay", String(t));
delay(1000);
}
int setTime(String posValue) {
t = posValue.toInt();
return 0;
}
And here’s the html code I used to change delay time.
<!DOCTYPE HTML>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<title>Slider</title>
<link href="sliderv2.css" rel="stylesheet" type="text/css" />
<body>
<P>Set Delay Time:<br><br>
<div class="slider-wrapper">
<input type="range" name="degBox" id="degBoxId" min="0" max="8000" step="1" value="4000" list="myData" onchange="setValue(this)">
</div>
<!-- This adds the tick marks to the range but does not in Safari -->
<datalist id="myData">
<option value="0" label="0">
<option value="500">
<option value="1000">
<option value="1500">
<option value="2000" label="2000">
<option value="2500">
<option value="3000">
<option value="3500">
<option value="4000" label="4000">
<option value="4500">
<option value="5000">
<option value="5500">
<option value="6000" label="6000">
<option value="6500">
<option value="7000">
<option value="7500">
<option value="8000" label="8000">
</datalist>
<br><br>
<button id="minusbutton" onclick="fineAdjust(-50)">⇐ -50</button>
<button id="plusbutton" onclick="fineAdjust(+50)">+50 ⇒</button>
<br><br>
<P>Current Delay Time: <span id="curPos"></span><br>
<script type="text/javascript">
var deviceID = "xxxxx";
var accessToken = "xxxxxx";
var setFunc = "setT";
var getFunc = "getT";
window.setInterval(function() {
requestURL = "https://api.particle.io/v1/devices/" + deviceID + "/" + getFunc + "/?access_token=" + accessToken;
$.getJSON(requestURL, function(json) {
document.getElementById("curPos").innerHTML = json.result + " ms";
document.getElementById("curPos").style.fontSize = "28px";
document.getElementById("degBoxId").value = parseInt(json.result);
});
}, 1000);
function setValue(obj) {
var newValue = document.getElementById('degBoxId').value;
sparkSetPos(newValue);
}
function fineAdjust(value) {
var currentValue = parseInt(document.getElementById('curPos').innerHTML);
var setValue = value + currentValue;
sparkSetPos(setValue);
document.getElementById("degBoxId").value = setValue;
}
function sparkSetPos(newValue) {
var requestURL = "https://api.particle.io/v1/devices/" +deviceID + "/" + setFunc + "/";
$.post( requestURL, { params: newValue, access_token: accessToken });
}
</script>
</body>
</html>
This code will work for the first few minutes and then failed. I’m really confused about what’s going on and was wondering if anyone is experiencing the same issue. I have already reset the access token today should I try it again?