Skip to content

Commit 67c3108

Browse files
committed
remove comments
1 parent 0121910 commit 67c3108

File tree

2 files changed

+1
-121
lines changed

2 files changed

+1
-121
lines changed

iot_protocol.cpp

Lines changed: 1 addition & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
IoTApp::IoTApp()
44
{
5-
// this->handleData = [this](void *, AsyncClient *client, void *data, size_t len)
6-
// {
7-
// this->onData(client, (uint8_t *)data, len);
8-
// };
95
}
106

117
void IoTApp::use(IoTMiddleware middleware)
@@ -36,19 +32,6 @@ void IoTApp::runMiddleware(IoTRequest *request, int index = 0)
3632
}
3733
}
3834

39-
// static void handleData(void* arg, AsyncClient* client, void *data, size_t len)
40-
// {
41-
// Serial.print("[CALLBACK] data received, ip: " + client->remoteIP().toString());
42-
// Serial.println( " [" + String((char*)data) + "]");
43-
44-
// // or loop through data , using data[i] and len:
45-
// // for ( int i = 0 ; i < len ; i++ ) {
46-
// // if ( uint8_t*)data[i] == 0 ) { } }
47-
48-
// // could send to server here, by doing:
49-
// // sendToServer( "Hello!");
50-
// }
51-
5235
void IoTApp::listen(Client *client)
5336
{
5437
this->clients.push_back(client);
@@ -235,12 +218,7 @@ IoTRequest *IoTApp::send(IoTRequest *request, IoTRequestResponse *requestRespons
235218
dataLength += 2 + request->bodyLength; /* 1 + 1 (B+\n) + request->bodyLength */
236219
}
237220

238-
// uint8_t *data = (uint8_t *)(malloc(dataLength * sizeof(uint8_t)));
239-
// uint8_t *data = new uint8_t[dataLength];
240-
241-
// char data[dataLength+1]; /* +1 (\0) */
242221
uint8_t data[dataLength + 1]; /* +1 (\0) */
243-
// uint8_t data[6 + pathLength + 2]; /* +2 (\n\0) */
244222
data[0] = request->version;
245223
data[1] = '\n';
246224
data[2] = static_cast<uint8_t>((char)request->method);
@@ -250,39 +228,30 @@ IoTRequest *IoTApp::send(IoTRequest *request, IoTRequestResponse *requestRespons
250228

251229
size_t nextIndex = 5;
252230

253-
// memcpy((data + 6), request->path, pathLength);
254231
for (size_t i = 0; i < pathLength; i++)
255232
{
256233
data[++nextIndex] = *(request->path + i);
257234
}
258235

259-
// size_t nextIndex = 6 + pathLength; /* 5 (last index) + pathLength + 1 (next) */
260-
// data[nextIndex] = '\n';
261-
// nextIndex++;
262-
263236
data[++nextIndex] = '\n';
264237

265238
if (headers.length() > 0)
266239
{
267-
// memcpy((data + nextIndex), headers.c_str(), headers.length());
268240
for (size_t i = 0; i < headers.length(); i++)
269241
{
270242
data[++nextIndex] = (headers.charAt(i));
271243
}
272-
// nextIndex += headers.length();
273244
}
274245

275246
if (request->body != NULL)
276247
{
277248
data[++nextIndex] = 'B';
278249
data[++nextIndex] = '\n';
279-
// memcpy((data + nextIndex + 1), request->body, request->bodyLength);
280250
for (size_t i = 0; i < request->bodyLength; i++)
281251
{
282252
data[++nextIndex] = *(request->body + i);
283253
}
284254
}
285-
// data[nextIndex + request->bodyLength + 1] = '\0';
286255

287256
data[++nextIndex] = '\0';
288257

@@ -298,94 +267,8 @@ IoTRequest *IoTApp::send(IoTRequest *request, IoTRequestResponse *requestRespons
298267
this->requestResponse.insert(std::make_pair(request->id, *requestResponse));
299268
}
300269

301-
// request->client->print("teste");
302-
// String _data = String((const char*)data);
303-
// request->client->print(_data);
304-
// const uint8_t* _data = data;
305-
306-
// const uint8_t* _data = data;
307-
// request->client->print(String(_data, dataLength));
308-
// request->client->print("lorem ipsum fuck the message how much logger is this better for our test and counter lorem ipsum fuck the message how much logger is this better for our test and counter lorem ipsum fuck the message how much logger is this better for our test and counter");
309-
310-
// request->client->add((const char*)data, dataLength);
311-
// request->client->send();
312-
313-
// request->client->write((const char*)data, dataLength);
314-
315-
// const char* teste = (const char *)(malloc(dataLength * sizeof(char)));
316-
317-
/* char c[3];
318-
319-
c[0] = 'h';
320-
c[1] = 'i';
321-
c[2] = '\0'; */
322-
323-
//---- ok com path
324-
// char c[6 + pathLength + 2];
325-
326-
// c[0] = request->version;
327-
// c[1] = '\n';
328-
// c[2] = static_cast<uint8_t>((char)request->method);
329-
// c[3] = request->id >> 8; /* Id as Big Endian - (MSB first) */
330-
// c[4] = request->id - (data[3] << 8); /* Id as Big Endian - (LSB last) */
331-
// c[5] = '\n';
332-
// size_t cursor = 6;
333-
// // char p[pathLength];
334-
// for (size_t i = 0; i < pathLength; i++)
335-
// {
336-
// c[cursor + i] = *(request->path+i);
337-
// }
338-
// // char p[] = "/who/r/i";
339-
// // for (size_t i = 0; i < 8; i++)
340-
// // {
341-
// // c[cursor + i] = p[i];
342-
// // }
343-
// // memcpy((c + 6), request->path, pathLength);
344-
// c[(6 + pathLength)] = '\n';
345-
// c[(7 + pathLength)] = '\0';
346-
347-
// const char *d = c;
348-
// request->client->write(d, dataLength);
349-
//----- ok com path
350-
// const uint8_t *d = data;
351-
352-
// std::copy(data, data+dataLength, teste);
353-
// memcpy((char*)teste, data, dataLength);
354-
355270
request->client->write(data, dataLength);
356-
// request->client->write(d, 6 + pathLength + 1);
357-
358-
// size_t space = request->client->space();
359-
// if (space > dataLength)
360-
// {
361-
// // request->client->write((const char *)data, dataLength, ASYNC_WRITE_FLAG_MORE);
362-
363-
// }
364-
365-
// free((char*)teste);
366-
367-
// request->client->free();
368-
369-
// write the data in chunks
370-
// int chunk_size = 16; // write data in 16-byte chunks
371-
// for (int i = 0; i < dataLength; i += chunk_size)
372-
// {
373-
// size_t remainToWrite = dataLength - i;
374-
// size_t amountToWrite = ( remainToWrite > chunk_size) ? chunk_size : remainToWrite;
375-
// int bytes_written = request->client->write(data + i, amountToWrite);
376-
// }
377-
378-
// _data = String();
379-
380-
// request->client->flush();
381-
// request->client->stop();
382-
383-
// request->client->;
384-
// request->client->close();
385-
386-
// free(data);
387-
388-
// delete[] data;
271+
389272
if (shouldFreePath)
390273
{
391274
free(request->path);

iot_protocol.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,8 @@ struct IoTRequestResponse
6363
class IoTApp
6464
{
6565
private:
66-
// std::vector<AsyncClient *> clients;
6766
std::vector<Client *> clients;
6867
void onData(Client *client, uint8_t *buffer, size_t bufLen);
69-
// void handleData(void* arg, AsyncClient* client, void *data, size_t len);
70-
// AcDataHandler handleData;
7168
std::map<uint16_t, IoTRequestResponse> requestResponse = std::map<uint16_t, IoTRequestResponse>();
7269

7370
public:

0 commit comments

Comments
 (0)