Bahaha you crashed
This commit is contained in:
parent
13d4e9bb65
commit
699bbae3e4
6 changed files with 111 additions and 5 deletions
|
@ -7,7 +7,7 @@ INCLUDE_PATH = ../include
|
|||
CFLAGS += -I$(INCLUDE_PATH)
|
||||
LDFLAGS = -L../src -lskipstone
|
||||
|
||||
EXAMPLES = read music map
|
||||
EXAMPLES = read music map test
|
||||
|
||||
RM = /bin/rm
|
||||
|
||||
|
|
53
examples/test.c
Normal file
53
examples/test.c
Normal file
|
@ -0,0 +1,53 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <skipstone/link.h>
|
||||
#include <skipstone/message.h>
|
||||
|
||||
static void usage(int argc, char **argv) {
|
||||
fprintf(stderr, "usage: %s /dev/rfcommX\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static int answer_phone_version_message(skipstone_message_service *service,
|
||||
void *buf, uint16_t size, uint16_t id) {
|
||||
uint8_t response[12] = {
|
||||
0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02
|
||||
};
|
||||
|
||||
skipstone_message_service_queue(service, &response, sizeof(response), id);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
skipstone_link *link;
|
||||
skipstone_message_service *service;
|
||||
|
||||
if (argc != 2) {
|
||||
usage(argc, argv);
|
||||
}
|
||||
|
||||
if ((link = skipstone_link_open_serial(argv[1])) == NULL) {
|
||||
goto error_link_open;
|
||||
}
|
||||
|
||||
if ((service = skipstone_message_service_new()) == NULL) {
|
||||
goto error_message_service_new;
|
||||
}
|
||||
|
||||
skipstone_message_service_register(service, 17, answer_phone_version_message, NULL);
|
||||
|
||||
skipstone_message_service_run(service, link);
|
||||
|
||||
skipstone_link_close(link);
|
||||
|
||||
return 0;
|
||||
|
||||
error_message_service_new:
|
||||
skipstone_link_close(link);
|
||||
|
||||
error_link_open:
|
||||
return 1;
|
||||
}
|
53
examples/test.c-e
Normal file
53
examples/test.c-e
Normal file
|
@ -0,0 +1,53 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <skipstone/link.h>
|
||||
#include <skipstone/message.h>
|
||||
|
||||
static void usage(int argc, char **argv) {
|
||||
fprintf(stderr, "usage: %s /dev/rfcommX\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static int answer_phone_version_message(skipstone_message_service *service,
|
||||
void *buf, uint16_t size, uint16_t id) {
|
||||
uint8_t response[12] = {
|
||||
0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02
|
||||
};
|
||||
|
||||
skipstone_message_service_queue(service, &response, sizeof(response), id);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
skipstone_link *link;
|
||||
skipstone_message_service *service;
|
||||
|
||||
if (argc != 2) {
|
||||
usage(argc, argv);
|
||||
}
|
||||
|
||||
if ((link = skipstone_link_open_serial(argv[1])) == NULL) {
|
||||
goto error_link_open;
|
||||
}
|
||||
|
||||
if ((service = skipstone_message_service_new()) == NULL) {
|
||||
goto error_message_service_new;
|
||||
}
|
||||
|
||||
skipstone_message_service_register(service, 17, answer_phone_version_message, NULL);
|
||||
|
||||
skipstone_message_service_run(service, link);
|
||||
|
||||
skipstone_link_close(link);
|
||||
|
||||
return 0;
|
||||
|
||||
error_message_service_new:
|
||||
skipstone_link_close(link);
|
||||
|
||||
error_link_open:
|
||||
return 1;
|
||||
}
|
|
@ -7,9 +7,9 @@ CC = $(CROSS)cc
|
|||
CFLAGS += -fPIC -I$(INCLUDE_PATH)
|
||||
LDFLAGS =
|
||||
|
||||
HEADERS = watch.h link.h map.h message.h
|
||||
HEADERS = watch.h link.h map.h message.h queue.h
|
||||
|
||||
OBJS = watch.o link.o map.o message.o
|
||||
OBJS = watch.o link.o map.o message.o queue.o
|
||||
|
||||
VERSION_MAJOR = 0
|
||||
VERSION_MINOR = 0.1
|
||||
|
|
|
@ -35,7 +35,7 @@ size_t skipstone_queue_count(skipstone_queue *queue) {
|
|||
int skipstone_queue_push(skipstone_queue *queue, void *value) {
|
||||
struct entry *next;
|
||||
|
||||
if ((next = malloc(sizeof(*entry))) == NULL) {
|
||||
if ((next = malloc(sizeof(*next))) == NULL) {
|
||||
goto error_malloc_next;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ size_t skipstone_queue_count(skipstone_queue *queue) {
|
|||
int skipstone_queue_push(skipstone_queue *queue, void *value) {
|
||||
struct entry *next;
|
||||
|
||||
if ((next = malloc(sizeof(*entry))) == NULL) {
|
||||
if ((next = malloc(sizeof(*next))) == NULL) {
|
||||
goto error_malloc_next;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue