Versions in this module Expand all Collapse all v1 v1.0.2 Jul 4, 2018 v1.0.1 May 30, 2018 v1.0.0 May 28, 2018 Changes in this version + const ModulationFSK + const ModulationLoRa + var ErrAlreadyExists = errors.New("object already exists") + var ErrApplicationInvalidName = errors.New("invalid application name") + var ErrCFListTooManyChannels = errors.New("too many channels in channel-list") + var ErrDoesNotExist = errors.New("object does not exist") + var ErrGatewayInvalidName = errors.New("invalid gateway name") + var ErrInvalidEmail = errors.New("invalid e-mail") + var ErrInvalidGatewayDiscoveryInterval = errors.New("invalid gateway-discovery interval, it must be greater than 0") + var ErrInvalidUsernameOrPassword = errors.New("invalid username or password") + var ErrNodeInvalidName = errors.New("invalid node name") + var ErrNodeMaxRXDelay = errors.New("max value of RXDelay is 15") + var ErrOrganizationInvalidName = errors.New("invalid organization name") + var ErrUsedByOtherObjects = errors.New("this object is used by other objects, remove them first") + var ErrUserInvalidUsername = errors.New(...) + var ErrUserPasswordLength = errors.New("passwords must be at least 6 characters long") + var HashIterations = 100000 + func CreateApplication(db sqlx.Queryer, item *Application) error + func CreateDevice(db sqlx.Ext, d *Device) error + func CreateDeviceActivation(db sqlx.Queryer, da *DeviceActivation) error + func CreateDeviceKeys(db sqlx.Execer, dc *DeviceKeys) error + func CreateDeviceProfile(db sqlx.Ext, dp *DeviceProfile) error + func CreateDeviceQueueMapping(db sqlx.Queryer, dqm *DeviceQueueMapping) error + func CreateGateway(db sqlx.Execer, gw *Gateway) error + func CreateGatewayPing(db sqlx.Queryer, ping *GatewayPing) error + func CreateGatewayPingRX(db sqlx.Queryer, rx *GatewayPingRX) error + func CreateGatewayProfile(db sqlx.Ext, gp *GatewayProfile) error + func CreateIntegration(db sqlx.Queryer, i *Integration) error + func CreateNetworkServer(db sqlx.Queryer, n *NetworkServer) error + func CreateOrganization(db sqlx.Queryer, org *Organization) error + func CreateOrganizationUser(db sqlx.Execer, organizationID, userID int64, isAdmin bool) error + func CreateServiceProfile(db sqlx.Ext, sp *ServiceProfile) error + func CreateUser(db sqlx.Queryer, user *User, password string) (int64, error) + func DeleteAllApplicationsForOrganizationID(db sqlx.Ext, organizationID int64) error + func DeleteAllDeviceProfilesForOrganizationID(db sqlx.Ext, organizationID int64) error + func DeleteAllDevicesForApplicationID(db sqlx.Ext, applicationID int64) error + func DeleteAllGatewaysForOrganizationID(db sqlx.Ext, organizationID int64) error + func DeleteAllServiceProfilesForOrganizationID(db sqlx.Ext, organizationID int64) error + func DeleteApplication(db sqlx.Ext, id int64) error + func DeleteDevice(db sqlx.Ext, devEUI lorawan.EUI64) error + func DeleteDeviceKeys(db sqlx.Execer, devEUI lorawan.EUI64) error + func DeleteDeviceProfile(db sqlx.Ext, id string) error + func DeleteDeviceQueueMapping(db sqlx.Execer, id int64) error + func DeleteGateway(db sqlx.Ext, mac lorawan.EUI64) error + func DeleteGatewayProfile(db sqlx.Ext, id string) error + func DeleteIntegration(db sqlx.Execer, id int64) error + func DeleteNetworkServer(db sqlx.Ext, id int64) error + func DeleteOrganization(db sqlx.Ext, id int64) error + func DeleteOrganizationUser(db sqlx.Execer, organizationID, userID int64) error + func DeleteServiceProfile(db sqlx.Ext, id string) error + func DeleteUser(db sqlx.Execer, id int64) error + func FlushDeviceQueueMappingForDevEUI(db sqlx.Execer, devEUI lorawan.EUI64) error + func GetApplicationCount(db sqlx.Queryer, search string) (int, error) + func GetApplicationCountForOrganizationID(db sqlx.Queryer, organizationID int64, search string) (int, error) + func GetApplicationCountForUser(db sqlx.Queryer, username string, organizationID int64, search string) (int, error) + func GetDeviceCountForApplicationID(db sqlx.Queryer, applicationID int64, search string) (int, error) + func GetDeviceProfileCount(db sqlx.Queryer) (int, error) + func GetDeviceProfileCountForApplicationID(db sqlx.Queryer, applicationID int64) (int, error) + func GetDeviceProfileCountForOrganizationID(db sqlx.Queryer, organizationID int64) (int, error) + func GetDeviceProfileCountForUser(db sqlx.Queryer, username string) (int, error) + func GetGatewayCount(db sqlx.Queryer, search string) (int, error) + func GetGatewayCountForOrganizationID(db sqlx.Queryer, organizationID int64, search string) (int, error) + func GetGatewayCountForUser(db sqlx.Queryer, username string, search string) (int, error) + func GetGatewayProfileCount(db sqlx.Queryer) (int, error) + func GetGatewayProfileCountForNetworkServerID(db sqlx.Queryer, networkServerID int64) (int, error) + func GetLastGatewayPingAndRX(db sqlx.Queryer, mac lorawan.EUI64) (GatewayPing, []GatewayPingRX, error) + func GetNetworkServerCount(db sqlx.Queryer) (int, error) + func GetNetworkServerCountForOrganizationID(db sqlx.Queryer, organizationID int64) (int, error) + func GetOrganizationCount(db sqlx.Queryer, search string) (int, error) + func GetOrganizationCountForUser(db sqlx.Queryer, username string, search string) (int, error) + func GetOrganizationUserCount(db sqlx.Queryer, organizationID int64) (int, error) + func GetServiceProfileCount(db sqlx.Queryer) (int, error) + func GetServiceProfileCountForOrganizationID(db sqlx.Queryer, organizationID int64) (int, error) + func GetServiceProfileCountForUser(db sqlx.Queryer, username string) (int, error) + func GetUserCount(db sqlx.Queryer, search string) (int32, error) + func LoginUser(db sqlx.Queryer, username string, password string) (string, error) + func NewRedisPool(redisURL string) *redis.Pool + func OpenDatabase(dsn string) (*common.DBLogger, error) + func SetUserSecret(s string) + func Transaction(db *common.DBLogger, f func(tx sqlx.Ext) error) error + func UpdateApplication(db sqlx.Execer, item Application) error + func UpdateDevice(db sqlx.Ext, d *Device) error + func UpdateDeviceKeys(db sqlx.Execer, dc *DeviceKeys) error + func UpdateDeviceProfile(db sqlx.Ext, dp *DeviceProfile) error + func UpdateGateway(db sqlx.Execer, gw *Gateway) error + func UpdateGatewayProfile(db sqlx.Ext, gp *GatewayProfile) error + func UpdateIntegration(db sqlx.Execer, i *Integration) error + func UpdateNetworkServer(db sqlx.Execer, n *NetworkServer) error + func UpdateOrganization(db sqlx.Execer, org *Organization) error + func UpdateOrganizationUser(db sqlx.Execer, organizationID, userID int64, isAdmin bool) error + func UpdatePassword(db sqlx.Execer, id int64, newpassword string) error + func UpdateServiceProfile(db sqlx.Ext, sp *ServiceProfile) error + func UpdateUser(db sqlx.Execer, item UserUpdate) error + func ValidateEmail(email string) error + func ValidatePassword(password string) error + func ValidateUsername(username string) error + type Action int + const Delete + const Insert + const Scan + const Select + const Update + type Application struct + Description string + ID int64 + Name string + OrganizationID int64 + PayloadCodec codec.Type + PayloadDecoderScript string + PayloadEncoderScript string + ServiceProfileID string + func GetApplication(db sqlx.Queryer, id int64) (Application, error) + func (a Application) Validate() error + type ApplicationListItem struct + ServiceProfileName string + func GetApplications(db sqlx.Queryer, limit, offset int, search string) ([]ApplicationListItem, error) + func GetApplicationsForOrganizationID(db sqlx.Queryer, organizationID int64, limit, offset int, search string) ([]ApplicationListItem, error) + func GetApplicationsForUser(db sqlx.Queryer, username string, organizationID int64, limit, offset int, ...) ([]ApplicationListItem, error) + type Device struct + ApplicationID int64 + CreatedAt time.Time + Description string + DevEUI lorawan.EUI64 + DeviceProfileID string + DeviceStatusBattery *int + DeviceStatusMargin *int + LastSeenAt *time.Time + Name string + SkipFCntCheck bool + UpdatedAt time.Time + func GetDevice(db sqlx.Queryer, devEUI lorawan.EUI64) (Device, error) + func (d Device) Validate() error + type DeviceActivation struct + AppSKey lorawan.AES128Key + CreatedAt time.Time + DevAddr lorawan.DevAddr + DevEUI lorawan.EUI64 + ID int64 + NwkSKey lorawan.AES128Key + func GetLastDeviceActivationForDevEUI(db sqlx.Queryer, devEUI lorawan.EUI64) (DeviceActivation, error) + type DeviceKeys struct + AppKey lorawan.AES128Key + CreatedAt time.Time + DevEUI lorawan.EUI64 + JoinNonce int + UpdatedAt time.Time + func GetDeviceKeys(db sqlx.Queryer, devEUI lorawan.EUI64) (DeviceKeys, error) + type DeviceListItem struct + DeviceProfileName string + func GetDevicesForApplicationID(db sqlx.Queryer, applicationID int64, limit, offset int, search string) ([]DeviceListItem, error) + type DeviceProfile struct + CreatedAt time.Time + DeviceProfile backend.DeviceProfile + Name string + NetworkServerID int64 + OrganizationID int64 + UpdatedAt time.Time + func GetDeviceProfile(db sqlx.Queryer, id string) (DeviceProfile, error) + func (dp DeviceProfile) Validate() error + type DeviceProfileMeta struct + CreatedAt time.Time + DeviceProfileID string + Name string + NetworkServerID int64 + OrganizationID int64 + UpdatedAt time.Time + func GetDeviceProfiles(db sqlx.Queryer, limit, offset int) ([]DeviceProfileMeta, error) + func GetDeviceProfilesForApplicationID(db sqlx.Queryer, applicationID int64, limit, offset int) ([]DeviceProfileMeta, error) + func GetDeviceProfilesForOrganizationID(db sqlx.Queryer, organizationID int64, limit, offset int) ([]DeviceProfileMeta, error) + func GetDeviceProfilesForUser(db sqlx.Queryer, username string, limit, offset int) ([]DeviceProfileMeta, error) + type DeviceQueueMapping struct + CreatedAt time.Time + DevEUI lorawan.EUI64 + FCnt uint32 + ID int64 + Reference string + func GetDeviceQueueMappingForDevEUIAndFCnt(db sqlx.Ext, devEUI lorawan.EUI64, fCnt uint32) (DeviceQueueMapping, error) + type ExtraChannel struct + Bandwidth int + Bitrate int + Frequency int + Modulation string + SpreadingFactors []int + type GPSPoint struct + Latitude float64 + Longitude float64 + func (l *GPSPoint) Scan(src interface{}) error + func (l GPSPoint) Value() (driver.Value, error) + type Gateway struct + CreatedAt time.Time + Description string + GatewayProfileID *string + LastPingID *int64 + LastPingSentAt *time.Time + MAC lorawan.EUI64 + Name string + NetworkServerID int64 + OrganizationID int64 + Ping bool + UpdatedAt time.Time + func GetGateway(db sqlx.Queryer, mac lorawan.EUI64, forUpdate bool) (Gateway, error) + func GetGateways(db sqlx.Queryer, limit, offset int, search string) ([]Gateway, error) + func GetGatewaysForOrganizationID(db sqlx.Queryer, organizationID int64, limit, offset int, search string) ([]Gateway, error) + func GetGatewaysForUser(db sqlx.Queryer, username string, limit, offset int, search string) ([]Gateway, error) + func (g Gateway) Validate() error + type GatewayPing struct + CreatedAt time.Time + DR int + Frequency int + GatewayMAC lorawan.EUI64 + ID int64 + func GetGatewayPing(db sqlx.Queryer, id int64) (GatewayPing, error) + type GatewayPingRX struct + Altitude float64 + CreatedAt time.Time + GatewayMAC lorawan.EUI64 + ID int64 + LoRaSNR float64 + Location GPSPoint + PingID int64 + RSSI int + ReceivedAt *time.Time + func GetGatewayPingRXForPingID(db sqlx.Queryer, pingID int64) ([]GatewayPingRX, error) + type GatewayProfile struct + Channels []int + CreatedAt time.Time + ExtraChannels []ExtraChannel + GatewayProfileID string + Name string + NetworkServerID int64 + UpdatedAt time.Time + func GetGatewayProfile(db sqlx.Queryer, id string) (GatewayProfile, error) + type GatewayProfileMeta struct + CreatedAt time.Time + GatewayProfileID string + Name string + NetworkServerID int64 + UpdatedAt time.Time + func GetGatewayProfiles(db sqlx.Queryer, limit, offset int) ([]GatewayProfileMeta, error) + func GetGatewayProfilesForNetworkServerID(db sqlx.Queryer, networkServerID int64, limit, offset int) ([]GatewayProfileMeta, error) + type Integration struct + ApplicationID int64 + CreatedAt time.Time + ID int64 + Kind string + Settings json.RawMessage + UpdatedAt time.Time + func GetIntegration(db sqlx.Queryer, id int64) (Integration, error) + func GetIntegrationByApplicationID(db sqlx.Queryer, applicationID int64, kind string) (Integration, error) + func GetIntegrationsForApplicationID(db sqlx.Queryer, applicationID int64) ([]Integration, error) + type NetworkServer struct + CACert string + CreatedAt time.Time + GatewayDiscoveryDR int + GatewayDiscoveryEnabled bool + GatewayDiscoveryInterval int + GatewayDiscoveryTXFrequency int + ID int64 + Name string + RoutingProfileCACert string + RoutingProfileTLSCert string + RoutingProfileTLSKey string + Server string + TLSCert string + TLSKey string + UpdatedAt time.Time + func GetNetworkServer(db sqlx.Queryer, id int64) (NetworkServer, error) + func GetNetworkServerForDevEUI(db sqlx.Queryer, devEUI lorawan.EUI64) (NetworkServer, error) + func GetNetworkServerForDeviceProfileID(db sqlx.Queryer, id string) (NetworkServer, error) + func GetNetworkServerForGatewayMAC(db sqlx.Queryer, mac lorawan.EUI64) (NetworkServer, error) + func GetNetworkServerForGatewayProfileID(db sqlx.Queryer, id string) (NetworkServer, error) + func GetNetworkServerForServiceProfileID(db sqlx.Queryer, id string) (NetworkServer, error) + func GetNetworkServers(db sqlx.Queryer, limit, offset int) ([]NetworkServer, error) + func GetNetworkServersForOrganizationID(db sqlx.Queryer, organizationID int64, limit, offset int) ([]NetworkServer, error) + func (ns NetworkServer) Validate() error + type Organization struct + CanHaveGateways bool + CreatedAt time.Time + DisplayName string + ID int64 + Name string + UpdatedAt time.Time + func GetOrganization(db sqlx.Queryer, id int64) (Organization, error) + func GetOrganizations(db sqlx.Queryer, limit, offset int, search string) ([]Organization, error) + func GetOrganizationsForUser(db sqlx.Queryer, username string, limit, offset int, search string) ([]Organization, error) + func (o Organization) Validate() error + type OrganizationUser struct + CreatedAt time.Time + IsAdmin bool + UpdatedAt time.Time + UserID int64 + Username string + func GetOrganizationUser(db sqlx.Queryer, organizationID, userID int64) (OrganizationUser, error) + func GetOrganizationUsers(db sqlx.Queryer, organizationID int64, limit, offset int) ([]OrganizationUser, error) + type SearchResult struct + ApplicationID *int64 + ApplicationName *string + DeviceDevEUI *lorawan.EUI64 + DeviceName *string + GatewayMAC *lorawan.EUI64 + GatewayName *string + Kind string + OrganizationID *int64 + OrganizationName *string + Score float64 + func GlobalSearch(db sqlx.Queryer, username string, globalAdmin bool, search string, ...) ([]SearchResult, error) + type ServiceProfile struct + CreatedAt time.Time + Name string + NetworkServerID int64 + OrganizationID int64 + ServiceProfile backend.ServiceProfile + UpdatedAt time.Time + func GetServiceProfile(db sqlx.Queryer, id string) (ServiceProfile, error) + func (sp ServiceProfile) Validate() error + type ServiceProfileMeta struct + CreatedAt time.Time + Name string + NetworkServerID int64 + OrganizationID int64 + ServiceProfileID string + UpdatedAt time.Time + func GetServiceProfiles(db sqlx.Queryer, limit, offset int) ([]ServiceProfileMeta, error) + func GetServiceProfilesForOrganizationID(db sqlx.Queryer, organizationID int64, limit, offset int) ([]ServiceProfileMeta, error) + func GetServiceProfilesForUser(db sqlx.Queryer, username string, limit, offset int) ([]ServiceProfileMeta, error) + type User struct + CreatedAt time.Time + Email string + ID int64 + IsActive bool + IsAdmin bool + Note string + PasswordHash string + SessionTTL int32 + UpdatedAt time.Time + Username string + func GetUser(db sqlx.Queryer, id int64) (User, error) + func GetUserByUsername(db sqlx.Queryer, username string) (User, error) + func GetUsers(db sqlx.Queryer, limit, offset int32, search string) ([]User, error) + type UserProfile struct + Organizations []UserProfileOrganization + User UserProfileUser + func GetProfile(db sqlx.Queryer, id int64) (UserProfile, error) + type UserProfileApplication struct + CreatedAt time.Time + ID int64 + IsAdmin bool + Name string + UpdatedAt time.Time + type UserProfileOrganization struct + CreatedAt time.Time + ID int64 + IsAdmin bool + Name string + UpdatedAt time.Time + type UserProfileUser struct + CreatedAt time.Time + ID int64 + IsActive bool + IsAdmin bool + SessionTTL int32 + UpdatedAt time.Time + Username string + type UserUpdate struct + Email string + ID int64 + IsActive bool + IsAdmin bool + Note string + SessionTTL int32 + Username string