rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Functions | Variables
wifi_console.cpp File Reference

Functions

chibios_rt::BinarySemaphore isrSemaphore (true)
 
void os_hook_isr ()
 
chibios_rt::BinarySemaphore sendDoneSemaphore (true)
 
void wifiCallback (uint8 u8MsgType, void *pvMsg)
 
static void socketCallback (SOCKET sock, uint8_t u8Msg, void *pvMsg)
 
void startWifiConsole ()
 

Variables

static int listenerSocket = -1
 
static int connectionSocket = -1
 
static const uint8_t * sendBuffer
 
static size_t sendSize
 
bool sendRequest = false
 
static uint8_t recvBuffer [512]
 
static input_queue_t wifiIqueue
 
static bool socketReady = false
 
static NO_CACHE WifiChannel wifiChannel
 
static NO_CACHE WifiHelperThread wifiHelper
 
static tstrWifiInitParam param
 
static tstrM2MAPConfig apConfig
 
static NO_CACHE uint8_t rxBuf [512]
 
static NO_CACHE WifiConsoleThread wifiThread
 

Function Documentation

◆ isrSemaphore()

chibios_rt::BinarySemaphore isrSemaphore ( true  )

Referenced by os_hook_isr().

Here is the caller graph for this function:

◆ os_hook_isr()

void os_hook_isr ( )

Definition at line 16 of file wifi_console.cpp.

16 {
17 isrSemaphore.signalI();
18}
chibios_rt::BinarySemaphore isrSemaphore(true)
Here is the call graph for this function:

◆ sendDoneSemaphore()

chibios_rt::BinarySemaphore sendDoneSemaphore ( true  )

Referenced by socketCallback().

Here is the caller graph for this function:

◆ socketCallback()

static void socketCallback ( SOCKET  sock,
uint8_t  u8Msg,
void *  pvMsg 
)
static

Definition at line 109 of file wifi_console.cpp.

109 {
110 switch (u8Msg) {
111 case SOCKET_MSG_BIND: {
112 auto bindMsg = reinterpret_cast<tstrSocketBindMsg*>(pvMsg);
113
114 if (bindMsg && bindMsg->status == 0) {
115 // Socket bind complete, now listen!
116 listen(sock, 1);
117 }
118 } break;
119 case SOCKET_MSG_LISTEN: {
120 auto listenMsg = reinterpret_cast<tstrSocketListenMsg*>(pvMsg);
121 if (listenMsg && listenMsg->status == 0) {
122 // Listening, now accept a connection
123 accept(sock, nullptr, nullptr);
124 }
125 } break;
126 case SOCKET_MSG_ACCEPT: {
127 auto acceptMsg = reinterpret_cast<tstrSocketAcceptMsg*>(pvMsg);
128 if (acceptMsg && (acceptMsg->sock >= 0)) {
129 connectionSocket = acceptMsg->sock;
130
131 recv(connectionSocket, &rxBuf, 1, 0);
132
133 socketReady = true;
134 }
135 } break;
136 case SOCKET_MSG_RECV: {
137 auto recvMsg = reinterpret_cast<tstrSocketRecvMsg*>(pvMsg);
138 if (recvMsg && (recvMsg->s16BufferSize > 0)) {
139 {
140 chibios_rt::CriticalSectionLocker csl;
141
142 for (size_t i = 0; i < recvMsg->s16BufferSize; i++) {
143 iqPutI(&wifiIqueue, rxBuf[i]);
144 }
145 }
146
147 size_t nextRecv;
148 if (recvMsg->u16RemainingSize < 1) {
149 // Always try to read at least 1 byte
150 nextRecv = 1;
151 } else if (recvMsg->u16RemainingSize > sizeof(rxBuf)) {
152 // Remaining is too big for the buffer, so just read one buffer worth
153 nextRecv = sizeof(rxBuf);
154 } else {
155 // The full thing will fit, try to read it
156 nextRecv = recvMsg->u16RemainingSize;
157 }
158
159 // start the next recv
160 recv(sock, &rxBuf, nextRecv, 0);
161 } else {
162 close(sock);
163
164 socketReady = false;
165
166 {
167 chibios_rt::CriticalSectionLocker csl;
168 iqResetI(&wifiIqueue);
169 }
170 }
171 } break;
172 case SOCKET_MSG_SEND: {
173 // Send completed, notify caller!
174 chibios_rt::CriticalSectionLocker csl;
175 sendDoneSemaphore.signalI();
176 } break;
177 }
178}
static bool socketReady
static int connectionSocket
static NO_CACHE uint8_t rxBuf[512]
static input_queue_t wifiIqueue
chibios_rt::BinarySemaphore sendDoneSemaphore(true)
Here is the call graph for this function:

