ENEN DEDE
home
Station available

OVMS Mail

Sorry when I wrote this once or twice before, but I just don't like to be digitally tracked by any "man in the middle" system. This was one of my main motivations for my interest in OVMS. With OVMS I can connect my car with my server and control all with my app. And everything is open source.

Now is the recent OVMS App mainly maintained by the extraordinary good work of "Dexter". Dexter made a "gcm" (Google Cloud Messaging) branch of the master code on Github  (github.com/openvehicles/Open-Vehicle-Android/tree/gcm). At the moment we don't see any development on the master branch. All the new features of the app, i.e. the nice Nissan Leaf images, are only found at the gcm branch. So if you want to use the latest OVMS app, you probably will use Dexters app, based on the gcm branch.

For me this means two problems.

  1. I can't run the app on my mobile phone, because I use "Cyanogenmod" without "Google Services" on my phone. Google services essentially make a permanent connection from your mobile phone to Google. Within this connection any data can be transferred between google and your phone. This data is mostly personalized by an unique id. A lot of programmers use Google services to quickly develop apps using Google maps. This makes programming easy, but also means that Google always is informed by the app about my location in combination with my unique id.

    If you use Cyanogenmod without Google Services on your phone you then won't be able to use these features of such an app. That is the reason why for me the GPS part of the OVMS app does not work. No problem as I don't use the OVMS GPS feature. I'm more interested in other OVMS features like remote climate control or the state of charge level of the battery.

    But, as I said, the standard OVMS app out of the gcm branch won't even start if you don't have Google services installed on your phone. This is because of two lines of code within the MainActivity.java:

     // check for Google Play Services App:
    if (!checkPlayServices())
    finish();
    
    So to make the app work for me at all I need to comment out these lines and compile the app. My compiled version can be downloaded here.

    Before you can install the apk on a Cyanogenmod without Google services you will also need a workaround on the Google maps framework. This is described here: sdgsystems.com/blog/installing-google-maps-framework-aosp-android
     
  2. OVMS can sent me notifications. For example "Charging interrupted" or "Alarm on". A very nice feature. Dexter alterd the master code for his gcm branch to use "Google Cloud Messaging" (gcm) as a message push service for these messages. This has the advantage, that messages are tranferred in real time. But for me it has the disadvantage, that Google services are needed and Google is "man in the middle" and tracks my communication thru the app.

    I prefer messaging by mail. This is not real time (it takes up to 10 minutes to receive a message), but it has the advantage that it runs completely over my own servers. But this also means that the use of an own OVMS server is essential to make this work. If you operate one, you can switch from Google cloud messaging to mail notification.

    Lets take a look on how to do that ...

    In the "ovms_server.pl" (this is the OVMS Server) we find this code:

    # send mail notifications:
    if ($row->{'pushtype'} eq 'mail' && $mail_enabled eq 1)
    This means that mail can be sent by the server when the field "pushtype" in the databaser is filled with "mail" and the server configuration file says "mail_enabled=1".

    The field "pushtype" can be found within the MySQL database in the table "ovms_notifies". As soon as a new vehicle is announced to server this field is automaticly filled with "gcm". This is because in the gcm branch within the MainActivity.java we find this code:

    // subscribe at OVMS server:
    // MP-0
    // p<appid>,<pushtype>,<pushkeytype>{,<vehicleid>,<netpass>,<pushkeyvalue>}
    String cmd = String.format("MP-0 p%s,gcm,production,%s,%s,%s",
    		uuid, carData.sel_vehicleid, carData.sel_server_password,
    		gcmToken);
    "gcm" is hard coded within "String.format". Therefor we can only change the field "pushtype" from "gcm" to "mail" directly within the MySQL database. But when we do so it is permanent, as the code above only is processed at the first occourance of a new car for the database.

    This is the first step. Edit the value of the field "pushtype" in the table "ovms_notifies" of the MySQL database from "gcm" to "mail". And for the system to know where to sent the mails to we also need to enter the receipient email address in the field "pushkeyvalue" of the "ovms_notifies" table.

    At Github you can find a script that can do this for you: github.com/openvehicles/Open-Vehicle-Monitoring-System/blob/master/client/README#L87

    Now we only need to activate the mail function of the OVMS server in its config file "ovms_server.conf":


    [mail]
    enabled=1
    interval=10
    
    sender=ovms@mydomain.com
    Restart the  OVMS server service and, tada, we get notification mails :-)

    An example of such a mail is this:

    "Vehicle is stopped turned on"

    You will receive this message, when you leave the vehicle running (on "P" of course) while moving away from the vehicle with the key in your pocket. Nice for testing ...
     

Perhaps we will have some time in the future the possibility to check within the app wether we want to use Google cloud messaging oder would rather like to use mail messaging. Perhaps we will be able to use the app completely without Google services too ...

Till then we can use this workaround.