Permalink
Browse files

Wi fi (#10)

HUD
  • Loading branch information...
Trevelopment committed Dec 13, 2018
1 parent 01bc86e commit 0e5fdf1533326315786902b7ad3f36b750d1275a
Showing with 11,436 additions and 8,924 deletions.
  1. +4 −1 .gitignore
  2. +31 −31 common/command_server.cpp
  3. +55 −1 hu/hu.proto
  4. +109 −17 hu/hu_aap.cpp
  5. +21 −2 hu/hu_aap.h
  6. +4 −2 mazda/Makefile
  7. +66 −7 mazda/callbacks.cpp
  8. +6 −0 mazda/callbacks.h
  9. +10,675 −8,800 mazda/dbus/cmu_interfaces.xml
  10. +3 −1 mazda/gps/mzd_gps.cpp
  11. BIN mazda/hud-test
  12. +69 −0 mazda/hud-test.cpp
  13. +167 −0 mazda/hud/hud.cpp
  14. +98 −0 mazda/hud/hud.h
  15. BIN mazda/hud/icons/0001.jpg
  16. BIN mazda/hud/icons/0002.jpg
  17. BIN mazda/hud/icons/0003.jpg
  18. BIN mazda/hud/icons/0004.jpg
  19. BIN mazda/hud/icons/0005.jpg
  20. BIN mazda/hud/icons/0006.jpg
  21. BIN mazda/hud/icons/0007.jpg
  22. BIN mazda/hud/icons/0008.jpg
  23. BIN mazda/hud/icons/0009.jpg
  24. BIN mazda/hud/icons/0010.jpg
  25. BIN mazda/hud/icons/0011.jpg
  26. BIN mazda/hud/icons/0012.jpg
  27. BIN mazda/hud/icons/0013.jpg
  28. BIN mazda/hud/icons/0014.jpg
  29. BIN mazda/hud/icons/0015.jpg
  30. BIN mazda/hud/icons/0016.jpg
  31. BIN mazda/hud/icons/0017.jpg
  32. BIN mazda/hud/icons/0018.jpg
  33. BIN mazda/hud/icons/0019.jpg
  34. BIN mazda/hud/icons/0020.jpg
  35. BIN mazda/hud/icons/0021.jpg
  36. BIN mazda/hud/icons/0022.jpg
  37. BIN mazda/hud/icons/0023.jpg
  38. BIN mazda/hud/icons/0024.jpg
  39. BIN mazda/hud/icons/0025.jpg
  40. BIN mazda/hud/icons/0026.jpg
  41. BIN mazda/hud/icons/0027.jpg
  42. BIN mazda/hud/icons/0028.jpg
  43. BIN mazda/hud/icons/0029.jpg
  44. BIN mazda/hud/icons/0030.jpg
  45. BIN mazda/hud/icons/0031.jpg
  46. BIN mazda/hud/icons/0032.jpg
  47. BIN mazda/hud/icons/0033.jpg
  48. BIN mazda/hud/icons/0034.jpg
  49. BIN mazda/hud/icons/0035.jpg
  50. BIN mazda/hud/icons/0036.jpg
  51. BIN mazda/hud/icons/0037.jpg
  52. BIN mazda/hud/icons/0038.jpg
  53. BIN mazda/hud/icons/0039.jpg
  54. BIN mazda/hud/icons/0040.jpg
  55. BIN mazda/hud/icons/0041.jpg
  56. BIN mazda/hud/icons/0042.jpg
  57. BIN mazda/hud/icons/0043.jpg
  58. BIN mazda/hud/icons/0044.jpg
  59. BIN mazda/hud/icons/0045.jpg
  60. BIN mazda/hud/icons/0046.jpg
  61. BIN mazda/hud/icons/0047.jpg
  62. BIN mazda/hud/icons/0048.jpg
  63. BIN mazda/hud/icons/0049.jpg
  64. BIN mazda/hud/icons/0050.jpg
  65. BIN mazda/hud/icons/0051.jpg
  66. BIN mazda/hud/icons/0052.jpg
  67. BIN mazda/hud/icons/0053.jpg
  68. BIN mazda/hud/icons/0054.jpg
  69. BIN mazda/hud/icons/0055.jpg
  70. BIN mazda/hud/icons/0056.jpg
  71. BIN mazda/hud/icons/0057.jpg
  72. BIN mazda/hud/icons/0058.jpg
  73. BIN mazda/hud/icons/0059.jpg
  74. BIN mazda/hud/icons/0060.jpg
  75. +4 −1 mazda/installer/config/androidauto/data_persist/dev/bin/check-usb.sh
  76. +57 −29 mazda/installer/config/androidauto/data_persist/dev/bin/headunit-wrapper
  77. +2 −2 mazda/installer/tweaks.sh
  78. BIN mazda/libunwind-1.2-rc1/lib/libunwind-generic.a
  79. BIN mazda/libunwind-1.2-rc1/lib/libunwind-generic.a
  80. +11 −4 mazda/main.cpp
  81. +3 −0 mazda/nm/mzd_nightmode.cpp
  82. +19 −25 mazda/outputs.cpp
  83. +14 −0 ubuntu/callbacks.cpp
  84. +4 −0 ubuntu/callbacks.h
  85. +14 −0 ubuntu/outputs.cpp
  86. +0 −1 ubuntu/version.h
@@ -8,4 +8,7 @@ CMakeLists.txt
cmake-build-debug/
mazda/installer/config/androidauto/data_persist/dev/bin/headunit
*.creator.user
bin/
bin/
*/version\.h

ubuntu/version\.h
@@ -7,59 +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;
}
result["headunitVersion"] = callbacks.GetVersion();
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;
resp.body << std::setw(4) << result;

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

