@@ -83,26 +83,23 @@ int CameraController<T>::sendSnapshot(uint8_t* buffer, size_t len) {
83
83
int resCode = -1 ;
84
84
85
85
#if defined(ESP32)
86
- T *device = static_cast <T *>(this );
87
-
88
- // Validate input buffer
86
+ T* device = static_cast <T*>(this );
87
+
89
88
if (!buffer) return resCode;
90
89
91
90
HTTPClient http;
92
91
bool beginSuccess = false ;
93
92
94
- #ifdef SINRICPRO_NOSSL
95
- WiFiClient *client = new WiFiClient ();
96
- if (!client) return resCode;
97
-
98
- beginSuccess = http.begin (*client, SINRICPRO_CAMERA_URL, 80 , SINRICPRO_CAMERA_PATH, false );
99
- #else
100
- WiFiClientSecure *secureClient = new WiFiClientSecure ();
101
- if (!secureClient) return resCode;
102
-
103
- secureClient->setInsecure (); // Skip certificate validation
104
- beginSuccess = http.begin (*secureClient, SINRICPRO_CAMERA_URL, 443 , SINRICPRO_CAMERA_PATH, true );
105
- #endif
93
+ #ifdef SINRICPRO_NOSSL
94
+ std::unique_ptr<WiFiClient> client = std::make_unique<WiFiClient>();
95
+ if (!client) return resCode;
96
+ beginSuccess = http.begin (*client, SINRICPRO_CAMERA_URL, 80 , SINRICPRO_CAMERA_PATH, false );
97
+ #else
98
+ std::unique_ptr<WiFiClientSecure> secureClient = std::make_unique<WiFiClientSecure>();
99
+ if (!secureClient) return resCode;
100
+ secureClient->setInsecure ();
101
+ beginSuccess = http.begin (*secureClient, SINRICPRO_CAMERA_URL, 443 , SINRICPRO_CAMERA_PATH, true );
102
+ #endif
106
103
107
104
if (!beginSuccess) {
108
105
http.end ();
@@ -111,7 +108,7 @@ int CameraController<T>::sendSnapshot(uint8_t* buffer, size_t len) {
111
108
112
109
const String& deviceId = device->getDeviceId ();
113
110
String createdAt = String (device->getTimestamp ());
114
- String signature = device->sign (deviceId+ createdAt);
111
+ String signature = device->sign (deviceId + createdAt);
115
112
116
113
http.addHeader (FSTR_SINRICPRO_deviceId, deviceId);
117
114
http.addHeader (FSTR_SINRICPRO_createdAt, createdAt);
@@ -120,8 +117,9 @@ int CameraController<T>::sendSnapshot(uint8_t* buffer, size_t len) {
120
117
resCode = http.POST (buffer, len);
121
118
http.end ();
122
119
#endif
123
-
120
+
124
121
return resCode;
125
122
}
126
123
124
+
127
125
} // namespace SINRICPRO_NAMESPACE
0 commit comments