mirror of
https://github.com/mainflux/mainflux.git
synced 2025-04-29 13:49:28 +08:00

* Refactor Mainflux go SDK Add structures instead of string parameters. Add offset and limit parameters to things and channels methods. Add better configuration support. Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Add new public errors with better error handling Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Update SDK to use uint instread of string id Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Update cli to use new SDK API Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Remove TLS termination from nginx configuration Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Update SDK documentation and structures Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Refactor things service Decouple HTTP layer from business logic. Remove ID number validation check. Remove models from HTTP requests and responses. Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Reformat tests for things service Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Increase test coverage for things service Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>
49 lines
910 B
Go
49 lines
910 B
Go
//
|
|
// Copyright (c) 2018
|
|
// Mainflux
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
package cli
|
|
|
|
import "github.com/spf13/cobra"
|
|
|
|
const contentTypeSenml = "application/senml+json"
|
|
|
|
var cmdMessages = []cobra.Command{
|
|
cobra.Command{
|
|
Use: "send",
|
|
Short: "send <channel_id> <JSON_string> <thing_token>",
|
|
Long: `Sends message on the channel`,
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
if len(args) != 3 {
|
|
logUsage(cmd.Short)
|
|
return
|
|
}
|
|
|
|
if err := sdk.SendMessage(args[0], args[1], args[2]); err != nil {
|
|
logError(err)
|
|
return
|
|
}
|
|
|
|
logOK()
|
|
},
|
|
},
|
|
}
|
|
|
|
// NewMessagesCmd returns messages command.
|
|
func NewMessagesCmd() *cobra.Command {
|
|
cmd := cobra.Command{
|
|
Use: "msg",
|
|
Short: "Send or retrieve messages",
|
|
Long: `Send or retrieve messages: control message flow on the channel`,
|
|
}
|
|
|
|
for i := range cmdMessages {
|
|
cmd.AddCommand(&cmdMessages[i])
|
|
}
|
|
|
|
return &cmd
|
|
}
|