Documentation
¶
Overview ¶
Package hilink provides a Hilink WebUI client.
Index ¶
- Constants
- Variables
- func HashPw(text string) string
- func NoSessionStart(c *Client) error
- func SimpleRequestXML(vals ...string) []byte
- func WifiDefaultConfig() map[string]string
- func XMLMapString(indent string, vals map[string]string) string
- type Client
- func (c *Client) AutorunVersion() (string, error)
- func (c *Client) ChangePassword(newPassword string) (bool, error)
- func (c *Client) Connect() (bool, error)
- func (c *Client) ConnectionInfo() (XMLData, error)
- func (c *Client) CradleMAC() (string, error)
- func (c *Client) CradleMACSet(addr string) (bool, error)
- func (c *Client) CradleStatusInfo() (XMLData, error)
- func (c *Client) DdnsList() (XMLData, error)
- func (c *Client) DeviceBackup() (string, error)
- func (c *Client) DeviceBasicInfo() (XMLData, error)
- func (c *Client) DeviceConfig() (XMLData, error)
- func (c *Client) DeviceControl(code uint) (bool, error)
- func (c *Client) DeviceFeatures() (XMLData, error)
- func (c *Client) DeviceInfo() (XMLData, error)
- func (c *Client) DeviceModeSet(mode uint) (bool, error)
- func (c *Client) DeviceReboot() (bool, error)
- func (c *Client) DeviceReset() (bool, error)
- func (c *Client) DeviceShutdown() (bool, error)
- func (c *Client) DhcpConfig() (XMLData, error)
- func (c *Client) Disconnect() (bool, error)
- func (c *Client) DmzConfig() (XMLData, error)
- func (c *Client) DmzConfigSet(enabled bool, dmzIPAddress string) (bool, error)
- func (c *Client) Do(path string, v interface{}) (XMLData, error)
- func (c *Client) FastbootFeatures() (XMLData, error)
- func (c *Client) FirewallFeatures() (XMLData, error)
- func (c *Client) GlobalConfig() (XMLData, error)
- func (c *Client) GlobalFeatures() (XMLData, error)
- func (c *Client) Language() (string, error)
- func (c *Client) LanguageSet(lang string) (bool, error)
- func (c *Client) LogInfo() (XMLData, error)
- func (c *Client) LogPath() (string, error)
- func (c *Client) LoginStatusInfo() (XMLData, error)
- func (c *Client) ModeInfo() (XMLData, error)
- func (c *Client) ModeList() (XMLData, error)
- func (c *Client) ModeNetworkInfo() (XMLData, error)
- func (c *Client) ModeSet(netMode, netBand, lteBand string) (bool, error)
- func (c *Client) MonthInfo() (XMLData, error)
- func (c *Client) NatType() (XMLData, error)
- func (c *Client) NatTypeSet(ntype uint) (bool, error)
- func (c *Client) NetworkInfo() (XMLData, error)
- func (c *Client) NetworkTypes() (XMLData, error)
- func (c *Client) NewSessionAndTokenID() (string, string, error)
- func (c *Client) NotificationInfo() (XMLData, error)
- func (c *Client) PCAssistantConfig() (XMLData, error)
- func (c *Client) PhonebookCount() (XMLData, error)
- func (c *Client) PhonebookCreate(group uint, name, phone string, sim bool) (XMLData, error)
- func (c *Client) PhonebookDelete(id uint) (bool, error)
- func (c *Client) PhonebookGroupList(page, count uint, sortByName, ascending bool) (XMLData, error)
- func (c *Client) PhonebookImport(group uint) (XMLData, error)
- func (c *Client) PhonebookList(group, page, count uint, sim, sortByName, ascending bool, keyword string) (XMLData, error)
- func (c *Client) PinActivate(pin string) (bool, error)
- func (c *Client) PinChange(pin, new string) (bool, error)
- func (c *Client) PinDeactivate(pin string) (bool, error)
- func (c *Client) PinEnter(pin string) (bool, error)
- func (c *Client) PinEnterPuk(puk, new string) (bool, error)
- func (c *Client) PinInfo() (XMLData, error)
- func (c *Client) PinSaveInfo() (XMLData, error)
- func (c *Client) PinSimlockInfo() (XMLData, error)
- func (c *Client) PowerFeatures() (XMLData, error)
- func (c *Client) ProfileInfo() (XMLData, error)
- func (c *Client) PublicKey() (string, error)
- func (c *Client) SetSessionAndTokenID(sessionID, tokenID string) error
- func (c *Client) SignalInfo() (XMLData, error)
- func (c *Client) SimInfo() (XMLData, error)
- func (c *Client) SipAlg() (XMLData, error)
- func (c *Client) SipAlgSet(port uint, enabled bool) (bool, error)
- func (c *Client) SmsConfig() (XMLData, error)
- func (c *Client) SmsCount() (XMLData, error)
- func (c *Client) SmsDelete(id uint) (bool, error)
- func (c *Client) SmsFeatures() (XMLData, error)
- func (c *Client) SmsList(boxType, page, count uint, sortByName, ascending, unreadPreferred bool) (XMLData, error)
- func (c *Client) SmsReadSet(id string) (bool, error)
- func (c *Client) SmsSend(msg string, to ...string) (bool, error)
- func (c *Client) SmsSendStatus() (XMLData, error)
- func (c *Client) StatusInfo() (XMLData, error)
- func (c *Client) TetheringFeatures() (XMLData, error)
- func (c *Client) TrafficClear() (bool, error)
- func (c *Client) TrafficInfo() (XMLData, error)
- func (c *Client) Upnp() (XMLData, error)
- func (c *Client) UpnpSet(enabled bool) (bool, error)
- func (c *Client) UssdCode(code string) (bool, error)
- func (c *Client) UssdContent() (string, error)
- func (c *Client) UssdRelease() (bool, error)
- func (c *Client) UssdStatus() (UssdState, error)
- func (c *Client) WebUIConfig() (XMLData, error)
- func (c *Client) WifiFeatures() (XMLData, error)
- func (c *Client) WlanConfig() (XMLData, error)
- func (c *Client) WlanDisable(ssid string, config map[string]string) (bool, error)
- func (c *Client) WlanMonthInfo() (XMLData, error)
- type Option
- type PinType
- type SmsBoxType
- type UssdState
- type XMLData
Constants ¶
const ( // DefaultURL is the default URL endpoint for the Hilink WebUI. DefaultURL = "http://192.168.8.1/" //DefaultHost default host header DefaultHost = "192.168.8.1" // DefaultTimeout is the default timeout. DefaultTimeout = 30 * time.Second // TokenHeader is the header used by the WebUI for CSRF tokens. TokenHeader = "__RequestVerificationToken" //TokenHeaderLogin . TokenHeaderLogin = TokenHeader + "one" )
Variables ¶
var ( // ErrBadStatusCode is the bad status code error. ErrBadStatusCode = errors.New("bad status code") // ErrInvalidResponse is the invalid response error. ErrInvalidResponse = errors.New("invalid response") // ErrInvalidError is the invalid error error. ErrInvalidError = errors.New("invalid error") // ErrInvalidValue is the invalid value error. ErrInvalidValue = errors.New("invalid value") // ErrInvalidXML is the invalid xml error. ErrInvalidXML = errors.New("invalid xml") // ErrMissingRootElement is the missing root element error. ErrMissingRootElement = errors.New("missing root element") // ErrMessageTooLong is the message too long error. ErrMessageTooLong = errors.New("message too long") )
var ErrorCodeMessageMap = map[string]string{
"-1": "system not available",
"100002": "not supported by firmware or incorrect API path",
"100003": "unauthorized",
"100004": "system busy",
"100005": "unknown error",
"100006": "invalid parameter",
"100009": "write error",
"103002": "unknown error",
"103015": "unknown error",
"108001": "invalid username",
"108002": "invalid password",
"108003": "user already logged in",
"108006": "invalid username or password",
"108007": "invalid username, password, or session timeout",
"110024": "battery charge less than 50%",
"111019": "no network response",
"111020": "network timeout",
"111022": "network not supported",
"113018": "system busy",
"114001": "file already exists",
"114002": "file already exists",
"114003": "SD card currently in use",
"114004": "path does not exist",
"114005": "path too long",
"114006": "no permission for specified file or directory",
"115001": "unknown error",
"117001": "incorrect WiFi password",
"117004": "incorrect WISPr password",
"120001": "voice busy",
"125001": "invalid token",
}
ErrorCodeMessageMap contains the known message strings for Hilink devices.
Functions ¶
func NoSessionStart ¶
NoSessionStart is an option that prevents the automatic creation of a session with the Hilink device.
func SimpleRequestXML ¶
SimpleRequestXML creates an XML string from value pairs.
Unfortunately the XML parser (or whatever underyling code) included with the WebUI on Hilink devices expects parameters in a specific order. This makes packages like mxj or other map based solutions not feasible for use, as Go has random key ordering for maps.
On another note, XML sucks.
func WifiDefaultConfig ¶
WifiDefaultConfig returns the default configuration of the wireless interface.
Types ¶
type Client ¶
Client represents a Hilink client connection.
func (*Client) AutorunVersion ¶
AutorunVersion retrieves device autorun version.
func (*Client) ChangePassword ¶
ChangePassword changes the current user password
func (*Client) ConnectionInfo ¶
ConnectionInfo retrieves connection (dialup) information.
func (*Client) CradleMACSet ¶
CradleMACSet sets the MAC address for the cradle.
func (*Client) CradleStatusInfo ¶
CradleStatusInfo retrieves cradle status information.
func (*Client) DeviceBackup ¶
DeviceBackup backups device configuration and retrieves backed up configuration data as a base64 encoded string.
func (*Client) DeviceBasicInfo ¶
DeviceBasicInfo retrieves basic device information.
func (*Client) DeviceConfig ¶
DeviceConfig retrieves device configuration.
func (*Client) DeviceControl ¶
DeviceControl sends a control code to the device.
func (*Client) DeviceFeatures ¶
DeviceFeatures retrieves device feature information.
func (*Client) DeviceInfo ¶
DeviceInfo retrieves general device information.
func (*Client) DeviceModeSet ¶
DeviceModeSet sets the device mode (0-project, 1-debug).
func (*Client) DeviceReboot ¶
DeviceReboot restarts the device.
func (*Client) DeviceReset ¶
DeviceReset resets the device configuration.
func (*Client) DeviceShutdown ¶
DeviceShutdown shuts down the device.
func (*Client) DhcpConfig ¶
DhcpConfig retrieves DHCP configuration.
func (*Client) Disconnect ¶
Disconnect disconnects the Hilink device from the network provider.
func (*Client) DmzConfigSet ¶
DmzConfigSet enables or disables the DMZ and the DMZ IP address of the device.
func (*Client) Do ¶
Do sends a request to the server with the provided path. If data is nil, then GET will be used as the HTTP method, otherwise POST will be used.
func (*Client) FastbootFeatures ¶
FastbootFeatures retrieves fastboot feature information.
func (*Client) FirewallFeatures ¶
FirewallFeatures retrieves firewall security feature information.
func (*Client) GlobalConfig ¶
GlobalConfig retrieves global Hilink configuration.
func (*Client) GlobalFeatures ¶
GlobalFeatures retrieves global feature information.
func (*Client) LanguageSet ¶
LanguageSet sets the language.
func (*Client) LoginStatusInfo ¶
LoginStatusInfo retrieves the status of user authentication.
func (*Client) ModeNetworkInfo ¶
ModeNetworkInfo retrieves current network mode information.
func (*Client) NatTypeSet ¶
NatTypeSet sets NAT type (values: 0, 1).
func (*Client) NetworkInfo ¶
NetworkInfo retrieves network provider information.
func (*Client) NetworkTypes ¶
NetworkTypes retrieves available network types.
func (*Client) NewSessionAndTokenID ¶
NewSessionAndTokenID starts a session with the server, and returns the session and token.
func (*Client) NotificationInfo ¶
NotificationInfo retrieves notification information.
func (*Client) PCAssistantConfig ¶
PCAssistantConfig retrieves PC Assistant configuration.
func (*Client) PhonebookCount ¶
PhonebookCount retrieves count of phonebook entries per group.
func (*Client) PhonebookCreate ¶
PhonebookCreate creates a new phonebook entry.
func (*Client) PhonebookDelete ¶
PhonebookDelete deletes a specified phonebook entry.
func (*Client) PhonebookGroupList ¶
PhonebookGroupList retrieves list of the phonebook groups.
func (*Client) PhonebookImport ¶
PhonebookImport imports SIM contacts into specified phonebook group.
func (*Client) PhonebookList ¶
func (c *Client) PhonebookList(group, page, count uint, sim, sortByName, ascending bool, keyword string) (XMLData, error)
PhonebookList retrieves list of phonebook entries from a specified group.
func (*Client) PinActivate ¶
PinActivate activates a SIM PIN.
func (*Client) PinDeactivate ¶
PinDeactivate deactivates a SIM PIN.
func (*Client) PinEnterPuk ¶
PinEnterPuk enters a SIM PIN puk.
func (*Client) PinSaveInfo ¶
PinSaveInfo retrieves SIM PIN save information.
func (*Client) PinSimlockInfo ¶
PinSimlockInfo retrieves SIM lock information.
func (*Client) PowerFeatures ¶
PowerFeatures retrieves power feature information.
func (*Client) ProfileInfo ¶
ProfileInfo retrieves profile information (ie, APN).
func (*Client) SetSessionAndTokenID ¶
SetSessionAndTokenID sets the sessionID and tokenID for the Client.
func (*Client) SignalInfo ¶
SignalInfo retrieves network signal information.
func (*Client) SipAlgSet ¶
SipAlgSet enables/disables SIP application-level gateway and sets SIP port.
func (*Client) SmsFeatures ¶
SmsFeatures retrieves SMS feature information.
func (*Client) SmsList ¶
func (c *Client) SmsList(boxType, page, count uint, sortByName, ascending, unreadPreferred bool) (XMLData, error)
SmsList retrieves list of SMS in an inbox.
func (*Client) SmsReadSet ¶
SmsReadSet sets the read status of a SMS.
func (*Client) SmsSendStatus ¶
SmsSendStatus retrieves SMS send status information.
func (*Client) StatusInfo ¶
StatusInfo retrieves general device status information.
func (*Client) TetheringFeatures ¶
TetheringFeatures retrieves USB tethering feature information.
func (*Client) TrafficClear ¶
TrafficClear clears the current traffic statistics.
func (*Client) TrafficInfo ¶
TrafficInfo retrieves traffic statistic information.
func (*Client) UssdContent ¶
UssdContent retrieves content buffer of the active USSD session.
func (*Client) UssdRelease ¶
UssdRelease releases the active USSD session.
func (*Client) UssdStatus ¶
UssdStatus retrieves current USSD session status information.
func (*Client) WebUIConfig ¶
WebUIConfig retrieves WebUI configuration.
func (*Client) WifiFeatures ¶
WifiFeatures retrieves wifi feature information.
func (*Client) WlanConfig ¶
WlanConfig retrieves basic WLAN settings.
func (*Client) WlanDisable ¶
WlanDisable disables the WLAN interface that matches the given ssid.
func (*Client) WlanMonthInfo ¶
WlanMonthInfo retrieves the WLAN month download statistic information.
type Option ¶
Option is an option used when creating a new Client.
func Auth ¶
Auth is an option specifying the identifier and password to use. The option is ignored if id is an empty string.
func HTTPClient ¶
HTTPClient is an option that allows setting the http.Client used by the Client.
func Host ¶
Host Set Host header to each request to prevent redirect to 192.168.8.1 when modem url different from default
type SmsBoxType ¶
type SmsBoxType uint
SmsBoxType represents the different inbox types available on a hilink device.
const ( SmsBoxTypeInbox SmsBoxType = iota + 1 SmsBoxTypeOutbox SmsBoxTypeDraft )
SmsBoxType values.