3737LORA_CLICK_BANDWIDTH_500KHZ = 2
3838
3939class LoraClickConfig (ctypes .Structure ):
40+ """Lora Click configuration"""
4041 _fields_ = [
4142 ("frequency" , ctypes .c_uint32 ),
4243 ("spreading_factor" , ctypes .c_uint8 ),
@@ -54,23 +55,56 @@ class LoraClickConfig(ctypes.Structure):
5455_LIB .lora_click_get_default_configuration .restype = LoraClickConfig
5556
5657def get_default_configuration ():
57- """Returns default configuration."""
58+ """Returns default configuration:
59+
60+ frequency = 868000000
61+ spreading_factor = 12
62+ auto_freq_band = LORA_CLICK_AUTO_FREQ_BAND_125KHZ
63+ coding_rate = LORA_CLICK_CODING_RATE_4_8
64+ bandwidth = LORA_CLICK_BANDWIDTH_250KHZ
65+ power = 14
66+ bitrate = 5000
67+ freq_deviation = 5000
68+ preamble_length = 8
69+ enable_crc_header = true
70+ """
5871 return _LIB .lora_click_get_default_configuration ()
5972
6073
6174def init (mikrobus_index , config ):
75+ """Initialize the Lora Click and configure it.
76+
77+ mikrobus_index: 0 (MIKROBUS_1) or 1 (MIKROBUS_2)
78+ config: Configuration of the Lora Click
79+
80+ Note: An exception is thrown if it fails to initialize the Lora Click.
81+ """
6282 ret = _LIB .lora_click_init (mikrobus_index , config )
6383 if ret < 0 :
6484 raise Exception ("" )
6585
6686
6787def configure (config ):
88+ """Configure the Lora Click
89+
90+ config: Configuration of the Lora Click
91+
92+ Note: An exception is thrown if it fails to configure the Lora Click.
93+ """
6894 ret = _LIB .lora_click_configure (config )
6995 if ret < 0 :
7096 raise Exception ("" )
7197
7298
7399def send (data ):
100+ """Send a list of bytes
101+
102+ data: list of bytes
103+
104+ This is a blocking call.
105+
106+ Note: An exception is thrown if it fails to send all bytes.
107+ """
74108 length = len (data )
75109 tx_buffer = (ctypes .c_uint8 * length )(* data )
76110 ret = _LIB .lora_click_send (tx_buffer , length )
@@ -79,6 +113,15 @@ def send(data):
79113
80114
81115def receive (length ):
116+ """Receive a list of bytes
117+
118+ length: Number of bytes to receive
119+
120+ This is a blocking call, it will not return until the number of requested
121+ bytes has been received.
122+
123+ Note: An exception is thrown if it fails to receive all bytes.
124+ """
82125 rx_buffer = (ctypes .c_uint8 * length )()
83126 ret = _LIB .lora_click_receive (rx_buffer , length )
84127 if ret < 0 :
@@ -87,6 +130,13 @@ def receive(length):
87130
88131
89132def write_eeprom (start_address , data ):
133+ """Write some bytes in EEPROM
134+
135+ start_address: Must be in range 0x300-0x3FF
136+ data: A list of bytes to write
137+
138+ Note: An exception is thrown if it fails to write bytes to the EEPROM.
139+ """
90140 length = len (data )
91141 tmp = (ctypes .c_uint8 * length )(* data )
92142 ret = _LIB .lora_click_write_eeprom (start_address , tmp , length )
@@ -95,6 +145,13 @@ def write_eeprom(start_address, data):
95145
96146
97147def read_eeprom (start_address , length ):
148+ """Read a list of bytes from EEPROM
149+
150+ start_address: Must be in range 0x300-0x3FF
151+ length: Number of bytes to read
152+
153+ Note: An exception is thrown if it fails to read bytes from the EEPROM.
154+ """
98155 data = (ctypes .c_uint8 * length )()
99156 ret = _LIB .lora_click_read_eeprom (start_address , data , length )
100157 if ret < 0 :
@@ -103,6 +160,13 @@ def read_eeprom(start_address, length):
103160
104161
105162def get_eui ():
163+ """Read the EUI from the Lora Click
164+
165+ This function returns a list of 8 bytes representing the EUI of the
166+ device.
167+
168+ Note: An exception is thrown if it fails to read the EUI.
169+ """
106170 eui = (ctypes .c_uint8 * 8 )()
107171 ret = _LIB .lora_click_get_eui (eui )
108172 if ret < 0 :
0 commit comments