mirror of https://github.com/opencardev/aasdk
add media and navigation status (#22)
* Implemented media status service, working on navigation service * Navigation Status Service supportpull/13/head
parent
d327d9059c
commit
1bc0fe69d5
|
@ -27,7 +27,7 @@ import "AVInputChannelData.proto";
|
||||||
import "BluetoothChannelData.proto";
|
import "BluetoothChannelData.proto";
|
||||||
import "NavigationChannelData.proto";
|
import "NavigationChannelData.proto";
|
||||||
import "VendorExtensionChannelData.proto";
|
import "VendorExtensionChannelData.proto";
|
||||||
import "MediaChannelData.proto";
|
import "MediaInfoChannelData.proto";
|
||||||
import "WifiChannelData.proto";
|
import "WifiChannelData.proto";
|
||||||
|
|
||||||
package aasdk.proto.data;
|
package aasdk.proto.data;
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* This file is part of aasdk library project.
|
||||||
|
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||||
|
*
|
||||||
|
* aasdk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
|
||||||
|
* aasdk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with aasdk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
syntax="proto2";
|
||||||
|
|
||||||
|
package aasdk.proto.enums;
|
||||||
|
|
||||||
|
message DistanceUnit
|
||||||
|
{
|
||||||
|
enum Enum
|
||||||
|
{
|
||||||
|
UNKNOWN = 0;
|
||||||
|
METERS = 1;
|
||||||
|
KILOMETERS = 2;
|
||||||
|
KILOMETERS_PARTIAL = 3;
|
||||||
|
MILES = 4;
|
||||||
|
MILES_PARTIAL = 5;
|
||||||
|
FEET = 6;
|
||||||
|
YARDS = 7;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* This file is part of aasdk library project.
|
||||||
|
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||||
|
*
|
||||||
|
* aasdk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
|
||||||
|
* aasdk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with aasdk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
syntax="proto2";
|
||||||
|
|
||||||
|
package aasdk.proto.enums;
|
||||||
|
|
||||||
|
message ManeuverDirection
|
||||||
|
{
|
||||||
|
enum Enum
|
||||||
|
{
|
||||||
|
UNKNOWN = 0;
|
||||||
|
LEFT = 1;
|
||||||
|
RIGHT = 2;
|
||||||
|
UNSPECIFIED = 3;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* This file is part of aasdk library project.
|
||||||
|
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||||
|
*
|
||||||
|
* aasdk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
|
||||||
|
* aasdk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with aasdk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
syntax="proto2";
|
||||||
|
|
||||||
|
package aasdk.proto.enums;
|
||||||
|
|
||||||
|
message ManeuverType
|
||||||
|
{
|
||||||
|
enum Enum
|
||||||
|
{
|
||||||
|
UNKNOWN = 0;
|
||||||
|
DEPART = 1;
|
||||||
|
NAME_CHANGE = 2;
|
||||||
|
SLIGHT_TURN = 3;
|
||||||
|
TURN = 4;
|
||||||
|
SHARP_TURN = 5;
|
||||||
|
U_TURN = 6;
|
||||||
|
ON_RAMP = 7;
|
||||||
|
OFF_RAMP = 8;
|
||||||
|
FORK = 9;
|
||||||
|
MERGE = 10;
|
||||||
|
ROUNDABOUT_ENTER = 11;
|
||||||
|
ROUNDABOUT_EXIT = 12;
|
||||||
|
ROUNDABOUT_ENTER_AND_EXIT = 13;
|
||||||
|
STRAIGHT = 14;
|
||||||
|
FERRY_BOAT = 16;
|
||||||
|
FERRY_TRAIN = 17;
|
||||||
|
DESTINATION = 19;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
/*
|
||||||
|
* This file is part of aasdk library project.
|
||||||
|
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||||
|
*
|
||||||
|
* aasdk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
|
||||||
|
* aasdk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with aasdk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
syntax="proto2";
|
||||||
|
|
||||||
|
package aasdk.proto.ids;
|
||||||
|
|
||||||
|
message MediaInfoChannelMessage
|
||||||
|
{
|
||||||
|
enum Enum
|
||||||
|
{
|
||||||
|
NONE = 0x0000;
|
||||||
|
PLAYBACK = 0x8001;
|
||||||
|
METADATA = 0x8003;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
/*
|
||||||
|
* This file is part of aasdk library project.
|
||||||
|
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||||
|
*
|
||||||
|
* aasdk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
|
||||||
|
* aasdk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with aasdk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
syntax="proto2";
|
||||||
|
|
||||||
|
package aasdk.proto.messages;
|
||||||
|
|
||||||
|
message MediaInfoChannelMetadataData
|
||||||
|
{
|
||||||
|
required string track_name = 1;
|
||||||
|
optional string artist_name = 2;
|
||||||
|
optional string album_name = 3;
|
||||||
|
optional bytes album_art = 4;
|
||||||
|
required int32 track_length = 6;
|
||||||
|
required int32 unknown1 = 7;
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* This file is part of aasdk library project.
|
||||||
|
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||||
|
*
|
||||||
|
* aasdk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
|
||||||
|
* aasdk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with aasdk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
syntax="proto2";
|
||||||
|
|
||||||
|
package aasdk.proto.messages;
|
||||||
|
|
||||||
|
message MediaInfoChannelPlaybackData
|
||||||
|
{
|
||||||
|
enum PlaybackState
|
||||||
|
{
|
||||||
|
NONE = 0x0000;
|
||||||
|
TRACK_CHANGE = 1;
|
||||||
|
PLAY = 2;
|
||||||
|
PAUSE = 3;
|
||||||
|
}
|
||||||
|
required PlaybackState playback_state = 1;
|
||||||
|
required string media_source = 2;
|
||||||
|
required int32 track_progress = 3;
|
||||||
|
required int32 unknown1 = 4;
|
||||||
|
required int32 unknown2 = 5;
|
||||||
|
required int32 unknown3 = 6;
|
||||||
|
|
||||||
|
}
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
syntax="proto2";
|
syntax="proto2";
|
||||||
|
|
||||||
|
import "NavigationTurnTypeEnum.proto";
|
||||||
import "NavigationImageOptionsData.proto";
|
import "NavigationImageOptionsData.proto";
|
||||||
|
|
||||||
package aasdk.proto.data;
|
package aasdk.proto.data;
|
||||||
|
@ -25,6 +26,6 @@ package aasdk.proto.data;
|
||||||
message NavigationChannel
|
message NavigationChannel
|
||||||
{
|
{
|
||||||
required uint32 minimum_interval_ms = 1;
|
required uint32 minimum_interval_ms = 1;
|
||||||
required uint32 type = 2;
|
required enums.NavigationTurnType.Enum type = 2;
|
||||||
required NavigationImageOptions image_options = 3;
|
required NavigationImageOptions image_options = 3;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* This file is part of aasdk library project.
|
||||||
|
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||||
|
*
|
||||||
|
* aasdk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
|
||||||
|
* aasdk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with aasdk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
syntax="proto2";
|
||||||
|
|
||||||
|
package aasdk.proto.ids;
|
||||||
|
|
||||||
|
message NavigationChannelMessage
|
||||||
|
{
|
||||||
|
enum Enum
|
||||||
|
{
|
||||||
|
NONE = 0x0000;
|
||||||
|
STATUS = 0x8003;
|
||||||
|
TURN_EVENT = 0x8004;
|
||||||
|
DISTANCE_EVENT = 0x8005;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* This file is part of aasdk library project.
|
||||||
|
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||||
|
*
|
||||||
|
* aasdk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
|
||||||
|
* aasdk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with aasdk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
syntax="proto2";
|
||||||
|
|
||||||
|
import "DistanceUnitEnum.proto";
|
||||||
|
|
||||||
|
package aasdk.proto.messages;
|
||||||
|
|
||||||
|
message NavigationDistanceEvent
|
||||||
|
{
|
||||||
|
required uint32 meters = 1;
|
||||||
|
required uint32 timeToStepSeconds = 2;
|
||||||
|
required uint32 distanceToStepMillis = 3;
|
||||||
|
required enums.DistanceUnit.Enum distanceUnit = 4;
|
||||||
|
|
||||||
|
}
|
|
@ -25,4 +25,5 @@ message NavigationImageOptions
|
||||||
required int32 width = 1;
|
required int32 width = 1;
|
||||||
required int32 height = 2;
|
required int32 height = 2;
|
||||||
required int32 colour_depth_bits = 3;
|
required int32 colour_depth_bits = 3;
|
||||||
|
required int32 dunno = 4;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* This file is part of aasdk library project.
|
||||||
|
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||||
|
*
|
||||||
|
* aasdk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
|
||||||
|
* aasdk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with aasdk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
syntax="proto2";
|
||||||
|
|
||||||
|
package aasdk.proto.messages;
|
||||||
|
|
||||||
|
message NavigationStatus
|
||||||
|
{
|
||||||
|
required Enum status = 1;
|
||||||
|
enum Enum
|
||||||
|
{
|
||||||
|
UNAVAILABLE = 0;
|
||||||
|
ACTIVE = 1;
|
||||||
|
INACTIVE = 2;
|
||||||
|
REROUTING = 3;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
* This file is part of aasdk library project.
|
||||||
|
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||||
|
*
|
||||||
|
* aasdk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
|
||||||
|
* aasdk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with aasdk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
syntax="proto2";
|
||||||
|
|
||||||
|
import "ManeuverTypeEnum.proto";
|
||||||
|
import "ManeuverDirectionEnum.proto";
|
||||||
|
|
||||||
|
package aasdk.proto.messages;
|
||||||
|
|
||||||
|
message NavigationTurnEvent
|
||||||
|
{
|
||||||
|
required string street_name = 1;
|
||||||
|
required enums.ManeuverDirection.Enum maneuverDirection = 2;
|
||||||
|
required enums.ManeuverType.Enum maneuverType = 3;
|
||||||
|
required bytes turnImage = 4;
|
||||||
|
required uint32 roundaboutExitNumber = 5;
|
||||||
|
required uint32 roundaboutExitAngle = 6;
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
/*
|
||||||
|
* This file is part of aasdk library project.
|
||||||
|
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||||
|
*
|
||||||
|
* aasdk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
|
||||||
|
* aasdk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with aasdk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
syntax="proto2";
|
||||||
|
|
||||||
|
package aasdk.proto.enums;
|
||||||
|
|
||||||
|
message NavigationTurnType
|
||||||
|
{
|
||||||
|
enum Enum
|
||||||
|
{
|
||||||
|
UNKNOWN = 0;
|
||||||
|
IMAGE = 1;
|
||||||
|
ENUM = 2;
|
||||||
|
}
|
||||||
|
}
|
|
@ -28,5 +28,9 @@ message VideoResolution
|
||||||
_480p = 1;
|
_480p = 1;
|
||||||
_720p = 2;
|
_720p = 2;
|
||||||
_1080p = 3;
|
_1080p = 3;
|
||||||
|
_1440p = 4;
|
||||||
|
_720p_p = 5;
|
||||||
|
_1080pp = 6;
|
||||||
|
_108s0p_p = 7;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
/*
|
||||||
|
* This file is part of aasdk library project.
|
||||||
|
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||||
|
*
|
||||||
|
* aasdk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
|
||||||
|
* aasdk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with aasdk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <aasdk_proto/ChannelOpenResponseMessage.pb.h>
|
||||||
|
#include <aasdk/Messenger/ChannelId.hpp>
|
||||||
|
#include <aasdk/Channel/Promise.hpp>
|
||||||
|
#include <aasdk/Channel/AV/IMediaStatusServiceChannelEventHandler.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
namespace aasdk
|
||||||
|
{
|
||||||
|
namespace channel
|
||||||
|
{
|
||||||
|
namespace av
|
||||||
|
{
|
||||||
|
|
||||||
|
class IMediaStatusServiceChannel
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef std::shared_ptr<IMediaStatusServiceChannel> Pointer;
|
||||||
|
|
||||||
|
IMediaStatusServiceChannel() = default;
|
||||||
|
virtual ~IMediaStatusServiceChannel() = default;
|
||||||
|
|
||||||
|
virtual void receive(IMediaStatusServiceChannelEventHandler::Pointer eventHandler) = 0;
|
||||||
|
virtual void sendChannelOpenResponse(const proto::messages::ChannelOpenResponse& response, SendPromise::Pointer promise) = 0;
|
||||||
|
virtual messenger::ChannelId getId() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
/*
|
||||||
|
* This file is part of aasdk library project.
|
||||||
|
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||||
|
*
|
||||||
|
* aasdk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
|
||||||
|
* aasdk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with aasdk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <aasdk_proto/ChannelOpenRequestMessage.pb.h>
|
||||||
|
#include <aasdk_proto/MediaInfoChannelMetadataData.pb.h>
|
||||||
|
#include <aasdk_proto/MediaInfoChannelPlaybackData.pb.h>
|
||||||
|
#include <aasdk/Error/Error.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
namespace aasdk
|
||||||
|
{
|
||||||
|
namespace channel
|
||||||
|
{
|
||||||
|
namespace av
|
||||||
|
{
|
||||||
|
|
||||||
|
class IMediaStatusServiceChannelEventHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef std::shared_ptr<IMediaStatusServiceChannelEventHandler> Pointer;
|
||||||
|
|
||||||
|
IMediaStatusServiceChannelEventHandler() = default;
|
||||||
|
virtual ~IMediaStatusServiceChannelEventHandler() = default;
|
||||||
|
|
||||||
|
virtual void onChannelOpenRequest(const proto::messages::ChannelOpenRequest& request) = 0;
|
||||||
|
virtual void onChannelError(const error::Error& e) = 0;
|
||||||
|
virtual void onMetadataUpdate(const proto::messages::MediaInfoChannelMetadataData& metadata) = 0;
|
||||||
|
virtual void onPlaybackUpdate(const proto::messages::MediaInfoChannelPlaybackData& playback) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* This file is part of aasdk library project.
|
||||||
|
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||||
|
*
|
||||||
|
* aasdk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
|
||||||
|
* aasdk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with aasdk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <aasdk/Channel/ServiceChannel.hpp>
|
||||||
|
#include <aasdk/Channel/AV/IMediaStatusServiceChannel.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
namespace aasdk
|
||||||
|
{
|
||||||
|
namespace channel
|
||||||
|
{
|
||||||
|
namespace av
|
||||||
|
{
|
||||||
|
|
||||||
|
class MediaStatusServiceChannel: public IMediaStatusServiceChannel, public ServiceChannel, public std::enable_shared_from_this<MediaStatusServiceChannel>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MediaStatusServiceChannel(boost::asio::io_service::strand& strand, messenger::IMessenger::Pointer messenger);
|
||||||
|
|
||||||
|
void receive(IMediaStatusServiceChannelEventHandler::Pointer eventHandler) override;
|
||||||
|
messenger::ChannelId getId() const override;
|
||||||
|
void sendChannelOpenResponse(const proto::messages::ChannelOpenResponse& response, SendPromise::Pointer promise) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
using std::enable_shared_from_this<MediaStatusServiceChannel>::shared_from_this;
|
||||||
|
void messageHandler(messenger::Message::Pointer message, IMediaStatusServiceChannelEventHandler::Pointer eventHandler);
|
||||||
|
void handleChannelOpenRequest(const common::DataConstBuffer& payload, IMediaStatusServiceChannelEventHandler::Pointer eventHandler);
|
||||||
|
void handleMetadataUpdate(const common::DataConstBuffer& payload, IMediaStatusServiceChannelEventHandler::Pointer eventHandler);
|
||||||
|
void handlePlaybackUpdate(const common::DataConstBuffer& payload, IMediaStatusServiceChannelEventHandler::Pointer eventHandler);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
/*
|
||||||
|
* This file is part of aasdk library project.
|
||||||
|
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||||
|
*
|
||||||
|
* aasdk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
|
||||||
|
* aasdk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with aasdk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <aasdk_proto/ChannelOpenResponseMessage.pb.h>
|
||||||
|
#include <aasdk/Messenger/ChannelId.hpp>
|
||||||
|
#include <aasdk/Channel/Promise.hpp>
|
||||||
|
#include <aasdk/Channel/Navigation/INavigationStatusServiceChannelEventHandler.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
namespace aasdk
|
||||||
|
{
|
||||||
|
namespace channel
|
||||||
|
{
|
||||||
|
namespace navigation
|
||||||
|
{
|
||||||
|
|
||||||
|
class INavigationStatusServiceChannel
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef std::shared_ptr<INavigationStatusServiceChannel> Pointer;
|
||||||
|
|
||||||
|
INavigationStatusServiceChannel() = default;
|
||||||
|
virtual ~INavigationStatusServiceChannel() = default;
|
||||||
|
|
||||||
|
virtual void receive(INavigationStatusServiceChannelEventHandler::Pointer eventHandler) = 0;
|
||||||
|
virtual void sendChannelOpenResponse(const proto::messages::ChannelOpenResponse& response, SendPromise::Pointer promise) = 0;
|
||||||
|
virtual messenger::ChannelId getId() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* This file is part of aasdk library project.
|
||||||
|
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||||
|
*
|
||||||
|
* aasdk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
|
||||||
|
* aasdk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with aasdk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <aasdk_proto/ChannelOpenRequestMessage.pb.h>
|
||||||
|
#include <aasdk_proto/NavigationDistanceEventMessage.pb.h>
|
||||||
|
#include <aasdk_proto/NavigationTurnEventMessage.pb.h>
|
||||||
|
#include <aasdk_proto/NavigationStatusMessage.pb.h>
|
||||||
|
#include <aasdk/Error/Error.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
namespace aasdk
|
||||||
|
{
|
||||||
|
namespace channel
|
||||||
|
{
|
||||||
|
namespace navigation
|
||||||
|
{
|
||||||
|
|
||||||
|
class INavigationStatusServiceChannelEventHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef std::shared_ptr<INavigationStatusServiceChannelEventHandler> Pointer;
|
||||||
|
|
||||||
|
INavigationStatusServiceChannelEventHandler() = default;
|
||||||
|
virtual ~INavigationStatusServiceChannelEventHandler() = default;
|
||||||
|
|
||||||
|
virtual void onChannelOpenRequest(const proto::messages::ChannelOpenRequest& request) = 0;
|
||||||
|
virtual void onChannelError(const error::Error& e) = 0;
|
||||||
|
virtual void onStatusUpdate(const proto::messages::NavigationStatus& navStatus) = 0;
|
||||||
|
virtual void onTurnEvent(const proto::messages::NavigationTurnEvent& turnEvent) = 0;
|
||||||
|
virtual void onDistanceEvent(const proto::messages::NavigationDistanceEvent& distanceEvent) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* This file is part of aasdk library project.
|
||||||
|
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||||
|
*
|
||||||
|
* aasdk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
|
||||||
|
* aasdk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with aasdk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <aasdk/Channel/ServiceChannel.hpp>
|
||||||
|
#include <aasdk/Channel/Navigation/INavigationStatusServiceChannel.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
namespace aasdk
|
||||||
|
{
|
||||||
|
namespace channel
|
||||||
|
{
|
||||||
|
namespace navigation
|
||||||
|
{
|
||||||
|
|
||||||
|
class NavigationStatusServiceChannel: public INavigationStatusServiceChannel, public ServiceChannel, public std::enable_shared_from_this<NavigationStatusServiceChannel>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NavigationStatusServiceChannel(boost::asio::io_service::strand& strand, messenger::IMessenger::Pointer messenger);
|
||||||
|
|
||||||
|
void receive(INavigationStatusServiceChannelEventHandler::Pointer eventHandler) override;
|
||||||
|
messenger::ChannelId getId() const override;
|
||||||
|
void sendChannelOpenResponse(const proto::messages::ChannelOpenResponse& response, SendPromise::Pointer promise) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
using std::enable_shared_from_this<NavigationStatusServiceChannel>::shared_from_this;
|
||||||
|
void messageHandler(messenger::Message::Pointer message, INavigationStatusServiceChannelEventHandler::Pointer eventHandler);
|
||||||
|
void handleChannelOpenRequest(const common::DataConstBuffer& payload, INavigationStatusServiceChannelEventHandler::Pointer eventHandler);
|
||||||
|
void handleStatusUpdate(const common::DataConstBuffer& payload, INavigationStatusServiceChannelEventHandler::Pointer eventHandler);
|
||||||
|
void handleTurnEvent(const common::DataConstBuffer& payload, INavigationStatusServiceChannelEventHandler::Pointer eventHandler);
|
||||||
|
void handleDistanceEvent(const common::DataConstBuffer& payload, INavigationStatusServiceChannelEventHandler::Pointer eventHandler);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -37,6 +37,8 @@ enum class ChannelId
|
||||||
SYSTEM_AUDIO,
|
SYSTEM_AUDIO,
|
||||||
AV_INPUT,
|
AV_INPUT,
|
||||||
BLUETOOTH,
|
BLUETOOTH,
|
||||||
|
NAVIGATION,
|
||||||
|
MEDIA_STATUS,
|
||||||
NONE = 255
|
NONE = 255
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,146 @@
|
||||||
|
/*
|
||||||
|
* This file is part of aasdk library project.
|
||||||
|
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||||
|
*
|
||||||
|
* aasdk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
|
||||||
|
* aasdk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with aasdk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <aasdk_proto/ControlMessageIdsEnum.pb.h>
|
||||||
|
#include <aasdk_proto/MediaInfoChannelMessageIdsEnum.pb.h>
|
||||||
|
#include <aasdk_proto/MediaInfoChannelMetadataData.pb.h>
|
||||||
|
#include <aasdk_proto/MediaInfoChannelPlaybackData.pb.h>
|
||||||
|
#include <aasdk_proto/BluetoothChannelMessageIdsEnum.pb.h>
|
||||||
|
#include <aasdk_proto/BluetoothPairingRequestMessage.pb.h>
|
||||||
|
#include <aasdk/Channel/AV/IMediaStatusServiceChannelEventHandler.hpp>
|
||||||
|
#include <aasdk/Channel/AV/MediaStatusServiceChannel.hpp>
|
||||||
|
#include <aasdk/Common/Log.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
namespace aasdk
|
||||||
|
{
|
||||||
|
namespace channel
|
||||||
|
{
|
||||||
|
namespace av
|
||||||
|
{
|
||||||
|
|
||||||
|
MediaStatusServiceChannel::MediaStatusServiceChannel(boost::asio::io_service::strand& strand, messenger::IMessenger::Pointer messenger)
|
||||||
|
: ServiceChannel(strand, std::move(messenger), messenger::ChannelId::MEDIA_STATUS)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void MediaStatusServiceChannel::receive(IMediaStatusServiceChannelEventHandler::Pointer eventHandler)
|
||||||
|
{
|
||||||
|
auto receivePromise = messenger::ReceivePromise::defer(strand_);
|
||||||
|
receivePromise->then(std::bind(&MediaStatusServiceChannel::messageHandler, this->shared_from_this(), std::placeholders::_1, eventHandler),
|
||||||
|
std::bind(&IMediaStatusServiceChannelEventHandler::onChannelError, eventHandler,std::placeholders::_1));
|
||||||
|
|
||||||
|
messenger_->enqueueReceive(channelId_, std::move(receivePromise));
|
||||||
|
}
|
||||||
|
|
||||||
|
messenger::ChannelId MediaStatusServiceChannel::getId() const
|
||||||
|
{
|
||||||
|
return channelId_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MediaStatusServiceChannel::sendChannelOpenResponse(const proto::messages::ChannelOpenResponse& response, SendPromise::Pointer promise)
|
||||||
|
{
|
||||||
|
AASDK_LOG(info) << "[MediaStatusServiceChannel] channel open response ";
|
||||||
|
auto message(std::make_shared<messenger::Message>(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::CONTROL));
|
||||||
|
message->insertPayload(messenger::MessageId(proto::ids::ControlMessage::CHANNEL_OPEN_RESPONSE).getData());
|
||||||
|
message->insertPayload(response);
|
||||||
|
|
||||||
|
this->send(std::move(message), std::move(promise));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MediaStatusServiceChannel::messageHandler(messenger::Message::Pointer message, IMediaStatusServiceChannelEventHandler::Pointer eventHandler)
|
||||||
|
{
|
||||||
|
messenger::MessageId messageId(message->getPayload());
|
||||||
|
common::DataConstBuffer payload(message->getPayload(), messageId.getSizeOf());
|
||||||
|
|
||||||
|
switch(messageId.getId())
|
||||||
|
{
|
||||||
|
case proto::ids::ControlMessage::CHANNEL_OPEN_REQUEST:
|
||||||
|
this->handleChannelOpenRequest(payload, std::move(eventHandler));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case proto::ids::MediaInfoChannelMessage::METADATA:
|
||||||
|
this->handleMetadataUpdate(payload, std::move(eventHandler));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case proto::ids::MediaInfoChannelMessage::PLAYBACK:
|
||||||
|
this->handlePlaybackUpdate(payload, std::move(eventHandler));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
AASDK_LOG(error) << "[MediaStatusServiceChannel] message not handled: " << messageId.getId() << " : " << dump(payload);
|
||||||
|
this->receive(std::move(eventHandler));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void MediaStatusServiceChannel::handleMetadataUpdate(const common::DataConstBuffer& payload, IMediaStatusServiceChannelEventHandler::Pointer eventHandler)
|
||||||
|
{
|
||||||
|
proto::messages::MediaInfoChannelMetadataData metadata;
|
||||||
|
if(metadata.ParseFromArray(payload.cdata, payload.size))
|
||||||
|
{
|
||||||
|
eventHandler->onMetadataUpdate(metadata);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD));
|
||||||
|
AASDK_LOG(error) << "[MediaStatusServiceChannel] encountered error with message: " << dump(payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MediaStatusServiceChannel::handlePlaybackUpdate(const common::DataConstBuffer& payload, IMediaStatusServiceChannelEventHandler::Pointer eventHandler)
|
||||||
|
{
|
||||||
|
proto::messages::MediaInfoChannelPlaybackData playback;
|
||||||
|
if(playback.ParseFromArray(payload.cdata, payload.size))
|
||||||
|
{
|
||||||
|
eventHandler->onPlaybackUpdate(playback);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD));
|
||||||
|
AASDK_LOG(error) << "[MediaStatusServiceChannel] encountered error with message: " << dump(payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void MediaStatusServiceChannel::handleChannelOpenRequest(const common::DataConstBuffer& payload, IMediaStatusServiceChannelEventHandler::Pointer eventHandler)
|
||||||
|
{
|
||||||
|
AASDK_LOG(info) << "[MediaStatusServiceChannel] channel open request ";
|
||||||
|
|
||||||
|
proto::messages::ChannelOpenRequest request;
|
||||||
|
if(request.ParseFromArray(payload.cdata, payload.size))
|
||||||
|
{
|
||||||
|
eventHandler->onChannelOpenRequest(request);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,162 @@
|
||||||
|
/*
|
||||||
|
* This file is part of aasdk library project.
|
||||||
|
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||||
|
*
|
||||||
|
* aasdk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
|
||||||
|
* aasdk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with aasdk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <aasdk_proto/ControlMessageIdsEnum.pb.h>
|
||||||
|
#include <aasdk_proto/NavigationChannelMessageIdsEnum.pb.h>
|
||||||
|
#include <aasdk_proto/NavigationStatusMessage.pb.h>
|
||||||
|
#include <aasdk_proto/NavigationTurnEventMessage.pb.h>
|
||||||
|
#include <aasdk_proto/NavigationDistanceEventMessage.pb.h>
|
||||||
|
#include <aasdk/Channel/Navigation/INavigationStatusServiceChannelEventHandler.hpp>
|
||||||
|
#include <aasdk/Channel/Navigation/NavigationStatusServiceChannel.hpp>
|
||||||
|
#include <aasdk/Common/Log.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
namespace aasdk
|
||||||
|
{
|
||||||
|
namespace channel
|
||||||
|
{
|
||||||
|
namespace navigation
|
||||||
|
{
|
||||||
|
|
||||||
|
NavigationStatusServiceChannel::NavigationStatusServiceChannel(boost::asio::io_service::strand& strand, messenger::IMessenger::Pointer messenger)
|
||||||
|
: ServiceChannel(strand, std::move(messenger), messenger::ChannelId::NAVIGATION)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void NavigationStatusServiceChannel::receive(INavigationStatusServiceChannelEventHandler::Pointer eventHandler)
|
||||||
|
{
|
||||||
|
AASDK_LOG(info) << "[NavigationStatusServiceChannel] receive ";
|
||||||
|
|
||||||
|
auto receivePromise = messenger::ReceivePromise::defer(strand_);
|
||||||
|
receivePromise->then(std::bind(&NavigationStatusServiceChannel::messageHandler, this->shared_from_this(), std::placeholders::_1, eventHandler),
|
||||||
|
std::bind(&INavigationStatusServiceChannelEventHandler::onChannelError, eventHandler,std::placeholders::_1));
|
||||||
|
|
||||||
|
messenger_->enqueueReceive(channelId_, std::move(receivePromise));
|
||||||
|
}
|
||||||
|
|
||||||
|
messenger::ChannelId NavigationStatusServiceChannel::getId() const
|
||||||
|
{
|
||||||
|
return channelId_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NavigationStatusServiceChannel::sendChannelOpenResponse(const proto::messages::ChannelOpenResponse& response, SendPromise::Pointer promise)
|
||||||
|
{
|
||||||
|
AASDK_LOG(info) << "[NavigationStatusServiceChannel] channel open response ";
|
||||||
|
|
||||||
|
auto message(std::make_shared<messenger::Message>(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::CONTROL));
|
||||||
|
message->insertPayload(messenger::MessageId(proto::ids::ControlMessage::CHANNEL_OPEN_RESPONSE).getData());
|
||||||
|
message->insertPayload(response);
|
||||||
|
|
||||||
|
this->send(std::move(message), std::move(promise));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void NavigationStatusServiceChannel::messageHandler(messenger::Message::Pointer message, INavigationStatusServiceChannelEventHandler::Pointer eventHandler)
|
||||||
|
{
|
||||||
|
AASDK_LOG(info) << "[NavigationStatusServiceChannel] message handler ";
|
||||||
|
|
||||||
|
messenger::MessageId messageId(message->getPayload());
|
||||||
|
common::DataConstBuffer payload(message->getPayload(), messageId.getSizeOf());
|
||||||
|
|
||||||
|
switch(messageId.getId())
|
||||||
|
{
|
||||||
|
case proto::ids::ControlMessage::CHANNEL_OPEN_REQUEST:
|
||||||
|
this->handleChannelOpenRequest(payload, std::move(eventHandler));
|
||||||
|
break;
|
||||||
|
case proto::ids::NavigationChannelMessage::STATUS:
|
||||||
|
this->handleStatusUpdate(payload, std::move(eventHandler));
|
||||||
|
break;
|
||||||
|
case proto::ids::NavigationChannelMessage::TURN_EVENT:
|
||||||
|
this->handleTurnEvent(payload, std::move(eventHandler));
|
||||||
|
break;
|
||||||
|
case proto::ids::NavigationChannelMessage::DISTANCE_EVENT:
|
||||||
|
this->handleDistanceEvent(payload, std::move(eventHandler));
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
default:
|
||||||
|
AASDK_LOG(error) << "[NavigationStatusServiceChannel] message not handled: " << messageId.getId() << " : " << dump(payload);
|
||||||
|
this->receive(std::move(eventHandler));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void NavigationStatusServiceChannel::handleChannelOpenRequest(const common::DataConstBuffer& payload, INavigationStatusServiceChannelEventHandler::Pointer eventHandler)
|
||||||
|
{
|
||||||
|
AASDK_LOG(info) << "[NavigationStatusServiceChannel] channel open request ";
|
||||||
|
|
||||||
|
proto::messages::ChannelOpenRequest request;
|
||||||
|
if(request.ParseFromArray(payload.cdata, payload.size))
|
||||||
|
{
|
||||||
|
eventHandler->onChannelOpenRequest(request);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void NavigationStatusServiceChannel::handleStatusUpdate(const common::DataConstBuffer& payload, INavigationStatusServiceChannelEventHandler::Pointer eventHandler)
|
||||||
|
{
|
||||||
|
proto::messages::NavigationStatus navStatus;
|
||||||
|
if(navStatus.ParseFromArray(payload.cdata, payload.size))
|
||||||
|
{
|
||||||
|
eventHandler->onStatusUpdate(navStatus);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD));
|
||||||
|
AASDK_LOG(error) << "[NavigationStatusServiceChannel] encountered error with message: " << dump(payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void NavigationStatusServiceChannel::handleTurnEvent(const common::DataConstBuffer& payload, INavigationStatusServiceChannelEventHandler::Pointer eventHandler)
|
||||||
|
{
|
||||||
|
proto::messages::NavigationTurnEvent turnEvent;
|
||||||
|
if(turnEvent.ParseFromArray(payload.cdata, payload.size))
|
||||||
|
{
|
||||||
|
eventHandler->onTurnEvent(turnEvent);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD));
|
||||||
|
AASDK_LOG(error) << "[NavigationStatusServiceChannel] encountered error with message: " << dump(payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void NavigationStatusServiceChannel::handleDistanceEvent(const common::DataConstBuffer& payload, INavigationStatusServiceChannelEventHandler::Pointer eventHandler)
|
||||||
|
{
|
||||||
|
proto::messages::NavigationDistanceEvent distanceEvent;
|
||||||
|
if(distanceEvent.ParseFromArray(payload.cdata, payload.size))
|
||||||
|
{
|
||||||
|
eventHandler->onDistanceEvent(distanceEvent);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD));
|
||||||
|
AASDK_LOG(error) << "[NavigationStatusServiceChannel] encountered error with message: " << dump(payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,6 +19,9 @@
|
||||||
#include <boost/algorithm/hex.hpp>
|
#include <boost/algorithm/hex.hpp>
|
||||||
#include <aasdk/Common/Data.hpp>
|
#include <aasdk/Common/Data.hpp>
|
||||||
#include <aasdk/Common/Log.hpp>
|
#include <aasdk/Common/Log.hpp>
|
||||||
|
#include <string>
|
||||||
|
#include <sstream>
|
||||||
|
#include <iomanip>
|
||||||
|
|
||||||
|
|
||||||
namespace aasdk
|
namespace aasdk
|
||||||
|
@ -130,6 +133,20 @@ std::string dump(const Data& data)
|
||||||
return dump(DataConstBuffer(data));
|
return dump(DataConstBuffer(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string uint8_to_hex_string(const uint8_t *v, const size_t s) {
|
||||||
|
std::stringstream ss;
|
||||||
|
|
||||||
|
ss << std::hex << std::setfill('0');
|
||||||
|
|
||||||
|
for (int i = 0; i < s; i++) {
|
||||||
|
ss << " ";
|
||||||
|
ss << std::hex << std::setw(2) << static_cast<int>(v[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
|
||||||
std::string dump(const DataConstBuffer& buffer)
|
std::string dump(const DataConstBuffer& buffer)
|
||||||
{
|
{
|
||||||
if(buffer.size == 0)
|
if(buffer.size == 0)
|
||||||
|
@ -138,7 +155,7 @@ std::string dump(const DataConstBuffer& buffer)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::string hexDump = "[" + std::to_string(buffer.size) + "] ";
|
std::string hexDump = "[" + uint8_to_hex_string(buffer.cdata, buffer.size) + " ] ";
|
||||||
//boost::algorithm::hex(bufferBegin(buffer), bufferEnd(buffer), back_inserter(hexDump));
|
//boost::algorithm::hex(bufferBegin(buffer), bufferEnd(buffer), back_inserter(hexDump));
|
||||||
return hexDump;
|
return hexDump;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,8 @@ std::string channelIdToString(ChannelId channelId)
|
||||||
return "AV_INPUT";
|
return "AV_INPUT";
|
||||||
case ChannelId::BLUETOOTH:
|
case ChannelId::BLUETOOTH:
|
||||||
return "BLUETOOTH";
|
return "BLUETOOTH";
|
||||||
|
case ChannelId::NAVIGATION:
|
||||||
|
return "NAVIGATION";
|
||||||
case ChannelId::NONE:
|
case ChannelId::NONE:
|
||||||
return "NONE";
|
return "NONE";
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue