aboutsummaryrefslogtreecommitdiff
path: root/src/survive.c
blob: 223cd5745d201807e5deac9b6e8cc7c3e4fb8bdc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//Copyright 2016 <>< C. N. Lohr, FULLY Under MIT/x11 License.
//All MIT/x11 Licensed Code in this file may be relicensed freely under the GPL or LGPL licenses.

#include <survive.h>
#include "survive_internal.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct SurviveContext * survive_init( void(*ff)( struct SurviveContext * ctx, const char * fault ), void(*notefunction)( struct SurviveContext * ctx, const char * note ) )
{
	int r = 0;
	struct SurviveContext * ret = calloc( 1, sizeof( struct SurviveContext  ) );

	ret->headset.sensors = 32;
	ret->headset.ctx = ret;
	memcpy( ret->headset.codename, "HED", 4 );

	ret->watchman[0].sensors = 16;
	ret->watchman[0].ctx = ret;
	memcpy( ret->watchman[0].codename, "CT0", 4 );

	ret->watchman[1].sensors = 16;
	ret->watchman[1].ctx = ret;
	memcpy( ret->watchman[1].codename, "CT1", 4 );


	ret->faultfunction = ff;
	ret->notefunction = notefunction;

	//USB must happen last.
	if( r = survive_usb_init( ret ) )
	{
		return 0;
	}

	//ret->headset->photos = malloc( ret->headset->sensors * sizeof(struct SurvivePhoto) );
	return ret;
}


void survive_close( struct SurviveContext * ctx )
{
	survive_usb_close( ctx );
}

int survive_poll( struct SurviveContext * ctx )
{
	survive_usb_poll( ctx );
}