Documentation
¶
Index ¶
- Variables
- type AsyncTaskCallback
- type MarsClient
- func (_this *MarsClient) AddSystemLog(_type, _msg string) bool
- func (_this *MarsClient) CallAPI(_api string, _payload string, _timeout int) string
- func (_this *MarsClient) CallAPISpecify(_url string, _api string, _payload string, _timeout int) string
- func (_this *MarsClient) DeleteData(_uuid, _suid, _ukey string, _mqttPush bool) bool
- func (_this *MarsClient) DeleteDataAdv(_space, _owner, _uuid, _suid, _ukey string, _eventInfo *MarsJSON.JSONObject, ...) bool
- func (_this *MarsClient) DownloadOTA(_srcFile string, _destFile string, _packet string, _version string) bool
- func (c *MarsClient) GetAuthToken() string
- func (_this *MarsClient) GetDataByTime(_uuid string, _startTime int64, _endTime int64) *MarsJSON.JSONObject
- func (_this *MarsClient) GetDataByTimeAdv(_space, _owner, _uuid, _suid string, _start, _end int64, _compress bool) *MarsJSON.JSONObject
- func (_this *MarsClient) GetLastData(_uuid string, _suid string, _count int, _compress bool) *MarsJSON.JSONObject
- func (_this *MarsClient) GetLastDataAdv(_space, _owner, _uuid, _suid, _orderBy, _orderType string, _count int, ...) *MarsJSON.JSONObject
- func (_this *MarsClient) GetServerURL() string
- func (_this *MarsClient) GetServerURLByIndex(_index int) string
- func (_this *MarsClient) LocalLogin(_proj string) bool
- func (_this *MarsClient) Login(_url string, _account string, _pass string) bool
- func (_this *MarsClient) LoginByKey(_url string, _key string) bool
- func (_this *MarsClient) LoginByKeyWithProj(_url string, _proj string, _key string) bool
- func (_this *MarsClient) LoginByToken(_url string, _token string) bool
- func (_this *MarsClient) LoginWithProj(_url string, _account string, _pass string, _proj string) bool
- func (_this *MarsClient) PushMail(_host *MarsJSON.JSONObject, _mail, _title, _msg string) bool
- func (_this *MarsClient) PutData(_uuid string, _suid string, _data *MarsJSON.JSONObject) bool
- func (_this *MarsClient) PutDataAdv(_space, _owner, _uuid, _suid, _ukey string, _data *MarsJSON.JSONObject, ...) bool
- func (_this *MarsClient) PutEvent(_uuid string, _suid string, _data *MarsJSON.JSONObject) bool
- func (_this *MarsClient) ReLogin() bool
- func (_this *MarsClient) RegistryDevice(_root *MarsJSON.JSONObject) bool
- func (_this *MarsClient) RegistryService(_info string, _resetKey bool) bool
- func (_this *MarsClient) RegistryServiceProperties(_id string, _prop string) bool
- func (_this *MarsClient) ReportAsyncTask(_taskID, _status string, _progress int) string
- func (_this *MarsClient) ResetSecurityKey() bool
- func (c *MarsClient) RunAsyncTask(id, service, api string, payload *MarsJSON.JSONObject, ...)
- func (c *MarsClient) RunAsyncTaskWithContext(ctx context.Context, id, service, api string, payload *MarsJSON.JSONObject, ...) <-chan error
- func (_this *MarsClient) SendBroadcast(_from string, _msg *MarsJSON.JSONObject) bool
- func (c *MarsClient) SetAuthToken(token string)
- func (_this *MarsClient) UnzipData(_dataBase64 string) *MarsJSON.JSONObject
- func (_this *MarsClient) UnzipDataHuge(_dataBase64 string) []string
- func (_this *MarsClient) UpdateServerURL()
Constants ¶
This section is empty.
Variables ¶
var AsyncTaskPollInterval = 2 * time.Second
var AsyncTaskTimeout = 5 * time.Minute
以下相容設定僅可於初始化時修改。
Functions ¶
This section is empty.
Types ¶
type AsyncTaskCallback ¶
-------------------------------------------------------------------------------------
type MarsClient ¶
type MarsClient struct {
ServerURLs []string
ProjID string
AuthToken string
Account string
Password string
SecretKey string
EnableLoadBalance bool
// contains filtered or unexported fields
}
-------------------------------------------------------------------------------------
func Create ¶
func Create() *MarsClient
-------------------------------------------------------------------------------------
func (*MarsClient) AddSystemLog ¶
func (_this *MarsClient) AddSystemLog(_type, _msg string) bool
-------------------------------------------------------------------------------------
func (*MarsClient) CallAPI ¶
func (_this *MarsClient) CallAPI(_api string, _payload string, _timeout int) string
------------------------------------------------------------------------------------- CALL API -------------------------------------------------------------------------------------
func (*MarsClient) CallAPISpecify ¶
func (_this *MarsClient) CallAPISpecify(_url string, _api string, _payload string, _timeout int) string
-------------------------------------------------------------------------------------
func (*MarsClient) DeleteData ¶
func (_this *MarsClient) DeleteData(_uuid, _suid, _ukey string, _mqttPush bool) bool
-------------------------------------------------------------------------------------
func (*MarsClient) DeleteDataAdv ¶
func (_this *MarsClient) DeleteDataAdv(_space, _owner, _uuid, _suid, _ukey string, _eventInfo *MarsJSON.JSONObject, _mqttPush bool) bool
-------------------------------------------------------------------------------------
func (*MarsClient) DownloadOTA ¶
func (_this *MarsClient) DownloadOTA(_srcFile string, _destFile string, _packet string, _version string) bool
DownloadOTA 下載遠端更新檔並儲存為檔案
func (*MarsClient) GetAuthToken ¶ added in v0.1.23
func (c *MarsClient) GetAuthToken() string
GetAuthToken 安全讀取登入憑證。
func (*MarsClient) GetDataByTime ¶
func (_this *MarsClient) GetDataByTime(_uuid string, _startTime int64, _endTime int64) *MarsJSON.JSONObject
-------------------------------------------------------------------------------------
func (*MarsClient) GetDataByTimeAdv ¶
func (_this *MarsClient) GetDataByTimeAdv(_space, _owner, _uuid, _suid string, _start, _end int64, _compress bool) *MarsJSON.JSONObject
-------------------------------------------------------------------------------------
func (*MarsClient) GetLastData ¶
func (_this *MarsClient) GetLastData(_uuid string, _suid string, _count int, _compress bool) *MarsJSON.JSONObject
-------------------------------------------------------------------------------------
func (*MarsClient) GetLastDataAdv ¶
func (_this *MarsClient) GetLastDataAdv(_space, _owner, _uuid, _suid, _orderBy, _orderType string, _count int, _compress bool) *MarsJSON.JSONObject
-------------------------------------------------------------------------------------
func (*MarsClient) GetServerURL ¶
func (_this *MarsClient) GetServerURL() string
-------------------------------------------------------------------------------------
func (*MarsClient) GetServerURLByIndex ¶
func (_this *MarsClient) GetServerURLByIndex(_index int) string
-------------------------------------------------------------------------------------
func (*MarsClient) LocalLogin ¶
func (_this *MarsClient) LocalLogin(_proj string) bool
------------------------------------------------------------------------------------- 基礎通訊與登入 -------------------------------------------------------------------------------------
func (*MarsClient) Login ¶
func (_this *MarsClient) Login(_url string, _account string, _pass string) bool
------------------------------------------------------------------------------------- Login 基礎登入
func (*MarsClient) LoginByKey ¶
func (_this *MarsClient) LoginByKey(_url string, _key string) bool
------------------------------------------------------------------------------------- LoginByKey 使用 Key 登入
func (*MarsClient) LoginByKeyWithProj ¶
func (_this *MarsClient) LoginByKeyWithProj(_url string, _proj string, _key string) bool
------------------------------------------------------------------------------------- LoginByKeyWithProj 使用 Key 與專案 ID 登入
func (*MarsClient) LoginByToken ¶
func (_this *MarsClient) LoginByToken(_url string, _token string) bool
------------------------------------------------------------------------------------- LoginByToken 使用現有 Token 登入
func (*MarsClient) LoginWithProj ¶
func (_this *MarsClient) LoginWithProj(_url string, _account string, _pass string, _proj string) bool
------------------------------------------------------------------------------------- LoginWithProj 帶有專案 ID 的登入
func (*MarsClient) PushMail ¶
func (_this *MarsClient) PushMail(_host *MarsJSON.JSONObject, _mail, _title, _msg string) bool
------------------------------------------------------------------------------------- 其他功能 -------------------------------------------------------------------------------------
func (*MarsClient) PutData ¶
func (_this *MarsClient) PutData(_uuid string, _suid string, _data *MarsJSON.JSONObject) bool
------------------------------------------------------------------------------------- 資料存取 (Put/Get) -------------------------------------------------------------------------------------
func (*MarsClient) PutDataAdv ¶
func (_this *MarsClient) PutDataAdv(_space, _owner, _uuid, _suid, _ukey string, _data *MarsJSON.JSONObject, _mqttPush bool) bool
-------------------------------------------------------------------------------------
func (*MarsClient) PutEvent ¶
func (_this *MarsClient) PutEvent(_uuid string, _suid string, _data *MarsJSON.JSONObject) bool
-------------------------------------------------------------------------------------
func (*MarsClient) ReLogin ¶
func (_this *MarsClient) ReLogin() bool
------------------------------------------------------------------------------------- ReLogin 重新執行登入流程
func (*MarsClient) RegistryDevice ¶
func (_this *MarsClient) RegistryDevice(_root *MarsJSON.JSONObject) bool
-------------------------------------------------------------------------------------
func (*MarsClient) RegistryService ¶
func (_this *MarsClient) RegistryService(_info string, _resetKey bool) bool
func (*MarsClient) RegistryServiceProperties ¶
func (_this *MarsClient) RegistryServiceProperties(_id string, _prop string) bool
-------------------------------------------------------------------------------------
func (*MarsClient) ReportAsyncTask ¶
func (_this *MarsClient) ReportAsyncTask(_taskID, _status string, _progress int) string
-------------------------------------------------------------------------------------
func (*MarsClient) ResetSecurityKey ¶
func (_this *MarsClient) ResetSecurityKey() bool
------------------------------------------------------------------------------------- 安全性管理 -------------------------------------------------------------------------------------
func (*MarsClient) RunAsyncTask ¶
func (c *MarsClient) RunAsyncTask(id, service, api string, payload *MarsJSON.JSONObject, callback AsyncTaskCallback)
RunAsyncTask 保留舊入口,預設五分鐘總期限。
func (*MarsClient) RunAsyncTaskWithContext ¶ added in v0.1.23
func (c *MarsClient) RunAsyncTaskWithContext(ctx context.Context, id, service, api string, payload *MarsJSON.JSONObject, callback AsyncTaskCallback) <-chan error
RunAsyncTaskWithContext 可取消等待與正在進行的 HTTP 請求。 結果通道送出一次結果後關閉;自訂 callback 必須自行保證返回。
func (*MarsClient) SendBroadcast ¶
func (_this *MarsClient) SendBroadcast(_from string, _msg *MarsJSON.JSONObject) bool
-------------------------------------------------------------------------------------
func (*MarsClient) SetAuthToken ¶ added in v0.1.23
func (c *MarsClient) SetAuthToken(token string)
SetAuthToken 安全更新登入憑證。
func (*MarsClient) UnzipData ¶
func (_this *MarsClient) UnzipData(_dataBase64 string) *MarsJSON.JSONObject
func (*MarsClient) UnzipDataHuge ¶
func (_this *MarsClient) UnzipDataHuge(_dataBase64 string) []string
-------------------------------------------------------------------------------------
func (*MarsClient) UpdateServerURL ¶
func (_this *MarsClient) UpdateServerURL()
------------------------------------------------------------------------------------- UpdateServerURL 更新負載平衡的伺服器清單