Microchip® Advanced Software Framework

cert_downloader/ota_https_download/iot/stream_writer.h File Reference

Stream utility for the IoT service.

Copyright (c) 2016-2018 Microchip Technology Inc. and its subsidiaries.

#include <stdint.h>
#include <stdlib.h>

Data Structures

struct  stream_writer
 

Typedefs

typedef int(* stream_writer_write_func_t )(void *module, char *buffer, size_t buffer_len)
 

Functions

void stream_writer_init (struct stream_writer *writer, char *buffer, size_t max_length, stream_writer_write_func_t func, void *priv_data)
 Initialize the Stream writer module. More...
 
void stream_writer_send_16BE (struct stream_writer *writer, int16_t value)
 Write 16bit big endian value to the writer. More...
 
void stream_writer_send_16LE (struct stream_writer *writer, int16_t value)
 Write 16bit little endian value to the writer. More...
 
void stream_writer_send_32BE (struct stream_writer *writer, int32_t value)
 Write 32bit big endian value to the writer. More...
 
void stream_writer_send_32LE (struct stream_writer *writer, int32_t value)
 Write 32bit little endian value to the writer. More...
 
void stream_writer_send_8 (struct stream_writer *writer, int8_t value)
 Write 8bit to the writer. More...
 
void stream_writer_send_buffer (struct stream_writer *writer, const char *buffer, size_t length)
 Write buffer to the writer. More...
 
void stream_writer_send_remain (struct stream_writer *writer)
 Process remain data in the writer. More...
 

typedef int(* stream_writer_write_func_t)(void *module, char *buffer, size_t buffer_len)

void stream_writer_init ( struct stream_writer writer,
char *  buffer,
size_t  max_length,
stream_writer_write_func_t  func,
void *  priv_data 
)

Initialize the Stream writer module.

Parameters
[in]writerPointer of stream writer.
[in]bufferBuffer which will be used for the storing the data.
[in]max_lengthMaximum size of buffer.
[in]funcFunction to be called when the buffer is full.
[in]priv_dataPrivate data. It is passed along when callback was called.

References buffer, stream_writer::buffer, stream_writer::max_size, stream_writer::priv_data, stream_writer::write_func, and stream_writer::written.

Referenced by _http_client_request().

void stream_writer_send_16BE ( struct stream_writer writer,
int16_t  value 
)

Write 16bit big endian value to the writer.

Parameters
[in]writerPointer of stream writer.
[in]valueValue will be written.

References stream_writer_send_8().

void stream_writer_send_16LE ( struct stream_writer writer,
int16_t  value 
)

Write 16bit little endian value to the writer.

Parameters
[in]writerPointer of stream writer.
[in]valueValue will be written.

References stream_writer_send_8().

void stream_writer_send_32BE ( struct stream_writer writer,
int32_t  value 
)

Write 32bit big endian value to the writer.

Parameters
[in]writerPointer of stream writer.
[in]valueValue will be written.

References stream_writer_send_8().

void stream_writer_send_32LE ( struct stream_writer writer,
int32_t  value 
)

Write 32bit little endian value to the writer.

Parameters
[in]writerPointer of stream writer.
[in]valueValue will be written.

References stream_writer_send_8().

void stream_writer_send_8 ( struct stream_writer writer,
int8_t  value 
)

Write 8bit to the writer.

Parameters
[in]writerPointer of stream writer.
[in]valueValue will be written.

References stream_writer::buffer, stream_writer::max_size, stream_writer_send_remain(), and stream_writer::written.

Referenced by stream_writer_send_16BE(), stream_writer_send_16LE(), stream_writer_send_32BE(), stream_writer_send_32LE(), and stream_writer_send_buffer().

void stream_writer_send_buffer ( struct stream_writer writer,
const char *  buffer,
size_t  length 
)

Write buffer to the writer.

Parameters
[in]writerPointer of stream writer.
[in]bufferBuffer will be written.
[in]lengthSize of the buffer.

References stream_writer_send_8().

void stream_writer_send_remain ( struct stream_writer writer)

Process remain data in the writer.

Parameters
[in]writerPointer of stream writer.

References stream_writer::buffer, stream_writer::priv_data, stream_writer::write_func, and stream_writer::written.

Referenced by _http_client_request(), and stream_writer_send_8().