summaryrefslogtreecommitdiffstats
path: root/example/mm.c
blob: af7101102d07248a9dbd76a38b597209c6114e14 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dect/libdect.h>
#include "common.h"

enum phones { PHONE1, PHONE2, PHONE3, };
static const struct dect_ipui ipuis[] = {
	[PHONE1] = {
		.put		= DECT_IPUI_N,
		.pun.n.ipei = {
			.emc	= 0x08ae,
			.psn	= 0x83d1e,
		},
	},
	[PHONE2] = {
		.put		= DECT_IPUI_N,
		.pun.n.ipei = {
			.emc	= 0x08ae,
			.psn	= 0x8969f,
		},
	},
	[PHONE3] = {
		.put		= DECT_IPUI_N,
		.pun.n.ipei = {
			.emc	= 0x08ae,
			.psn	= 0x5b9a0,
		},
	},
};

static const struct dect_mm_ops mm_ops = {
	.mm_access_rights_ind	= 0,
	.mm_access_rights_cfm	= 0,
};

static int mm_access_rights_request(struct dect_handle *dh)
{
	struct dect_ie_portable_identity portable_identity;
	struct dect_mm_access_rights_param param = {
		.portable_identity	= &portable_identity,
	};

	dect_ie_init(&portable_identity);
	portable_identity.type = ID_TYPE_IPUI;
	portable_identity.ipui = ipuis[PHONE1];

	return dect_mm_access_rights_req(dh, &param);
}

static struct dect_ops ops = {
	.mm_ops			= &mm_ops,
};

int main(int argc, char **argv)
{
	if (dect_event_ops_init(&ops) < 0)
		exit(1);

	dh = dect_alloc_handle(&ops);
	if (dh == NULL)
		exit(1);

	if (dect_init(dh) < 0)
		exit(1);

	if (mm_access_rights_request(dh) < 0)
		exit(1);

	dect_event_loop();
	dect_close_handle(dh);
	dect_event_ops_cleanup();
	return 0;
}