9#ifndef __NBWICEDMSGSTRUCTS_H
10#define __NBWICEDMSGSTRUCTS_H
14#include <wifi/nbWifiConstants.h>
21#define BufferToObjPtr(buffer, objType) ((objType *)((uint8_t *)((buffer)->pData) + (buffer)->usedsize))
22#define AddToBuffLen(buffer, msgPtr) (buffer)->usedsize += sizeof(*msgPtr)
23#define GetSafeLength(val, max) ((val) <= (max)) ? (val) : (max)
25#define MESSAGE_TYPE_BIT_OFFSET 4
26#define TYPELEN_FIELD_LEN (sizeof(NB::NBWifiAPIMessage::Header::lenType))
27#define _STRUCT_PACKED __attribute__((__packed__))
28#define MAX_HARDWARE_TYPE_LENGTH 64
37namespace NBWifiAPIMessage
43 Type_API_Request = 0x0,
44 Type_API_Response = 0x1,
45 Type_Credit_Report = 0x2,
47 Type_Data_CompressedIP = 0x4,
56 Type_Connect_Start = 0x1,
57 Type_Disconnect_Stop = 0x2,
60 Type_SaveConfig = 0x5,
61 Type_GetCredits = 0x6,
62 Type_SetBusSpeed = 0x7,
63 Type_ReadyFirmware = 0x8,
64 Type_FirmwareChunk = 0x9,
65 Type_VerifyAndProgFirm = 0xA,
66 Type_AddRemoveMulticast = 0xB,
67 Type_SetITUCountry = 0xC,
68 Type_GetStatus = 0xFD,
69 Type_GetDeviceInfo = 0xFE,
70 Type_GetOptionTable = 0xFF
77 Type_Scan_Result = 0x0,
79 Type_DeviceInfo = 0x2,
80 Type_OptionTableResp = 0x3,
87 Type_Internal_JoinAP = 0x0,
88 Type_Internal_SendStatus = 0x1,
89 Type_Internal_Reconnect = 0x2,
103namespace NBWifiAPIMessage
108struct _STRUCT_PACKED lenType
113struct _STRUCT_PACKED APIRequest
115 lenType lengthAndType;
120struct _STRUCT_PACKED APIResponse
122 lenType lengthAndType;
123 uint8_t responseType;
130struct _STRUCT_PACKED CreditReport
132 lenType lengthAndType;
133 uint8_t availableCredits;
135struct _STRUCT_PACKED Data_Raw
137 lenType lengthAndType;
138 uint8_t availableCredits;
141struct _STRUCT_PACKED Data_CompressedIP
143 lenType lengthAndType;
144 uint8_t connectionID;
145 uint8_t availableCredits;
148struct _STRUCT_PACKED Internal
150 lenType lengthAndType;
159struct _STRUCT_PACKED ConfigReq
163 uint8_t passwdLength;
167struct _STRUCT_PACKED ConnectStart
173struct _STRUCT_PACKED Scan
179struct _STRUCT_PACKED SetMAC
183struct _STRUCT_PACKED SaveConfig
187struct _STRUCT_PACKED SetBusSpeed
191struct _STRUCT_PACKED FirmwareChunk
198struct _STRUCT_PACKED VerifyAndProgFirm
200 beuint32_t imageLength;
201 beuint32_t checksum[4];
203struct _STRUCT_PACKED AddRemoveMulticast
208struct _STRUCT_PACKED SetITUCountry
213struct _STRUCT_PACKED GetTableReq
222struct _STRUCT_PACKED ScanResult
234struct _STRUCT_PACKED Status
240 beuint32_t maxTxRate;
249struct _STRUCT_PACKED DeviceInfo
251 uint8_t hardwareMajorRev;
252 uint8_t hardwareMinorRev;
253 uint8_t softwareMajorRev;
254 uint8_t softwareMinorRev;
256 uint8_t hardwareTypeLength;
257 char hardwareType[MAX_HARDWARE_TYPE_LENGTH + 1];
259struct _STRUCT_PACKED OptionTable
267 beuint16_t flagsAndEntryCount;
282namespace NBWifiAPIMessage
286void WriteHeader_APIRequest(
PoolPtr messageBuffer,
288 NB::NBWifiAPIMessage::Request::RequestTypes requestType,
290void WriteHeader_APIResponse(
PoolPtr messageBuffer,
292 NB::NBWifiAPIMessage::Response::ResponseTypes responseType,
295void FixHeader_Length(
PoolPtr messageBuffer);
296void WriteHeader_Data_Raw(
PoolPtr messageBuffer,
bool additionalFlag, uint16_t length);
297void WriteHeader_Data_CompressedIP(
PoolPtr messageBuffer,
bool additionalFlag, uint16_t length, uint8_t connectionID);
298void WriteCreditReport(
PoolPtr messageBuffer,
bool additionalFlag, uint16_t length, uint8_t availableCredits);
299bool VerifyChecksum(NB::NBWifiAPIMessage::Header::lenType lengthAndType);
303void WriteMsg_ConfigReq(
PoolPtr messageBuffer,
307 uint8_t passwdLength,
308 uint16_t *optionList,
309 uint8_t optionCount);
310void WriteMsg_ConnectStart(
PoolPtr messageBuffer, uint8_t configNumber,
bool scan, uint8_t retryCount);
311void WriteMsg_SetMAC(
PoolPtr messageBuffer,
const MACADR *newMAC);
312void WriteMsg_SetITUCountry(
PoolPtr messageBuffer, NB::ITU_Country::CountryCode_t country);
313void WriteMsg_SetBusSpeed(
PoolPtr messageBuffer, uint32_t busSpeed);
314void WriteMsg_SaveConfig(
PoolPtr messageBuffer, uint32_t busSpeed);
315void WriteMsg_FirmwareChunk(
PoolPtr messageBuffer, uint32_t offset, uint16_t dataLen, uint16_t checksum,
const uint8_t *data);
316void WriteMsg_VerifyAndProgFirm(
PoolPtr messageBuffer, uint32_t imageLen,
const uint32_t *checksum);
317void WriteMsg_AddRemoveMulticast(
PoolPtr messageBuffer,
bool AddNotRemove,
const MACADR *mac);
318void WriteMsg_Scan(
PoolPtr messageBuffer, uint8_t optionCount, uint16_t *optionList, uint8_t ssidLength,
const char *ssid);
322void WriteMsg_ScanResult(
PoolPtr messageBuffer,
324 Constants::RadioBand band,
325 Constants::BssType bssType,
333void WriteMsg_Status(
PoolPtr messageBuffer,
344void WriteMsg_DeviceInfo(
PoolPtr messageBuffer,
345 uint8_t hardwareMajorRev,
346 uint8_t hardwareMinorRev,
347 uint8_t softwareMajorRev,
348 uint8_t softwareMinorRev,
349 const MACADR *pHardwareID,
350 const char *hardwareType,
351 uint8_t hardwareTypeLength);
Used to store and manipulate MAC addresses.
Definition nettypes.h:69
Main buffer structure for network and serial communication.
Definition buffers.h:90