gcartlidge / biostarPython

biostarPython - Suprema GSDK package for python.
MIT License
2 stars 1 forks source link

Python Client for Suprema GSDK

This is the pip distributable version of the Suprema GSDK Python client, which makes it easier to interact with the GSDK.

The examples from the Suprema GSDK Wiki can be used, but with this package, all dependencies are handled via PIP. The EventCode .json file and device list are also initialized automatically when importing package.

Tips

On some clients (Particularly android) the EventCode json can sometimes not be loaded. If this happens, an error will display. You can then call

JsonFileLocation = "C:\\biostarPython\\event_code.json"
biostarPython.initCodeMap(JsonFileLocation)

To check Event codes, call

biostarPython.getEventString(eventCode,subCode)

To check device type, call

biostarPython.deviceType[deviceCode]

I'd also recommend checking out Advanced Installer! They allow free licences for open-source projects and the features of the program licences are well worth it!

How to use the rest of the classes.

All classes that can be used are imported under the biostarPython package. The ones currently written are:
GatewayClient, ConnectSvc, DeviceSvc, FaceSvc, FingerSvc, StatusSvc, UserSvc, DisplaySvc, AdminSvc, WiegandSvc, TimeSvc, CardSvc, EventSvc, NetworkSvc, ServerSvc, SystemSvc, DoorSvc, RS485Svc, AuthSvc, AccessSvc, ScheduleSvc, ActionSvc, TNASvc, OperatorSvc, LockZoneSvc, TimedAPBZoneSvc, APBZoneSvc, IntrusionZoneSvc, FireZoneSvc, InterlockZoneSvc, UDPSvc & TestSvc

With the remaining being added in a future release. I think im up to date!

With all of these services, they are a callable class underneath the biostarPython package. An example of initial setup with the GatewayClient and ConnectSvc is below: For all of the functions below these services, they are formated with the first letter in lowercase, so to search a device would be searchDevice(), to get info would be getInfo().
The guides on how to use these are present at the the GSDK Homepage

# import the service duh!
import biostarPython as g
# connect to the gateway, get a channel, then funnel this through to the 
# services!
gateway = g.GatewayClient('127.0.0.1',4000,'ca.crt')
channel = gateway.getChannel()
connect = g.ConnectSvc(channel)
face = g.FaceSvc(channel)
network = g.NetworkSvc(channel)
# will return a list of devices visible on UDP
deviceInfo = connect.searchDevice(300) 
# needs IP address, port and SSL state
bs3 = connect.connect(connect.getConnInfo('192.168.0.50', 51211, False))
# 4 is the default scan threshold
face.scan(bs3,4)
#lets get and change an IP Config
existingConfig = network.getIPConfig(bs3)
existingConfig.useDHCP = False
existingConfig.IPAddress = '192.168.0.20'
network.setIPConfig(bs3, existingConfig)

All of the specific APIs can be found at the wiki Above.

changelog