|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
NetX DHCP and a single-connection HTTP camera server over ESP32-C6. More...
#include <stdint.h>#include <string.h>#include "c6_camera_server.h"#include "nx_api.h"#include "nx_ether_driver_c6.h"#include "nxd_dhcp_client.h"#include "ra8_attributes.h"#include "ra8_c6link.h"#include "ra8_err.h"#include "tx_api.h"Go to the source code of this file.
Enumerations | |
| enum | c6_cam_net_format_t : uint32_t { k_c6_cam_net_decimal_digits = 10U , k_c6_cam_http_get_min = 5U } |
| Decimal formatting and minimum HTTP request sizes. More... | |
Functions | |
| static UINT | internal_c6_cam_net_create (void) |
| Create the static NetX packet pool and IP instance. | |
| ra8_err_t | c6_cam_net_up (ra8_c6link_t *link, const ra8_c6link_mac_t *mac, c6_cam_lease_t *out) |
| Bind NetX to an associated raw C6 link and obtain a DHCP lease. | |
| static UINT | internal_c6_cam_http_send (const void *data, uint32_t bytes) |
| Send an exact byte span over the accepted HTTP socket. | |
| static uint32_t | internal_c6_cam_append (char *out, uint32_t at, uint32_t cap, const char *text) |
| Append bounded text to a fixed HTTP header buffer. | |
| static uint32_t | internal_c6_cam_append_u32 (char *out, uint32_t at, uint32_t cap, uint32_t value) |
| Append an unsigned decimal value to a fixed buffer. | |
| static UINT | internal_c6_cam_http_response (const char *type, const void *body, uint32_t body_bytes, const c6_cam_frame_timing_t *timing, uint32_t timestamp_ms) |
| Send one complete close-delimited HTTP response. | |
| static UINT | internal_c6_cam_http_stream (void) |
| Serve a bounded multipart MJPEG sequence. | |
| static bool | internal_c6_cam_request_is (const char *request, uint32_t bytes, const char *path) |
| Match a bounded HTTP GET request path. | |
| static void | internal_c6_cam_http_frame (void) |
| Capture and serve one JPEG still response. | |
| static void | internal_c6_cam_http_audio (void) |
| Snapshot and serve the current audio window. | |
| static void | internal_c6_cam_http_dispatch (const char *request, uint32_t bytes) |
| Dispatch a bounded HTTP request to one route handler. | |
| static void | internal_c6_cam_http_handle (void) |
| Receive and dispatch one HTTP request. | |
| void | c6_cam_http_serve (void) |
| Serve the browser UI and fresh JPEG frames forever. | |
Variables | |
| static NX_PACKET_POOL | s_pool |
| static uint8_t | s_pool_mem [k_c6_cam_net_pool_bytes] |
| static NX_IP | s_ip |
| static uint8_t | s_ip_stack [k_c6_cam_net_ip_stack] |
| static uint8_t | s_arp_cache [k_c6_cam_net_arp_bytes] |
| static NX_DHCP | s_dhcp |
| static NX_TCP_SOCKET | s_http_socket |
| static CHAR | s_pool_name [] = "c6_cam_pool" |
| static CHAR | s_ip_name [] = "c6_cam_ip" |
| static CHAR | s_dhcp_name [] = "c6_cam_dhcp" |
| static CHAR | s_socket_name [] = "c6_cam_http" |
| static const char | s_page [] |
NetX DHCP and a single-connection HTTP camera server over ESP32-C6.
The C6 remains the validated esp-hosted L2 co-processor. NetX Duo, DHCP, TCP, HTTP parsing, camera capture and JPEG generation all run on RA8. The page uses one persistent multipart/MJPEG connection. /frame.jpg remains available for still capture, diagnostics, and HIL qualification.
Definition in file c6_cam_net.c.
| enum c6_cam_net_format_t : uint32_t |
Decimal formatting and minimum HTTP request sizes.
| Enumerator | |
|---|---|
| k_c6_cam_net_decimal_digits | Decimal digits in a 32-bit integer. |
| k_c6_cam_http_get_min | Minimum bytes in an HTTP GET prefix. |
Definition at line 221 of file c6_cam_net.c.
| void c6_cam_http_serve | ( | void | ) |
Serve the browser UI and fresh JPEG frames forever.
Definition at line 550 of file c6_cam_net.c.
References c6_cam_puts(), internal_c6_cam_http_handle(), k_c6_cam_http_port, k_c6_cam_listen_backlog, k_c6_cam_tcp_window, s_http_socket, s_ip, s_socket_name, and tx_thread_sleep.
Referenced by internal_c6_cam_worker_entry().
|
nodiscard |
Bind NetX to an associated raw C6 link and obtain a DHCP lease.
Definition at line 107 of file c6_cam_net.c.
References c6_cam_lease_t::bound, c6_cam_lease_t::dhcp_server, c6_cam_lease_t::gateway, internal_c6_cam_net_create(), c6_cam_lease_t::ip, k_c6_cam_dhcp_wait_ms, k_ra8_err_not_initialized, k_ra8_err_null_ptr, k_ra8_err_timeout, k_ra8_ok, c6_cam_lease_t::mask, nx_ether_driver_c6_bind(), nx_ether_driver_c6_set_mac(), ra8_c6link_mac::octet, s_dhcp, s_dhcp_name, and s_ip.
Referenced by internal_c6_cam_join().
|
static |
Append bounded text to a fixed HTTP header buffer.
Copies until NUL or capacity and returns the next write position.
| [out] | out | Destination character buffer. |
| [in] | at | Initial write offset. |
| [in] | cap | Destination capacity. |
| [in] | text | NUL-terminated source text. |
| uint32_t | First unwritten offset, never greater than cap. |
Definition at line 212 of file c6_cam_net.c.
Referenced by internal_c6_cam_http_response(), and internal_c6_cam_http_stream().
|
static |
Append an unsigned decimal value to a fixed buffer.
Formats digits in reverse stack storage and copies them in display order.
| [out] | out | Destination character buffer. |
| [in] | at | Initial write offset. |
| [in] | cap | Destination capacity. |
| [in] | value | Value to append. |
| uint32_t | First unwritten offset, never greater than cap. |
Definition at line 243 of file c6_cam_net.c.
References k_c6_cam_net_decimal_digits.
Referenced by internal_c6_cam_http_response(), and internal_c6_cam_http_stream().
|
static |
Snapshot and serve the current audio window.
Requests a stable WAV snapshot from the ping-pong audio backend and returns either that snapshot or a bounded not-ready response to the client.
Definition at line 462 of file c6_cam_net.c.
References c6_cam_audio_snapshot_wav(), c6_cam_put_u32(), c6_cam_puts(), internal_c6_cam_http_response(), k_ra8_ok, and RA8_INTERNAL.
Referenced by internal_c6_cam_http_dispatch().
|
static |
Dispatch a bounded HTTP request to one route handler.
Matches the request path against the stream, still-frame, audio, and health endpoints, falling back to the embedded browser page.
| [in] | request | Extracted request prefix. |
| [in] | bytes | Extracted request-byte count. |
Definition at line 498 of file c6_cam_net.c.
References internal_c6_cam_http_audio(), internal_c6_cam_http_frame(), internal_c6_cam_http_response(), internal_c6_cam_http_stream(), internal_c6_cam_request_is(), RA8_INTERNAL, and s_page.
Referenced by internal_c6_cam_http_handle().
|
static |
Capture and serve one JPEG still response.
Captures through the configured camera backend, emits the JPEG with timing metadata on success, and otherwise sends a bounded diagnostic body.
Definition at line 419 of file c6_cam_net.c.
References c6_cam_camera_capture_jpeg(), c6_cam_camera_report_last_error(), c6_cam_put_u32(), c6_cam_puts(), c6_cam_frame_timing_t::capture_ms, c6_cam_frame_timing_t::convert_ms, c6_cam_frame_timing_t::encode_ms, internal_c6_cam_http_response(), k_ra8_ok, ra8_err_to_str(), RA8_INTERNAL, and c6_cam_frame_timing_t::timestamp_ms.
Referenced by internal_c6_cam_http_dispatch().
|
static |
Receive and dispatch one HTTP request.
Extracts a bounded request prefix and serves stream, frame, audio, health, or UI content.
Definition at line 532 of file c6_cam_net.c.
References internal_c6_cam_http_dispatch(), k_c6_cam_request_max, RA8_INTERNAL, and s_http_socket.
Referenced by c6_cam_http_serve().
|
static |
Send one complete close-delimited HTTP response.
Builds bounded headers with optional timing and timestamp metadata, then sends the body.
| [in] | type | NUL-terminated MIME content type. |
| [in] | body | Readable response body. |
| [in] | body_bytes | Response body size. |
| [in] | timing | Optional camera timing metadata. |
| [in] | timestamp_ms | Optional monotonic media timestamp. |
| NX_SUCCESS | Header and body were sent. |
| NX_NOT_SUCCESSFUL | A socket send failed. |
Definition at line 275 of file c6_cam_net.c.
References c6_cam_frame_timing_t::capture_ms, c6_cam_frame_timing_t::convert_ms, c6_cam_frame_timing_t::encode_ms, internal_c6_cam_append(), internal_c6_cam_append_u32(), internal_c6_cam_http_send(), and RA8_INTERNAL.
Referenced by internal_c6_cam_http_audio(), internal_c6_cam_http_dispatch(), and internal_c6_cam_http_frame().
|
static |
Send an exact byte span over the accepted HTTP socket.
Chunks caller data into bounded NetX packets and sends them in order.
| [in] | data | Readable body or header bytes. |
| [in] | bytes | Total bytes to transmit. |
| NX_SUCCESS | The entire span was queued. |
| NX_NOT_SUCCESSFUL | Packet allocation, append, or socket send failed. |
Definition at line 163 of file c6_cam_net.c.
References k_c6_cam_http_chunk, RA8_INTERNAL, s_http_socket, and s_pool.
Referenced by internal_c6_cam_http_response(), and internal_c6_cam_http_stream().
|
static |
Serve a bounded multipart MJPEG sequence.
Captures a fresh JPEG for each part and emits per-frame timing diagnostics.
| NX_SUCCESS | The configured frame sequence completed. |
| NX_NOT_SUCCESSFUL | Capture or socket transmission failed. |
Definition at line 325 of file c6_cam_net.c.
References c6_cam_camera_capture_jpeg(), c6_cam_camera_report_last_error(), c6_cam_put_u32(), c6_cam_puts(), c6_cam_frame_timing_t::capture_ms, c6_cam_frame_timing_t::convert_ms, c6_cam_frame_timing_t::encode_ms, internal_c6_cam_append(), internal_c6_cam_append_u32(), internal_c6_cam_http_send(), k_c6_cam_stream_frames, k_ra8_ok, and RA8_INTERNAL.
Referenced by internal_c6_cam_http_dispatch().
|
static |
Create the static NetX packet pool and IP instance.
Enables ARP, UDP, TCP, and ICMP over the already-bound C6 Ethernet driver.
| NX_SUCCESS | All required NetX objects and protocols are ready. |
| NX_NOT_SUCCESSFUL | A NetX creation or enable operation failed. |
Definition at line 70 of file c6_cam_net.c.
References k_c6_cam_net_ip_prio, k_c6_cam_net_pkt_payload, nx_ether_driver_c6(), RA8_INTERNAL, s_arp_cache, s_ip, s_ip_name, s_ip_stack, s_pool, s_pool_mem, and s_pool_name.
Referenced by c6_cam_net_up().
|
static |
Match a bounded HTTP GET request path.
Compares the request target exactly while accepting a query suffix.
| [in] | request | Raw request bytes. |
| [in] | bytes | Available request-byte count. |
| [in] | path | NUL-terminated path to match. |
| true | The request is a GET for path with optional query text. |
| false | The method, length, or path does not match. |
Definition at line 391 of file c6_cam_net.c.
References k_c6_cam_http_get_min, and memcmp().
Referenced by internal_c6_cam_http_dispatch().
|
static |
Definition at line 34 of file c6_cam_net.c.
|
static |
Definition at line 35 of file c6_cam_net.c.
Referenced by c6_cam_net_up(), priv_net_dhcp(), and priv_net_dhcp().
|
static |
Definition at line 39 of file c6_cam_net.c.
Referenced by c6_cam_net_up(), priv_net_dhcp(), and priv_net_dhcp().
|
static |
Definition at line 36 of file c6_cam_net.c.
Referenced by c6_cam_http_serve(), internal_c6_cam_http_handle(), and internal_c6_cam_http_send().
|
static |
Definition at line 32 of file c6_cam_net.c.
|
static |
Definition at line 38 of file c6_cam_net.c.
Referenced by demo_netx_bring_up(), demo_netx_create_ip(), internal_c6_cam_net_create(), internal_demo_netx_bring_up(), priv_net_create_ip(), and priv_net_create_ip().
|
static |
Definition at line 33 of file c6_cam_net.c.
|
static |
Definition at line 42 of file c6_cam_net.c.
Referenced by cm_draw_page(), cm_draw_progress_bar(), cm_draw_status_bar(), cm_handle_tap(), and internal_c6_cam_http_dispatch().
|
static |
Definition at line 30 of file c6_cam_net.c.
|
static |
Definition at line 31 of file c6_cam_net.c.
Referenced by internal_c6_cam_net_create(), priv_net_create_ip(), and priv_net_create_ip().
|
static |
Definition at line 37 of file c6_cam_net.c.
Referenced by internal_c6_cam_net_create(), priv_net_create_ip(), and priv_net_create_ip().
|
static |
Definition at line 40 of file c6_cam_net.c.
Referenced by c6_cam_http_serve(), demo_netx_bring_up(), demo_tcp_connect(), and internal_demo_tcp_connect().