servicepoint-binding-c/example/random_stuff.c
Vinzenz Schroeter 3589a90385
Some checks failed
Rust / build (pull_request) Failing after 3m9s
add functions to convert containers directly into packet
2025-04-12 22:13:29 +02:00

27 lines
699 B
C

#include <stdio.h>
#include "servicepoint.h"
int main(void) {
UdpConnection *connection = sp_udp_open_ipv4(127, 0, 0, 1, 2342);
if (connection == NULL)
return 1;
Bitmap *pixels = sp_bitmap_new(PIXEL_WIDTH, PIXEL_HEIGHT);
if (pixels == NULL)
return 1;
sp_bitmap_fill(pixels, true);
Packet *packet = sp_bitmap_into_packet(pixels, 0, 0, COMPRESSION_CODE_UNCOMPRESSED);
if (packet == NULL)
return 1;
Header *header = sp_packet_get_header(packet);
printf("[%d, %d, %d, %d, %d]\n", header->command_code, header->a, header->b, header->c, header->d);
sp_udp_send_packet(connection, packet);
sp_udp_free(connection);
return 0;
}