11#include " http_client.h"
2+ #include " led_ctrl.h"
23#include " log.h"
34#include " security_profile.h"
45#include " sequans_controller.h"
@@ -83,6 +84,8 @@ static HttpResponse sendData(const char* endpoint,
8384 const uint32_t header_length = 0 ,
8485 const char * content_type = " " ) {
8586
87+ LedCtrl.on (Led::CON, true );
88+
8689 // The modem could hang if several HTTP requests are done quickly after each
8790 // other, this alleviates this
8891 SequansController.writeCommand (" AT" );
@@ -108,6 +111,7 @@ static HttpResponse sendData(const char* endpoint,
108111 content_type,
109112 header == NULL ? " " : (const char *)header);
110113
114+ LedCtrl.on (Led::DATA, true );
111115 SequansController.writeBytes ((uint8_t *)command, command_length, true );
112116
113117 // Only send the data payload if there is any
@@ -119,6 +123,9 @@ static HttpResponse sendData(const char* endpoint,
119123 " payload. Is the "
120124 " server online? If you're using HTTPS, you might need to "
121125 " provision with a different CA certificate." );
126+
127+ LedCtrl.off (Led::CON, true );
128+ LedCtrl.off (Led::DATA, true );
122129 return http_response;
123130 }
124131
@@ -138,6 +145,8 @@ static HttpResponse sendData(const char* endpoint,
138145 if (!SequansController.waitForURC (HTTP_RING_URC,
139146 http_response_buffer,
140147 sizeof (http_response_buffer))) {
148+ LedCtrl.off (Led::CON, true );
149+ LedCtrl.off (Led::DATA, true );
141150 Log.warn (" Did not get HTTP response before timeout\r\n " );
142151 return http_response;
143152 }
@@ -166,6 +175,9 @@ static HttpResponse sendData(const char* endpoint,
166175 http_response.data_size = atoi (data_size_buffer);
167176 }
168177
178+ LedCtrl.off (Led::CON, true );
179+ LedCtrl.off (Led::DATA, true );
180+
169181 return http_response;
170182}
171183
@@ -183,6 +195,8 @@ static HttpResponse queryData(const char* endpoint,
183195 const uint8_t * header,
184196 const uint32_t header_length) {
185197
198+ LedCtrl.on (Led::CON, true );
199+
186200 // The modem could hang if several HTTP requests are done quickly after each
187201 // other, this alleviates this
188202 SequansController.writeCommand (" AT" );
@@ -203,6 +217,7 @@ static HttpResponse queryData(const char* endpoint,
203217 endpoint,
204218 header == NULL ? " " : (const char *)header);
205219
220+ LedCtrl.on (Led::DATA, true );
206221 SequansController.writeCommand (command);
207222
208223 char http_response_buffer[HTTP_RESPONSE_MAX_LENGTH] = " " ;
@@ -213,6 +228,9 @@ static HttpResponse queryData(const char* endpoint,
213228 http_response_buffer,
214229 sizeof (http_response_buffer))) {
215230 Log.warn (" Did not get HTTP response before timeout\r\n " );
231+
232+ LedCtrl.off (Led::DATA, true );
233+ LedCtrl.off (Led::CON, true );
216234 return http_response;
217235 }
218236
@@ -238,6 +256,9 @@ static HttpResponse queryData(const char* endpoint,
238256 http_response.data_size = atoi (data_size_buffer);
239257 }
240258
259+ LedCtrl.off (Led::DATA, true );
260+ LedCtrl.off (Led::CON, true );
261+
241262 return http_response;
242263}
243264
0 commit comments