1+ /* *
2+ * @file communication_demo.h
3+ *
4+ * @brief Definition of the communication demo.
5+ *
6+ * Revised BSD License
7+ * Copyright Semtech Corporation 2020. All rights reserved.
8+ *
9+ * Redistribution and use in source and binary forms, with or without
10+ * modification, are permitted provided that the following conditions are met:
11+ * * Redistributions of source code must retain the above copyright
12+ * notice, this list of conditions and the following disclaimer.
13+ * * Redistributions in binary form must reproduce the above copyright
14+ * notice, this list of conditions and the following disclaimer in the
15+ * documentation and/or other materials provided with the distribution.
16+ * * Neither the name of the Semtech corporation nor the
17+ * names of its contributors may be used to endorse or promote products
18+ * derived from this software without specific prior written permission.
19+ *
20+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23+ * ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY
24+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+ */
31+
32+ #ifndef __COMMUNICATION_DEMO_H__
33+ #define __COMMUNICATION_DEMO_H__
34+
35+ #include " communication_interface.h"
36+
37+ typedef enum
38+ {
39+ COMMUNICATION_DEMO_STATUS_OK,
40+ COMMUNICATION_DEMO_STATUS_TIMEOUT,
41+ COMMUNICATION_DEMO_STATUS_OVERFLOW,
42+ COMMUNICATION_DEMO_STATUS_DISABLED,
43+ } CommunicationDemoStatus_t;
44+
45+ class CommunicationDemo : public CommunicationInterface
46+ {
47+ public:
48+ virtual void Runtime ( ) override ;
49+ virtual bool GetDateAndApproximateLocation ( uint32_t & gps_second, float & latitude, float & longitude,
50+ float & altitude ) override ;
51+ virtual bool GetResults ( float & latitude, float & longitude, float & altitude, float & accuracy, char * geo_coding,
52+ const uint8_t geo_coding_max_length );
53+ virtual void Store ( const demo_wifi_scan_all_results_t & wifi_results );
54+ virtual void Store ( const demo_gnss_all_results_t & gnss_results, uint32_t delay_since_capture );
55+ virtual void Store ( const version_handler_t & version );
56+ virtual void EraseDataStored ( ) override ;
57+ virtual void SendDataStoredToServer ( ) override ;
58+ virtual void vLog ( const char * fmt, va_list argp ) override ;
59+ virtual bool HasNewCommand ( ) const override ;
60+ virtual CommandInterface* FetchCommand ( ) override ;
61+
62+ protected:
63+ CommunicationDemoStatus_t AskAndParseResults ( float & latitude, float & longitude, float & altitude, float & accuracy,
64+ char * geo_coding, const uint8_t geo_coding_max_length );
65+ CommunicationDemoStatus_t ReceiveData ( const uint16_t buffer_length_max, char * buffer,
66+ uint16_t & buffer_length_received, const uint16_t timeout );
67+ CommunicationDemoStatus_t AskData ( const char * token, const uint16_t buffer_length_max, char * buffer,
68+ uint16_t & buffer_length_received, const uint16_t timeout );
69+ void SendCommand ( const char * command );
70+ void Store ( const char * fmt, ... );
71+ };
72+
73+ #endif // __COMMUNICATION_DEMO_H__
0 commit comments