◆ startWifiConsole()

void startWifiConsole ( )

Definition at line 228 of file wifi_console.cpp.

228 {
229 iqObjectInit(&wifiIqueue, recvBuffer, sizeof(recvBuffer), nullptr, nullptr);
230
231 wifiThread.start();
232}
static NO_CACHE WifiConsoleThread wifiThread
static uint8_t recvBuffer[512]

Referenced by initEfiWithConfig().

Here is the caller graph for this function:

◆ wifiCallback()

void wifiCallback ( uint8  u8MsgType,
void *  pvMsg 
)

Definition at line 94 of file wifi_console.cpp.

94 {
95 switch (u8MsgType) {
96 case M2M_WIFI_REQ_DHCP_CONF: {
97 auto& dhcpInfo = *reinterpret_cast<tstrM2MIPConfig*>(pvMsg);
98 uint8_t* addr = reinterpret_cast<uint8_t*>(&dhcpInfo.u32StaticIP);
99 efiPrintf("WiFi client connected DHCP IP is %d.%d.%d.%d", addr[0], addr[1], addr[2], addr[3]);
100 } break;
101 default:
102 efiPrintf("WifiCallback: %d", (int)u8MsgType);
103 break;
104 }
105}
constexpr uint8_t addr
Definition ads1015.cpp:14

Variable Documentation

◆ apConfig

tstrM2MAPConfig apConfig
static

Definition at line 92 of file wifi_console.cpp.

◆ connectionSocket

int connectionSocket = -1
static

Definition at line 12 of file wifi_console.cpp.

Referenced by socketCallback().

◆ listenerSocket

int listenerSocket = -1
static

Definition at line 11 of file wifi_console.cpp.

◆ param

tstrWifiInitParam param
static

◆ recvBuffer

uint8_t recvBuffer[512]
static

Definition at line 27 of file wifi_console.cpp.

Referenced by startWifiConsole().

◆ rxBuf

NO_CACHE uint8_t rxBuf[512]
static

Definition at line 107 of file wifi_console.cpp.

Referenced by socketCallback().

◆ sendBuffer

const uint8_t* sendBuffer
static

Definition at line 21 of file wifi_console.cpp.

◆ sendRequest

bool sendRequest = false

Definition at line 23 of file wifi_console.cpp.

◆ sendSize

size_t sendSize
static

Definition at line 22 of file wifi_console.cpp.

◆ socketReady

bool socketReady = false
static

Definition at line 30 of file wifi_console.cpp.

Referenced by socketCallback().

◆ wifiChannel

NO_CACHE WifiChannel wifiChannel
static

Definition at line 68 of file wifi_console.cpp.

◆ wifiHelper

NO_CACHE WifiHelperThread wifiHelper
static

Definition at line 88 of file wifi_console.cpp.

◆ wifiIqueue

input_queue_t wifiIqueue
static

Definition at line 28 of file wifi_console.cpp.

Referenced by socketCallback(), and startWifiConsole().

◆ wifiThread

NO_CACHE WifiConsoleThread wifiThread
static

Definition at line 226 of file wifi_console.cpp.

Referenced by startWifiConsole().

Go to the source code of this file.