htc: add remaining worker receive thread logic
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2020 Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <stratosphere.hpp>
|
||||
#include "htclow_ctrl_send_buffer.hpp"
|
||||
|
||||
namespace ams::htclow::ctrl {
|
||||
|
||||
bool HtcctrlSendBuffer::IsPriorPacket(HtcctrlPacketType packet_type) const {
|
||||
return packet_type == HtcctrlPacketType_DisconnectFromTarget;
|
||||
}
|
||||
|
||||
bool HtcctrlSendBuffer::IsPosteriorPacket(HtcctrlPacketType packet_type) const {
|
||||
switch (packet_type) {
|
||||
case HtcctrlPacketType_ConnectFromTarget:
|
||||
case HtcctrlPacketType_ReadyFromTarget:
|
||||
case HtcctrlPacketType_SuspendFromTarget:
|
||||
case HtcctrlPacketType_ResumeFromTarget:
|
||||
case HtcctrlPacketType_BeaconResponse:
|
||||
case HtcctrlPacketType_InformationFromTarget:
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void HtcctrlSendBuffer::AddPacket(std::unique_ptr<HtcctrlPacket, HtcctrlPacketDeleter> ptr) {
|
||||
/* Get the packet. */
|
||||
HtcctrlPacket *packet = ptr.release();
|
||||
|
||||
/* Get the packet type. */
|
||||
const auto packet_type = packet->GetHeader()->packet_type;
|
||||
|
||||
/* Add the packet to the appropriate list. */
|
||||
if (this->IsPriorPacket(packet_type)) {
|
||||
m_prior_packet_list.push_back(*packet);
|
||||
} else {
|
||||
AMS_ABORT_UNLESS(this->IsPosteriorPacket(packet_type));
|
||||
m_posterior_packet_list.push_back(*packet);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user