onButtonPress not working?



  • Any ideas why my onButtonPress is not working? Its not turning the led on nor posting to my webservice.

    I also cant figure out how to get data from the getUserCoordinates() call. Best Ive gotten so far is c and o values returned.

    registerAppletDescription('Location Tracker');

    var iota = "blue";
    registerUserVariable("iota", "text", iota, "Iota Name");

    var url = "https://xxxxxx/";

    function onEnterRange() {
    //called when you are in range of a Dot
    //post enter range

    var locationList = getUserCoordinates();
    
    var trackerUrl = url + "api/upload.php?iota=" + iota +
                            "&state=in&lat=" + locationList[ 0 ] + 
                            "&long=" + locationList[ 1 ];
                            
    sendWebRequest(trackerUrl, null, null, "GET", callback);
    
    
                
    }
    

    function onExitRange() {
    //called when you exit the range of a Dot

    var locationList = getUserCoordinates();
    
    var trackerUrl = url + "api/upload.php?iota=" + iota + 
                        "&state=out&lat=" + locationList[ 0 ] + 
                            "&long=" + locationList[ 1 ];
    
    sendWebRequest(trackerUrl, null, null, "GET", callback);
    
    
    }
    

    function onButtonPress() {

    setLED('00CC00');
    
    
    var trackerUrl = url + "api/upload.php?iota=" + iota +
                            "&state=button&lat=123&long=456";
                            
    sendWebRequest(trackerUrl, null, null, "GET", callback);
    
    
    
    setTimeout(5, turnOffLed, {"key1":"key2"});
    }
    

    function turnOffLed( params ){

    setLED('000000');
    }
    

    function callback(data){
    //print( data );
    }


  • administrators

    I've updated documentation for user coords:
    http://docs.doteverything.co/docs/get-user-coordinates

    As for the button press bug, can you confirm that your button is working in general? Does it cause the Find My Iphone app to trigger and your Iota to pulse in the home screen?



  • The button seems to work. It works with the Find my phone and it also does light up when I press it. But it doesnt seem to reflect the hex color value. Its sort of a green/red color always. Ive tried changing the hex value but its always same color. It also never seems to trigger the web call. The button does trigger the web cal if I run it thru the IDE debug mode.

    For the user coordinates Im still getting undefined values.

    If I have this code,

    var locationList = getUserCoordinates();
    
    print( locationList.latitude );
    print( locationList[ 0 ] );    //this is only way that doesnt give me undefined
    print( locationList[ "latitude" ] );  //ide tells me to change to . notation
    print( locationList[ 'latitude' ] );  //ide tells me to change to . notation
    

    I get this in the debug,

    [blue][9:40:3] ~ undefined
    [blue][9:40:3] ~ c
    [blue][9:40:3] ~ undefined
    [blue][9:40:3] ~ undefined

    I also checked and made sure that I have allowed location services for the Iota app.


  • administrators

    @mbattistello Interesting. That may reflect a bug with what happens to the firmware when the button is pressed relating to the LED. We'll look into that. The getUserCoordinates needs to run on the phone to work, because the simulator does not know your location, only the phone gps does.

    If you'd like to test what you are getting, for now I'd suggest scheduling a notification with the contents of the getUserCoordinates results as the title or body, and viewing it that way.

    Can you get notifications to fire for your mod on button press with the scheduleNotificationNow method?


Log in to reply
 

Looks like your connection to Dot Community was lost, please wait while we try to reconnect.