Skip to content

Commit

Permalink
network_http_post_bin added to network functions for all targets
Browse files Browse the repository at this point in the history
  • Loading branch information
markjfisher committed Sep 1, 2024
1 parent c751591 commit 5da12ed
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
6 changes: 5 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

## [Unreleased]

## [4.5.3] - 2024-08-32
## [4.6.0] - 2024-09-01

- [network] Add network_http_post_bin function to allow sending binary data instead of text, allowing for 00 char to be sent.

## [4.5.3] - 2024-08-30

- network_read and network_read_nb will exit if there is a general error.
network_read will set fn_bytes_read to the bytes read into the buffer so far, for client to decide what to do.
Expand Down
16 changes: 16 additions & 0 deletions common/src/fn_network/network_http_post_bin.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifdef _CMOC_VERSION_
#include <cmoc.h>
#else
#include <stdint.h>
#include <string.h>
#endif /* _CMOC_VERSION_ */
#include "fujinet-network.h"

uint8_t network_http_post_bin(char *devicespec, uint8_t *data, uint16_t len) {
uint8_t err;
err = network_http_set_channel_mode(devicespec, HTTP_CHAN_MODE_POST_SET_DATA);
if (err) return err;
err = network_write(devicespec, data, len);
if (err) return err;
return network_http_set_channel_mode(devicespec, HTTP_CHAN_MODE_BODY);
}
16 changes: 14 additions & 2 deletions fujinet-network.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,27 @@ uint8_t network_http_add_header(char *devicespec, char *header);


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


/**
* @brief Send POST HTTP request, sends binary data from data location for length len, which allows sending arbitrary binary data
* @param devicespec pointer to device specification, e.g. "N1:HTTPS://fujinet.online/"
* @param data binary data to post
* @param len length of binary data to send
* @return fujinet-network error code (See FN_ERR_* values)
*
* Assumes an open connection.
*/
uint8_t network_http_post_bin(char *devicespec, uint8_t *data, uint16_t len);

/**
* @brief Send PUT HTTP request
* @param devicespec pointer to device specification, e.g. "N1:HTTPS://fujinet.online/"
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.5.3
4.6.0

0 comments on commit 5da12ed

Please sign in to comment.