summaryrefslogtreecommitdiff
path: root/cesar/maximus/python/tools/csi/csiavln.py
blob: 01b3190abdb9ba864472143de1dff4e259bd15f1 (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
from csistation import *

class csiAvln:

    def __init__ (self, npw, ahfid):
        self.__npw = npw
        self.__ahfid = ahfid
        self.__hp_sta_max = 254
        self.__sta_list = list()

    def get_ahfid (self):
        return self.__ahfid

    def get_npw (self):
        return self.__npw

    def get_nb_sta (self):
        return len(self.__sta_list)

    def get_sta (self, index):
        if index < self.get_nb_sta():
            return self.__sta_list[index]
        else:
            return None

    def sta_exists (self, sta):
	return (self.__sta_list.count (sta) == 1)

    def sta_add (self, mac_addr, cco_pref, was_cco, dpw, mhfid, uhfid, sl, debug, delay_ms = 0):
        if self.__hp_sta_max <= self.get_nb_sta():
            return None

        if len (dpw) < 16 or len (dpw) > 64:
            raise Exception ("Device password wrong length, must be at least 16 characters at most 64")

        for i in range (0, self.get_nb_sta()):
            if (self.get_sta(i).get_mac_addr() == mac_addr):
                return None

        if len (self.__sta_list) > 0:
            if self.__sta_list[len(self.__sta_list) -1].get_delay_ms() > delay_ms:
                raise Exception ('Delay value smaller than the previous	station delay')

            sta = csiSta (mac_addr, cco_pref, was_cco, self.get_npw(), dpw, mhfid, uhfid, self.get_ahfid(), sl, debug, delay_ms)
            self.__sta_list.append (sta)
            return sta

    def sta_remove (self, mac_addr):

        for i in range (0, self.get_nb_sta()):
            sta = self.get_sta(i)
            if sta.get_mac_addr () == mac_addr:
                self.__sta_list.remove (sta)
                break