Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge back everything #3

Open
wants to merge 51 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
71bd0bd
Fixed Bluetooth Call Bug!!
Trevelopment Sep 2, 2017
9eca5d1
Merge branch 'master' into 'master'
Trevelopment Sep 2, 2017
549a9d0
v1.06 build
Trevelopment Nov 17, 2017
04bcd0e
v1.06b
Trevelopment Nov 17, 2017
960426e
I'VE DONE IT!!
Trevelopment Nov 18, 2017
b4794a0
Merge branch 'gartnera' into Use_unused_MLENT_stream
Trevelopment Nov 19, 2017
93151b9
Use the unused MLENT stream for AA
Trevelopment Nov 19, 2017
a1e67e2
Merge remote-tracking branch 'origin/releases' into Use_unused_MLENT_…
Trevelopment Nov 19, 2017
d922d2b
v1.07
Trevelopment Nov 19, 2017
7fcc826
Merge branch 'Use_unused_MLENT_stream'
Trevelopment Nov 19, 2017
522e994
Merge branch 'releases' into gps_fix
Trevelopment Nov 25, 2017
18a5f93
Merge branch 'gps_fix' into releases
Trevelopment Nov 25, 2017
d7f981b
Modified GPS Routines to make it stable from a /dev/ttyxxx to a dbus
Trevelopment Nov 27, 2017
c849b72
Merge
Trevelopment Nov 30, 2017
47b7a3b
Merge branch 'releases' into 1.07-release
Trevelopment Dec 2, 2017
7b4856d
1.07-release
Trevelopment Dec 2, 2017
ee97363
Merge remote-tracking branch 'gartnera/master' into releases
Trevelopment Dec 11, 2017
8a2fc01
Merge branch 'master' into releases
Trevelopment Dec 11, 2017
cc28447
Update AndroidAutoTmplt.js
Trevelopment Dec 11, 2017
13e6ec7
Merge branch 'master' into 'master'
Trevelopment Dec 11, 2017
476ee64
Wi fi (#9)
Trevelopment Aug 4, 2018
041787a
🗞
0xe25 Aug 11, 2018
697449c
🗞
0xe25 Aug 11, 2018
8d4f813
🗞
0xe25 Aug 11, 2018
2516b91
🗞
0xe25 Aug 11, 2018
80cf47b
🗞
0xe25 Aug 11, 2018
c12d34a
Merge branch 'p1' of gitlab.com-khantaena:mzdonline/headunit into p1
0xe25 Aug 11, 2018
b619ab7
🗞
0xe25 Aug 11, 2018
a5b22ae
check-usb.sh for detect android phone
0xe25 Aug 13, 2018
598f8d1
Merge branch 'MZD_Online/p1'
Trevelopment Sep 21, 2018
01bc86e
MUSIC and FAV button functions reversed (#8)
VitaliyKurokhtin Dec 8, 2018
0e5fdf1
Wi fi (#10)
Trevelopment Dec 13, 2018
d8333ef
Button fix
Trevelopment Dec 14, 2018
831d74f
More Button Fixes
Trevelopment Dec 22, 2018
8283515
Fix black screen issues when reopening/out of reverse
Trevelopment Jan 14, 2019
61ee618
Merge pull request #134 from Trevelopment/master
Trevelopment Jan 14, 2019
d46c7eb
#138: Detect the phone IP address and write it to the config file, wh…
Jun 17, 2019
e35d3d6
Correct the default IP address.
Jun 17, 2019
d220224
Roundabout formula fixed
VitaliyKurokhtin Aug 6, 2019
d62b015
Long press to release audio/video focus
VitaliyKurokhtin Aug 10, 2019
5161c53
Merge pull request #156 from VitaliyKurokhtin/roundabout
Trevelopment Aug 10, 2019
49d4c67
Merge pull request #157 from VitaliyKurokhtin/vvk/focus
Trevelopment Aug 10, 2019
af446a0
Merge pull request #153 from johnnyleitrim/master
Trevelopment Aug 19, 2019
08d1dea
Wrapper Tweaks
Trevelopment Aug 22, 2019
4a869a5
Working Wifi for Android 9 (Pie)
Trevelopment Aug 26, 2019
3a6b453
Hud units (#162)
VitaliyKurokhtin Oct 1, 2019
3890967
Possible solution for left-hand roundabouts (#168)
VitaliyKurokhtin Oct 25, 2019
9e370fc
Change set_head_unit_name to mazda to get mazda icon for exit button …
morpheus133 Feb 20, 2020
0f916da
Support for interleaved channel data (#174)
VitaliyKurokhtin Feb 20, 2020
54b38d6
Another merge case, getting turn event 3 with direction 3 for lane me…
VitaliyKurokhtin Feb 20, 2020
1cfb398
fix hud display will be clear sometimes. (#185)
leonunix May 15, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ CMakeLists.txt
cmake-build-debug/
mazda/installer/config/androidauto/data_persist/dev/bin/headunit
*.creator.user
bin/
*/version\.h
.vscode
60 changes: 38 additions & 22 deletions common/command_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,59 @@ using json = nlohmann::json;

namespace
{
void AddCORSHeaders(WPP::Response& resp)
{
resp.headers.emplace("Access-Control-Allow-Origin", "*");
resp.headers.emplace("Access-Control-Allow-Methods", "POST, GET");
}
void AddCORSHeaders(WPP::Response& resp)
{
resp.headers.emplace("Access-Control-Allow-Origin", "*");
resp.headers.emplace("Access-Control-Allow-Methods", "POST, GET");
}
}

CommandServer::CommandServer(ICommandServerCallbacks &callbacks)
{
server.get("/status", [&callbacks](WPP::Request& req, WPP::Response& resp)
{
resp.type = "application/json";
json result;
result["connected"] = callbacks.IsConnected();
result["videoFocus"] = callbacks.HasVideoFocus();
result["audioFocus"] = callbacks.HasAudioFocus();
std::string logPath = callbacks.GetLogPath();
if (logPath.length() > 0)
result["logPath"] = logPath;
resp.type = "application/json";
json result;
result["connected"] = callbacks.IsConnected();
result["videoFocus"] = callbacks.HasVideoFocus();
result["audioFocus"] = callbacks.HasAudioFocus();
std::string logPath = callbacks.GetLogPath();
if (logPath.length() > 0)
{
result["logPath"] = logPath;
}
result["headunitVersion"] = callbacks.GetVersion();

resp.body << std::setw(4) << result;

logd("Got /status call. response:\n%s\n", resp.body.str().c_str());

AddCORSHeaders(resp);
});

server.get("/updateConfig", [&callbacks](WPP::Request& req, WPP::Response& resp)
{
resp.type = "application/json";
json result;
result["result"] = callbacks.ChangeParameterConfig(req.query["parameter"], req.query["value"], req.query["type"]);

resp.body << std::setw(4) << result;
resp.body << std::setw(4) << result;

logd("Got /status call. response:\n%s\n", resp.body.str().c_str());
logd("Got /updateConfig call. response:\n%s\n", resp.body.str().c_str());

AddCORSHeaders(resp);
AddCORSHeaders(resp);
});

server.post("/takeVideoFocus", [&callbacks](WPP::Request& req, WPP::Response& resp)
{
resp.type = "application/json";
callbacks.TakeVideoFocus();
json result;
resp.body << std::setw(4) << result;
resp.type = "application/json";
callbacks.TakeVideoFocus();
json result;
resp.body << std::setw(4) << result;

printf("Got /takeVideoFocus call. response:\n%s\n", resp.body.str().c_str());
printf("Got /takeVideoFocus call. response:\n%s\n", resp.body.str().c_str());

AddCORSHeaders(resp);
AddCORSHeaders(resp);
});
}

Expand Down
2 changes: 2 additions & 0 deletions common/command_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class ICommandServerCallbacks
virtual bool HasVideoFocus() const = 0;
virtual void TakeVideoFocus() = 0;
virtual std::string GetLogPath() const = 0;
virtual std::string GetVersion() const = 0;
virtual std::string ChangeParameterConfig(std::string param, std::string value, std::string type) const = 0;
};

//This is mostly designed as a way to recieve UI events from the CMU JS code via HTTP requests
Expand Down
106 changes: 106 additions & 0 deletions common/config.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#include <fstream>
#include "hu_aap.h"
#include "config.h"

//default settings
std::string config::configFile = "/tmp/root/headunit.json";
bool config::launchOnDevice = true;
bool config::carGPS = true;
HU_TRANSPORT_TYPE config::transport_type = HU_TRANSPORT_TYPE::USB;
std::string config::phoneIpAddress = "192.168.43.1";
bool config::reverseGPS = false;

void config::parseJson(json config_json)
{
if (config_json["launchOnDevice"].is_boolean())
{
config::launchOnDevice = config_json["launchOnDevice"];
}
if (config_json["carGPS"].is_boolean())
{
config::carGPS = config_json["carGPS"];
}
if (config_json["wifiTransport"].is_boolean())
{
config::transport_type = config_json["wifiTransport"] ? HU_TRANSPORT_TYPE::WIFI : HU_TRANSPORT_TYPE::USB;
}
if (config_json["phoneIpAddress"].is_string())
{
config::phoneIpAddress = config_json["phoneIpAddress"];
}
if (config_json["reverseGPS"].is_boolean())
{
config::reverseGPS = config_json["reverseGPS"];
}
printf("json config parsed\n");
}

json config::readConfigFile()
{
std::ifstream ifs(config::configFile);
json config_json;
//config file exists, read it
if (ifs.good())
{
try
{
ifs >> config_json;
}catch (...)
{
printf("couldn't parse config file. possible corruption\n");
config_json = nullptr;
ifs.close();
}
ifs.close();
}
else
{
printf("couldn't read config file. check permissions\n");
}
return config_json;
}

void config::readConfig()
{
json config_json = readConfigFile();
if (config_json == nullptr) return;

config::parseJson(config_json);
}

void config::writeConfigFile(json config_json)
{
std::ofstream out_file(config::configFile);
if (out_file.good())
{
out_file << std::setw(4) << config_json << std::endl;
out_file.close();
printf("config file written\n");
}
else
{
printf("couldn't write config file. check permissions\n");
}
}

void config::updateConfigString(std::string parameter, std::string value)
{
printf("updating parameter [%s] = [%s]\n", parameter.c_str(), value.c_str());
json config_json = readConfigFile();
if (config_json == nullptr) return;

config_json[parameter]=value;
writeConfigFile(config_json);
config::parseJson(config_json);
}

void config::updateConfigBool(std::string parameter, bool value)
{
printf("updating parameter [%s] = [%s]\n", parameter.c_str(), value ? "true" : "false");
json config_json = readConfigFile();
if (config_json == nullptr) return;

config_json[parameter]=value;
writeConfigFile(config_json);
config::parseJson(config_json);
}
25 changes: 25 additions & 0 deletions common/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#pragma once

#include "json/json.hpp"
using json = nlohmann::json;

class config {
public:

static void readConfig();
static void updateConfigString(std::string parameter, std::string value);
static void updateConfigBool(std::string parameter, bool value);

static std::string configFile;
static bool launchOnDevice;
static bool carGPS;
static HU_TRANSPORT_TYPE transport_type;
static std::string phoneIpAddress;
static bool reverseGPS;

private:
static json readConfigFile();
static void writeConfigFile(json config_json);
static void parseJson(json config_json);
};

75 changes: 72 additions & 3 deletions hu/hu.proto
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,12 @@ message ChannelDescriptor
}

required uint32 minimum_interval_ms = 1;
required uint32 type = 2;
enum CLUSTER_TYPE
{
CUSTOM_IMAGES_SUPPORTED = 1;
IMAGE_CODES_ONLY = 2;
}
required CLUSTER_TYPE type = 2;
optional ImageOptions image_options = 3;
}
optional NavigationStatusService navigation_status_service = 8;
Expand All @@ -417,10 +422,9 @@ message ChannelDescriptor

optional VendorExtensionService vendor_extension_service = 12;

//vendor extension==12
//genericnotification==13
message GenericNotificationService
{
optional string name = 1;
}
optional GenericNotificationService generic_notification_service = 13;
}
Expand Down Expand Up @@ -694,3 +698,68 @@ message BluetoothAuthData
{
optional string data = 1;
}

message NAVMessagesStatus
{
enum STATUS
{
START = 1;
STOP = 2;
}
optional STATUS status = 1;
}

message NAVTurnMessage
{
optional string event_name = 1;
enum TURN_SIDE
{
TURN_LEFT = 1;
TURN_RIGHT = 2;
TURN_UNSPECIFIED = 3;
}
optional TURN_SIDE turn_side = 2;
enum TURN_EVENT
{
TURN_UNKNOWN = 0;
TURN_DEPART = 1;
TURN_NAME_CHANGE = 2;
TURN_SLIGHT_TURN = 3;
TURN_TURN = 4;
TURN_SHARP_TURN = 5;
TURN_U_TURN = 6;
TURN_ON_RAMP = 7;
TURN_OFF_RAMP = 8;
TURN_FORK = 9;
TURN_MERGE = 10;
TURN_ROUNDABOUT_ENTER = 11;
TURN_ROUNDABOUT_EXIT = 12;
TURN_ROUNDABOUT_ENTER_AND_EXIT = 13;
TURN_STRAIGHT = 14;
TURN_FERRY_BOAT = 16;
TURN_FERRY_TRAIN = 17;
TURN_DESTINATION = 19;
}
optional TURN_EVENT turn_event = 3;
optional bytes image = 4; // image in png format
optional int32 turn_number = 5;
optional int32 turn_angle = 6;
}

//32773 (0x8005)
message NAVDistanceMessage
{
optional int32 distance = 1; //meters
optional int32 time_until = 2; //seconds
optional uint64 display_distance = 3; //distance rounded for display
enum DISPLAY_DISTANCE_UNIT
{
METERS = 1; // meters * 1000, used when rounded distance < 1000m
KILOMETERS10 = 2; // kilometers * 1000, used when rounded distance > 10km, not same as just meters because "km" is displayed on screen
KILOMETERS = 3; // kilometers * 1000, used when rounded distance between 1km and 10km, not same as just meters because "km" is displayed on screen
MILES10 = 4; // miles * 1000, used when rounded distance > 10mi
MILES = 5; // miles * 1000, used when rounded distance between 1mi and 10mi
FEET = 6; // feet * 1000
}
optional DISPLAY_DISTANCE_UNIT display_distance_unit = 4;
}
Loading