AddCORSHeaders(resp);
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.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 /updateConfig 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);
});
}

@@ -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;
@@ -694,3 +699,52 @@ message BluetoothAuthData
{
optional string data = 1;
}

message NAVMessagesStatus
{
optional int32 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
}
@@ -34,7 +34,6 @@

}


int HUServer::ihu_tra_start (HU_TRANSPORT_TYPE transportType, bool waitForDevice) {
if (transportType == HU_TRANSPORT_TYPE::WIFI) {
logd ("AA over Wifi");
@@ -117,7 +116,7 @@

int log_packet_info = 1;

int HUServer::hu_aap_tra_send (int retry, byte * buf, int len, int tmo) { // Send Transport data: chan,flags,len,type,...
int HUServer::hu_aap_tra_send (int retry, byte * buf, int len, int tmo) { // Send Transport data: chan,flags,len,type,...
// Need to send when starting
if (iaap_state != hu_STATE_STARTED && iaap_state != hu_STATE_STARTIN) {
loge ("CHECK: iaap_state: %d (%s)", iaap_state, state_get (iaap_state));
@@ -421,27 +420,33 @@
tsConfig->set_height(480);

//No idea what these mean since they aren't the same as HU_INPUT_BUTTON
inner->add_keycodes_supported(HUIB_MENU); // 0x01 Open menu
inner->add_keycodes_supported(HUIB_MIC1); // 0x02 Mic
inner->add_keycodes_supported(HUIB_HOME); // 0x03 AA home
inner->add_keycodes_supported(HUIB_MENU); // 0x01 Soft Left (Menu)
inner->add_keycodes_supported(HUIB_MIC1); // 0x02 Soft Right (Mic)
inner->add_keycodes_supported(HUIB_HOME); // 0x03 Home
inner->add_keycodes_supported(HUIB_BACK); // 0x04 Back
inner->add_keycodes_supported(HUIB_PHONE); // 0x05 Phone screen
inner->add_keycodes_supported(HUIB_CALLEND); // 0x06 End call
//inner->add_keycodes_supported(HUIB_NAV); // 0x07 Nav (This one is not correct)
inner->add_keycodes_supported(HUIB_PHONE); // 0x05 Call
inner->add_keycodes_supported(HUIB_CALLEND); // 0x06 End Call
inner->add_keycodes_supported(HUIB_UP); // 0x13 Up
inner->add_keycodes_supported(HUIB_DOWN); // 0x14 Down
inner->add_keycodes_supported(HUIB_LEFT); // 0x15 Left/Menu
inner->add_keycodes_supported(HUIB_RIGHT); // 0x16 Right/Mic
inner->add_keycodes_supported(HUIB_LEFT); // 0x15 Left (Menu)
inner->add_keycodes_supported(HUIB_RIGHT); // 0x16 Right (Mic)
inner->add_keycodes_supported(HUIB_ENTER); // 0x17 Select
inner->add_keycodes_supported(HUIB_MIC); // 0x54 Mic again
inner->add_keycodes_supported(HUIB_MIC); // 0x54 Search (Mic)
inner->add_keycodes_supported(HUIB_PLAYPAUSE); // 0x55 Play/Pause
inner->add_keycodes_supported(HUIB_NEXT); // 0x57 Next track
inner->add_keycodes_supported(HUIB_NEXT); // 0x57 Next Track
inner->add_keycodes_supported(HUIB_PREV); // 0x58 Prev Track
inner->add_keycodes_supported(HUIB_MUSIC); // 0xD1 Music Screen
inner->add_keycodes_supported(HUIB_SCROLLWHEEL);
// Might as well include these even if we dont use them
inner->add_keycodes_supported(HUIB_START); // 0x7E (126) Start media
inner->add_keycodes_supported(HUIB_STOP); // 0x7F (127) Stop media
inner->add_keycodes_supported(HUIB_SCROLLWHEEL); // 65536 Comand Knob Rotate
inner->add_keycodes_supported(HUIB_TEL); // 65537 Phone
inner->add_keycodes_supported(HUIB_NAVIGATION); // 65538 Navigation
inner->add_keycodes_supported(HUIB_MEDIA); // 65539 Media
// Might as well include these even if we dont use them
inner->add_keycodes_supported(HUIB_RADIO); // 65540 Radio (Doesn't Do Anything)
inner->add_keycodes_supported(HUIB_PRIMARY_BUTTON); // 65541 Primary (Doesn't Do Anything)
inner->add_keycodes_supported(HUIB_SECONDARY_BUTTON); // 65542 Secondary (Doesn't Do Anything)
inner->add_keycodes_supported(HUIB_TERTIARY_BUTTON); // 65543 Tertiary (Doesn't Do Anything)
inner->add_keycodes_supported(HUIB_START); // 0x7E (126) Start Media
inner->add_keycodes_supported(HUIB_STOP); // 0x7F (127) Stop Media

callbacks.CustomizeInputConfig(*inner);

@@ -541,6 +546,21 @@
}
*/

HU::ChannelDescriptor* navigationChannel = carInfo.add_channels();
navigationChannel->set_channel_id(AA_CH_NAVI);
{
auto inner = navigationChannel->mutable_navigation_status_service();

inner->set_minimum_interval_ms(1000);
//auto ImageOptions = inner->mutable_image_options();
//ImageOptions->set_width(100);
//ImageOptions->set_height(100);
//ImageOptions->set_colour_depth_bits(8);
inner->set_type(HU::ChannelDescriptor::NavigationStatusService::IMAGE_CODES_ONLY);
}



std::string carBTAddress = callbacks.GetCarBluetoothAddress();
if (carBTAddress.size() > 0)
{
@@ -918,6 +938,54 @@
return 0;
}

int HUServer::hu_handle_NaviStatus(int chan, byte * buf, int len) {
HU::NAVMessagesStatus request;
if (!request.ParseFromArray(buf, len))
{
logv ("NaviStatus Request");
logv(request.DebugString().c_str());
return -1;
}
else
{
logv ("NaviStatus Request");
}
callbacks.HandleNaviStatus(*this, request);
return 0;
}

int HUServer::hu_handle_NaviTurn(int chan, byte * buf, int len) {
HU::NAVTurnMessage request;
if (!request.ParseFromArray(buf, len))
{
logv ("NaviTurn Request");
logv(request.DebugString().c_str());
return -1;
}
else
{
logv ("NaviTurn Request");
}
callbacks.HandleNaviTurn(*this, request);
return 0;
}

int HUServer::hu_handle_NaviTurnDistance(int chan, byte * buf, int len) {
HU::NAVDistanceMessage request;
if (!request.ParseFromArray(buf, len))
{
logv ("NaviTurnDistance Request");
logv(request.DebugString().c_str());
return -1;
}
else
{
logv ("NaviTurnDistance Request");
}
callbacks.HandleNaviTurnDistance(*this, request);
return 0;
}

int HUServer::iaap_msg_process (int chan, uint16_t msg_type, byte * buf, int len) {

if (ena_log_verbo)
@@ -1054,11 +1122,35 @@
return hu_handle_MicRequest(chan, buf, len);
case HU_MEDIA_CHANNEL_MESSAGE::VideoFocusRequest:
return hu_handle_VideoFocusRequest(chan, buf, len);
default:
default:
loge ("Unknown msg_type: %d", msg_type);
return (0);
}
}
else if (chan == AA_CH_NAVI)
{
logv ("AA_CH_NAVI");
logv ("AA_CH_NAVI msg_type: %04x len: %d buf: %p", msg_type, len, buf);
hex_dump("AA_CH_NAVI", 80, buf, len);
switch((HU_NAVI_CHANNEL_MESSAGE)msg_type)
{
case HU_NAVI_CHANNEL_MESSAGE::Status:
logv ("AA_CH_NAVI: HU_NAVI_CHANNEL_MESSAGE::Status");
hu_handle_NaviStatus(chan, buf, len);
return (0);
case HU_NAVI_CHANNEL_MESSAGE::Turn:
logv ("AA_CH_NAVI: HU_NAVI_CHANNEL_MESSAGE::Turn");
hu_handle_NaviTurn(chan, buf, len);
return (0);
case HU_NAVI_CHANNEL_MESSAGE::TurnDistance:
logv ("AA_CH_NAVI: HU_NAVI_CHANNEL_MESSAGE::TurnDistance");
hu_handle_NaviTurnDistance(chan, buf, len);
return (0);
default:
loge ("Unknown msg_type: %d", msg_type);
return (0);
}
}
}

loge ("Unknown chan: %d", chan);
Oops, something went wrong.

0 comments on commit 0e5fdf1

Please sign in to comment.