summaryrefslogtreecommitdiffstats
path: root/python/PythonXPA/server/test_XPAS.py
blob: fe4f1a24becb69144b7f7641478b702a3581675c (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/python

################################
####### testing:               #
################################

from XPAServer import *

import time

print "Poll"
n = x.XPAPoll(10000, 0)
print "got %d" % n

EXIT_FLAG = False


##############################
#    setting up Info Point   #
##############################

def py_infocb_func(a, b, c):
    global EXIT_FLAG
    print ">>> INFO:"
    print "params:", c
    print "info:", a
    print "XPA.name", b[0].name
    print "<<<" 
    if (c[0:4] == "exit"):
        print "setting EXIT_FLAG" 
        EXIT_FLAG = True
    return 0

infocb_func = INFOCBFUNC(py_infocb_func)

xpa = XPAInfoNew("XPA", "i_test", infocb_func, "my info", "")

##############################




#######################################
#    setting up  AccessPoint Get/Set  #
#######################################

def py_sendcb_func(data, call_data, param, buf, len):
   print "inside send_callback"
   print "param:", param
   print "buf:", string_at(buf)
   buf[0] = cast("this is test only\n", c_byte_p)
   len[0] = 19
   return 0

sendcb_func = SENDCBFUNC(py_sendcb_func)


def py_rcvcb_func(data, call_data, param, buf, len):
   print "inside rcv_callback"
   print "param:", param
   print "got %d bytes" % len
   print "buf:", string_at(buf)
   return 0

rcvcb_func = RCVCBFUNC(py_rcvcb_func)


xpa2 = XPANew("XPA", "myxpa", "this is great help", 
              sendcb_func,
              "SEND_DATA", "freebuf=false",
              rcvcb_func,
              "", "")





##############################
print "Entering loop"

while EXIT_FLAG == False:
    n = XPAPoll(1000, 1)
    print "got:", n

print "loop finished"
##############################


print "calling XPAFree"
XPAFree(xpa)
XPAFree(xpa2)