Skip to content

Commit

Permalink
Add "ping" plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
ivankravets committed Jun 7, 2015
1 parent 6d94e40 commit 6590d47
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
9 changes: 9 additions & 0 deletions firmware/src/plugins/ping/manifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<smartanthill.plugin name="ping" title="Ping" version="1.0">

<description>The plugin allows to indicate if device is on-line ("1" will be returned in response) and to mesure latency</description>

<reply>
<field name="ok" type="encoded-uint[max=1]" min="1" max="1" />
</reply>

</smartanthill.plugin>
30 changes: 30 additions & 0 deletions firmware/src/plugins/ping/ping.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*******************************************************************************
Copyright (C) 2015 OLogN Technologies AG
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*******************************************************************************/

#include "ping.h"

uint8_t ping_plugin_handler_init( const void* plugin_config, void* plugin_state )
{
return 0;
}

uint8_t ping_plugin_handler( const void* plugin_config, void* plugin_state, parser_obj* command, MEMORY_HANDLE reply/*, WaitingFor* waiting_for*/, uint8_t first_byte )
{
zepto_response_to_request( reply );
zepto_write_uint8( reply, 1 ); // answer with "1", we are on-line!
return 0;
}
39 changes: 39 additions & 0 deletions firmware/src/plugins/ping/ping.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*******************************************************************************
Copyright (C) 2015 OLogN Technologies AG
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*******************************************************************************/


#if !defined __SA_PING_PLUGIN_H__
#define __SA_PING_PLUGIN_H__

#include "../../common/sa-common.h"
#include "../../common/sa-data-types.h"

typedef struct _PingPluginConfig
{

} PingPluginConfig;

typedef struct _PingPluginState
{

} PingPluginState;

uint8_t ping_plugin_handler_init( const void* plugin_config, void* plugin_state );
uint8_t ping_plugin_handler( const void* plugin_config, void* plugin_state, parser_obj* command, MEMORY_HANDLE reply/*, WaitingFor* waiting_for*/, uint8_t first_byte );


#endif // __SA_PING_PLUGIN_H__

0 comments on commit 6590d47

Please sign in to comment.