Git Product home page Git Product logo

Comments (9)

carestad avatar carestad commented on June 12, 2024

Something like this might work:

      public function getLocation() {
        $initResult = $this->sendRequest('MyCarFinderRequest.php');
  
        $result = new stdClass;
        $code = $initResult->status;
  
        if (200 == $code && !empty($this->resultKey)) {
          $start = time();
  
          while (true) {
            $result = $this->sendRequest('MyCarFinderResultRequest.php', ['resultKey' => $this->resultKey]);
  
            // Don't get stuck forever
            if (time() - $start < 100) {
              if (1 != $result->responseFlag) {
                echo "Still not ready...\n";
              }
  
              sleep(5);
              continue;
            }
            else {
              echo "Taking too long. Have to give up.\n";
            }
  
            break;
          }
        }
  
        return $result;
      }   

from nissan-connect-php.

gboudreau avatar gboudreau commented on June 12, 2024

Is "find my car" a new feature in the Nissan LEAF official app, for newer LEAF models ?
I have never seen that in my version of the app.

from nissan-connect-php.

carestad avatar carestad commented on June 12, 2024

Hm, it might be? My app version is 3.0.6, last updated in November 2016. It's from Nissan Europe though, so maybe it's for European users? My Leaf is a 2016 model so it might be newer models only perhaps.

I also noticed the endpoint my app uses is a bit different, and all the requests goes to https://gdcportalgw.its-mo.com/gworchest_160803EC/gdc/

from nissan-connect-php.

gboudreau avatar gboudreau commented on June 12, 2024

I'd need a PR to integrate this functionality, as I don't have access to it.
If you tested the above function, and it works, I can integrate that.

from nissan-connect-php.

carestad avatar carestad commented on June 12, 2024

Well kinda, but it has some debugging info that is unnecessary if it is to be pushed to master. I also realized that there was a waitUntilSuccess() method that did most of what I do there, so the simplest implementation of this is really just:

public function getLocation() {
  $result = $this->sendRequest('MyCarFinderRequest.php');
  return $this->waitUntilSuccess('MyCarFinderResultRequest.php');
}   

A var_dump of the result will give you something like this:

object(stdClass)#3 (9) {
  ["status"]=>
  int(200)
  ["responseFlag"]=>
  string(1) "1"
  ["resultCode"]=>
  string(1) "1"
  ["timeStamp"]=>
  string(19) "2017-10-12 18:38:19"
  ["Location"]=>
  object(stdClass)#12 (12) {
    ["Position"]=>
    string(11) "UNAVAILABLE"
    ["LocationType"]=>
    string(5) "WGS84"
    ["LatitudeMode"]=>
    string(5) "NORTH"
    ["LongitudeMode"]=>
    string(4) "EAST"
    ["Home"]=>
    string(7) "OUTSIDE"
    ["LatitudeDeg"]=>
    string(2) "99"
    ["LatitudeMin"]=>
    string(2) "99"
    ["LatitudeSec"]=>
    string(4) "9999"
    ["LongitudeDeg"]=>
    string(1) "9"
    ["LongitudeMin"]=>
    string(2) "99"
    ["LongitudeSec"]=>
    string(4) "9999"
    ["Country"]=>
    string(0) ""
  }
  ["receivedDate"]=>
  string(16) "2017/10/12 18:38"
  ["TargetDate"]=>
  string(16) "2017/10/12 18:38"
  ["lat"]=>
  string(15) "1.234567890"
  ["lng"]=>
  string(15) "1.234568790"
}

I can create a pull request for you.

from nissan-connect-php.

gboudreau avatar gboudreau commented on June 12, 2024

Merged in #15

from nissan-connect-php.

Raiden38 avatar Raiden38 commented on June 12, 2024

Where is the MyCarFinderRequest.php file? Do we need it to make it work?

Can this be called at the same time then a normal status request? How? Thanks!

from nissan-connect-php.

carestad avatar carestad commented on June 12, 2024

You just need to call the getLocation() method after getStatus(). For example:

$nc = new NissanConnect('YourUsername', 'YourPassword');
$status = $nc->getStatus();
$loc = $nc->getLocation();

var_dump($status, $loc);

from nissan-connect-php.

gboudreau avatar gboudreau commented on June 12, 2024

@Raiden38 This is not available to everyone.
If you have this feature in the Nissan official app, then the code posted by carestad should work.

from nissan-connect-php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.