You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Pygate is an 8-channel LoRaWAN gateway. You connect a WiPy or Gpy board to the Pygate and flash a firmware build where the Pygate functionality is enabled. See the [Pygate tutorial](/tutorials/all/pygate) to get started.
10
+
11
+
## Methods
12
+
13
+
#### machine.pygate\_init(buff)
14
+
15
+
This function is used to initialize the Pygate
16
+
17
+
-`buff`: the data contents of the gateway global config json file
The ETH class enables the use of an ethernet connection via the PyEthernet board plugged into a Pygate.
10
+
11
+
---
12
+
*NOTE* :
13
+
Ethernet support is only available in special Gpy or WiPy firmware builds where this feature has been enabled.
14
+
15
+
---
16
+
17
+
## Constructors
18
+
19
+
### class network.ETH(id=0, ...)
20
+
21
+
Create and configure an ETH object. See init for params of configuration.
22
+
23
+
```python
24
+
from network importETH
25
+
eth = ETH()
26
+
```
27
+
28
+
## Methods
29
+
30
+
31
+
### eth.init(hostname=None)
32
+
33
+
This function starts the Ethernet interface and enables the ethernet adapter.
34
+
35
+
`hostname`: set the interface hostname
36
+
37
+
### eth.ifconfig(config=\['dhcp' or configtuple\])
38
+
39
+
With no parameters given, this returns a 4-tuple of (ip, subnet mask, gateway, DNS server).
40
+
41
+
Optionally specify the configuration parameter:
42
+
43
+
-`config='dhcp'`
44
+
45
+
If 'dhcp' is passed as a parameter, then the DHCP client is enabled and the IP parameters are negotiated with the DHCP server.
46
+
47
+
-`config=(ip, nm, gw, dns)`
48
+
49
+
If the 4-tuple config is given then a static IP is configured. For example: `eth.ifconfig(config=('192.168.0.4', '255.255.255.0', '192.168.0.1', '8.8.8.8'))`.
50
+
51
+
### eth.hostname(string)
52
+
53
+
Set the interface host name.
54
+
55
+
### eth.mac()
56
+
57
+
Get the ethernet interface mac address.
58
+
59
+
### eth.deinit()
60
+
61
+
Shuts down the ethernet interface.
62
+
63
+
### eth.isconnected()
64
+
65
+
Returns `True` if the ethernet link is up and IP is accquired, `False` otherwise.
__To connect your Pygate to a LoRa server, follow these steps:__
3
+
The Pygate is an 8-channel LoRaWAN gateway. This page will help you get started with it.
4
4
5
-
1- Attach a Pycom development board e.g. a Wipy, LoPy4, GPy, to the Pygate. (The RGB LED of the development board should be aligned with the USB port of PyGate)
5
+
### Quickstart
6
6
7
-
2- Attach the LoRa Antenna to the Pygate
7
+
To connect your Pygate to a LoRa server, follow these steps:
8
8
9
-
3- Flash the Pycom Device with latest PyGate Firmware.
9
+
1. Attach a Wipy, or GPy to the Pygate. The RGB LED of the development board should be aligned with the USB port of the Pygate.
10
+
1. Attach the LoRa Antenna to the Pygate.
11
+
1. Flash the Pycom Device with with a firmware build where Pygate functionality is enabled.
12
+
1. Create a `config.json` for your Pygate and upload it.
13
+
1. Create a `main.py` that creates an uplink and runs the Pygate packet fowarder.
14
+
1. Run the `main.py`.
15
+
1. Now it is operational. The communication from other LoRa nodes such as a LoPy4 will now reach the gateway and will receive up and downlink via the PyGate.
16
+
1. To stop the Pygate at any time press Ctrl-C on the REPL and run `machine.pygate_deinit()`. It will take a few seconds to stop the gateway tasks and safely power-off the concentrator.
10
17
11
-
4- Upload the Gateway configuration json file onto the attached Pycom device (via Pymakr on Atom or VSCode). Depending on the type of Pygate (EU868/US915) you should have different config files.
12
18
13
-
__The following example will demonstrate a simple script for getting started with a Pygate via a Wifi connection for the EU868 region:__
19
+
Make sure you supply a config matching your region (EU868, US915, etc), e.g. https://github.com/Lora-net/packet_forwarder/tree/master/lora_pkt_fwd/cfg. If you are in EU region, it should be sufficent to update the example below with your GW ID, the LoRa server address and port number.
20
+
21
+
22
+
### Example TTN Wifi
23
+
24
+
The following example shows the script and json file to run the Pygate over Wifi connecting to [The Things Network](https://www.thethingsnetwork.org/).
25
+
26
+
* log in to https://console.thethingsnetwork.org/
27
+
* go to Gateways and register a new gateway
28
+
* select "I'm using a legacy packet forwarder"
29
+
* enter a EUI (8 byte hexadecimal value) - also enter this in your `config.json` for `gateway_ID` (Just enter the digits without the "eui-" prefix)
30
+
* select your Frequency Plan
31
+
* select a router - also enter the hostname in your `config.json` for `server_address`
32
+
* enter your wifi SSID and password in `main.py`
33
+
14
34
15
-
You can use the same file, just enter your GW unique ID, the LoRa server address and port numbers.
#Sync time via NTP server for GW timestamps on Events
71
+
#Sync time via NTP server for GW timestamps on Events
54
72
rtc = RTC()
55
73
rtc.ntp_sync(server="0.nl.pool.ntp.org")
56
74
57
-
#Read the GW config file from Filesystem
75
+
#Read the GW config file from Filesystem
58
76
fp =open('/flash/config.json','r')
59
77
buf = fp.read()
60
78
61
-
# Start Pygate
79
+
# Start the Pygate
62
80
machine.pygate_init(buf)
63
81
64
82
```
65
83
66
-
A sample Config json file for GW configuration on EU868 region:
84
+
A sample `config.json` file for gateway configuration in EU868 region:
67
85
68
86
```json
69
87
{
@@ -253,132 +271,3 @@ A sample Config json file for GW configuration on EU868 region:
253
271
}
254
272
}
255
273
```
256
-
To stop the Pygate at any time use:
257
-
258
-
- REPL -> use CTRL-C
259
-
- using deinit function `machine.pygate_deinit()`
260
-
261
-
This will stop GW tasks and safely power-off the Concentrator.
262
-
263
-
264
-
__Note__: The Pygate packet forwarder is a legacy packet forwarder, so you must make sure you use select the legacy packet forwarder option in TTN as shown below.
-`buff`: the data contents of the gateway global config json file
278
-
279
-
When no parameter is passed to function the Pygate is just powered on. (will be useful when using pygate as just a concentrator controllable via uart by another device eg. RPi)
280
-
281
-
#### machine.pygate\_deinit()
282
-
283
-
This shuts down the concentrator.
284
-
285
-
#### machine.pygate\_cmd\_decode(buff)
286
-
287
-
This sends the LoRa gateway command to the concentrator. This is useful when packet forwarder / HAL software is run on a different device (e.g. Rpi) and commands to the concentrator are passed to the Pygate via UART.
288
-
289
-
#### machine.pygate\_cmd\_get()
290
-
291
-
This gets the command execution result from concentrator.
292
-
293
-
An example script demonstrating running packet forwarder software on a different device:
0 commit comments