Skip to content

Commit 5da12ed

Browse files
committed
network_http_post_bin added to network functions for all targets
1 parent c751591 commit 5da12ed

File tree

4 files changed

+36
-4
lines changed

4 files changed

+36
-4
lines changed

Changelog.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
## [Unreleased]
44

5-
## [4.5.3] - 2024-08-32
5+
## [4.6.0] - 2024-09-01
6+
7+
- [network] Add network_http_post_bin function to allow sending binary data instead of text, allowing for 00 char to be sent.
8+
9+
## [4.5.3] - 2024-08-30
610

711
- network_read and network_read_nb will exit if there is a general error.
812
network_read will set fn_bytes_read to the bytes read into the buffer so far, for client to decide what to do.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#ifdef _CMOC_VERSION_
2+
#include <cmoc.h>
3+
#else
4+
#include <stdint.h>
5+
#include <string.h>
6+
#endif /* _CMOC_VERSION_ */
7+
#include "fujinet-network.h"
8+
9+
uint8_t network_http_post_bin(char *devicespec, uint8_t *data, uint16_t len) {
10+
uint8_t err;
11+
err = network_http_set_channel_mode(devicespec, HTTP_CHAN_MODE_POST_SET_DATA);
12+
if (err) return err;
13+
err = network_write(devicespec, data, len);
14+
if (err) return err;
15+
return network_http_set_channel_mode(devicespec, HTTP_CHAN_MODE_BODY);
16+
}

fujinet-network.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,15 +206,27 @@ uint8_t network_http_add_header(char *devicespec, char *header);
206206

207207

208208
/**
209-
* @brief Send POST HTTP request
209+
* @brief Send POST HTTP request - assumes data is a string with nul terminator. This will not be able to send the 00 byte
210210
* @param devicespec pointer to device specification, e.g. "N1:HTTPS://fujinet.online/"
211-
* @param data data to post
211+
* @param data text data to post
212212
* @return fujinet-network error code (See FN_ERR_* values)
213213
*
214214
* Assumes an open connection.
215215
*/
216216
uint8_t network_http_post(char *devicespec, char *data);
217217

218+
219+
/**
220+
* @brief Send POST HTTP request, sends binary data from data location for length len, which allows sending arbitrary binary data
221+
* @param devicespec pointer to device specification, e.g. "N1:HTTPS://fujinet.online/"
222+
* @param data binary data to post
223+
* @param len length of binary data to send
224+
* @return fujinet-network error code (See FN_ERR_* values)
225+
*
226+
* Assumes an open connection.
227+
*/
228+
uint8_t network_http_post_bin(char *devicespec, uint8_t *data, uint16_t len);
229+
218230
/**
219231
* @brief Send PUT HTTP request
220232
* @param devicespec pointer to device specification, e.g. "N1:HTTPS://fujinet.online/"

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.5.3
1+
4.6.0

0 commit comments

Comments
 (0)