LOM2M  0.8.0
bsp-esp8266.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2013-2021 LAAS-CNRS (www.laas.fr)
3  7 Colonel Roche 31077 Toulouse - France
4 
5  The use of this source code requires an agreement with the CNRS.
6 
7  Initial Contributors:
8  David Gauchard, Guillaume Garzone, Thierry Monteil.
9 */
10 
11 #ifndef __BSP_ESP8266_H
12 #define __BSP_ESP8266_H
13 
14 #include <Arduino.h>
15 #include <ESP8266WebServer.h>
16 #include <detail/mimetable.h> // ESP8266WebServer
17 #include "bsp.h"
18 
19 #if 1
20 // esp8266 arduino needs updates to take a PROGMEM char*
21 // (in progress https://github.com/esp8266/Arduino/issues/6384)
22 #undef PSTR
23 #define PSTR(x) x
24 #undef PROGMEM
25 #define PROGMEM
26 #endif
27 
28 extern ESP8266WebServer om2msrv;
29 
30 inline const String HTTPCode2Human(HTTPCode code)
31 {
32  return ESP8266WebServer::responseCodeToString(code);
33 }
34 [[deprecated]]
35 inline void sendReply(HTTPCode code, const String& contentType, const String& message)
36 {
37  om2msrv.send(code, contentType, message);
38 }
39 
40 template <typename T>
41 inline const String& HTTPHeader(const T& attribute)
42 {
43  return om2msrv.header(attribute);
44 }
45 
46 template <typename T>
47 inline const String& HTTPArg(const T& key)
48 {
49  return om2msrv.arg(key);
50 }
51 
52 template <typename T>
53 inline bool HTTPHasArg(const T& key)
54 {
55  return om2msrv.hasArg(key);
56 }
57 
58 inline const String& HTTPContent()
59 {
60  return HTTPArg(F("plain"));
61 }
62 
63 inline const String& HTTPArgValueByIndex(int i)
64 {
65  return om2msrv.arg(i);
66  }
67 
68 inline const String& HTTPArgNameByIndex(int i)
69 {
70  return om2msrv.argName(i);
71 }
72 
73 inline const int ArgsNumber()
74 {
75  return om2msrv.args();
76 }
77 
78 inline HTTPMethod method()
79 {
80  return om2msrv.method();
81 }
82 
84 
85 #endif // __BSP_ESP8266
const char * contentType(const String &filename)
Definition: bsp-esp8266.cpp:13
const String & HTTPHeader(const T &attribute)
Definition: bsp-esp8266.h:41
void sendReply(HTTPCode code, const String &contentType, const String &message)
Definition: bsp-esp8266.h:35
const String & HTTPContent()
Definition: bsp-esp8266.h:58
const String & HTTPArg(const T &key)
Definition: bsp-esp8266.h:47
const String & HTTPArgValueByIndex(int i)
Definition: bsp-esp8266.h:63
const String & HTTPArgNameByIndex(int i)
Definition: bsp-esp8266.h:68
ESP8266WebServer om2msrv
bool HTTPHasArg(const T &key)
Definition: bsp-esp8266.h:53
const String HTTPCode2Human(HTTPCode code)
Definition: bsp-esp8266.h:30
const int ArgsNumber()
Definition: bsp-esp8266.h:73
HTTPMethod method()
Definition: bsp-esp8266.h:78
HTTPCode
Definition: bsp.h:19
String message
Definition: mqttBinding.cpp:190