mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
[Thread] Implement write on socket interface
Bug: 313425570 Test: build pass & manual test Change-Id: I2da14a563b795b0044362c1c248b53c1d3505d39
This commit is contained in:
@@ -83,6 +83,12 @@ void SocketInterface::Deinit(void) {
|
||||
mReceiveFrameBuffer = nullptr;
|
||||
}
|
||||
|
||||
otError SocketInterface::SendFrame(const uint8_t* aFrame, uint16_t aLength) {
|
||||
Write(aFrame, aLength);
|
||||
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
void SocketInterface::UpdateFdSet(void* aMainloopContext) {
|
||||
otSysMainloopContext* context = reinterpret_cast<otSysMainloopContext*>(aMainloopContext);
|
||||
|
||||
@@ -95,6 +101,12 @@ void SocketInterface::UpdateFdSet(void* aMainloopContext) {
|
||||
}
|
||||
}
|
||||
|
||||
void SocketInterface::Write(const uint8_t* aFrame, uint16_t aLength) {
|
||||
ssize_t rval = TEMP_FAILURE_RETRY(write(mSockFd, aFrame, aLength));
|
||||
VerifyOrDie(rval >= 0, OT_EXIT_ERROR_ERRNO);
|
||||
VerifyOrDie(rval > 0, OT_EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int SocketInterface::OpenFile(const ot::Url::Url& aRadioUrl) {
|
||||
int fd = -1;
|
||||
sockaddr_un serverAddress;
|
||||
|
||||
@@ -72,6 +72,20 @@ class SocketInterface : public ot::Spinel::SpinelInterface {
|
||||
*/
|
||||
void Deinit(void);
|
||||
|
||||
/**
|
||||
* Sends a Spinel frame to Radio Co-processor (RCP) over the
|
||||
* socket.
|
||||
*
|
||||
* @param[in] aFrame A pointer to buffer containing the Spinel frame to
|
||||
* send.
|
||||
* @param[in] aLength The length (number of bytes) in the frame.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully sent the Spinel frame.
|
||||
* @retval OT_ERROR_FAILED Failed to send a frame.
|
||||
*
|
||||
*/
|
||||
otError SendFrame(const uint8_t* aFrame, uint16_t aLength);
|
||||
|
||||
/**
|
||||
* Updates the file descriptor sets with file descriptors used by the radio
|
||||
* driver.
|
||||
@@ -122,6 +136,15 @@ class SocketInterface : public ot::Spinel::SpinelInterface {
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* Writes a given frame to the socket.
|
||||
*
|
||||
* @param[in] aFrame A pointer to buffer containing the frame to write.
|
||||
* @param[in] aLength The length (number of bytes) in the frame.
|
||||
*
|
||||
*/
|
||||
void Write(const uint8_t* aFrame, uint16_t aLength);
|
||||
|
||||
/**
|
||||
* Opens file specified by aRadioUrl.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user