NissanConnect EV third party app; part 1

July 2018 ยท 2 minute read

I am embarking on a new quest; building a simple, great looking, and fast third party Android app competing with the official NissanConnect EV app. It is used for the Nissan Leaf exclusively at the moment. I will be writing it using Dart and Flutter. The first part is to write a wrapper Dart library for the Carwings API. This API is what the official Nissan EV app is using. The Carwings API is essentially a collection PHP scripts that you call with your Nissan EV credentials. Some of these calls are asynchronous and require polling to receive the result when it is ready.

Through the Carwings API you can ask your vehicle for the latest data, see current battery and charging statuses, see the current climate control state, start or stop climate control remotely, remotely start charging, and retrieve the last known location of the vehicle.

For implementation details I have used a project written in Go, another Python project by Jason Horne, as reference and Josh Perry’s protocol reference as well;

Without these a lot more work would be needed.

The first problem on this endeavour is the initial authentication to the Carwings API. The authentication consists of a username and a Blowfish encrypted pkcs5 padded password. Dart has no native support for Blowfish encryption. Therefore the initial key and password are sent to my own server and the Blowfish encrypted password is generated there. Using mcrypt for PHP. From a security standpoint this is obviously the wrong way. I haven’t found a better solution yet sadly. The final implementation does not do this anymore. The encryption is now done natively using the Blowfish implementation in the Android SDK and iOS SDK.

The Dart library I have written is called dartcarwings and it is mostly done. The next step is the app written using Flutter.

Here are some examples of using the dartcarwings library;

CarwingsSession session = new CarwingsSession(debug: true);

  session
    .login(
       username: "username",
       password: "password",
       blowfishEncryptCallback: (String key, String password) async {
         // No native support for Blowfish encryption with Dart
         // Use external service
       })
    .then((vehicle) {
        vehicle.requestBatteryStatus().then((battery) {
            print(battery.batteryPercentage);
            print(battery.cruisingRangeAcOffKm);
            print(battery.cruisingRangeAcOnKm);
    });
  });

Take a peek at the dartcarwings library source code at; https://gitlab.com/tobiaswkjeldsen/dartcarwings

Part 2 will be about implementing the Android app using Dart and Flutter.