Skip to content

Source IP address of received UDP data #17

@xioTechnologies

Description

@xioTechnologies

Please update the rsi_socket_async to expose the source IP address of a UDP message. This was supported by legacy RS9916 documentation but not the current SAPI .

Our current work around is to call the following function in the SPI HAL for every SPI transfer.

/**
 * @brief Extracts the IP address from the WLAN data response frame.
 * @param frame_ Frame.
 * @param numberOfBytes NumberOfBytes.
 */
void ExtractResponseFrameIPAddress(const void* const frame_, const size_t numberOfBytes) {

    typedef struct {

        union {
            uint16_t word0;

            struct {
                unsigned int frameLength : 12;
                unsigned int frameType : 4;
            } __attribute__((__packed__));
        };

        union {
            uint16_t word1;

            struct {

                union {
                    unsigned int commandID : 8;
                    unsigned int responseID : 8;
                } __attribute__((__packed__));
                unsigned int : 8;
            };
        };
        uint16_t word2;
        uint16_t word3;
        uint16_t word4;
        uint16_t word5;

        union {
            uint16_t word6;
            uint16_t status;
        };
        uint16_t word7;
        uint16_t ipVersion;
        uint16_t socketDescriptor;
        uint32_t bufferSize;
        uint16_t bufferOffset;
        uint16_t port;
        uint32_t ipAddress;
    } __attribute__((__packed__)) Frame;

    // Check number of bytes
    if (numberOfBytes < sizeof (Frame)) {
        return;
    }
    const Frame * const frame = (void*) frame_;

    // Check frame type
    const int FrameTypeWlanData = 5;
    if (frame->frameType != FrameTypeWlanData) {
        return;
    }

    // Check response ID
    const int ResponseIDDataReceived = 0x00;
    if (frame->responseID != ResponseIDDataReceived) {
        return;
    }

    // Extract IP address
    responseFrameIPAddress = frame->ipAddress;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions