= 2.3
3 | hidapi
4 | google-cloud-pubsub
5 |
--------------------------------------------------------------------------------
/scripts/shield.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MicrochipTech/gcp-iot-core-examples/938321f643e737bbe98b3737ec08ae1aa7411d4e/scripts/shield.ico
--------------------------------------------------------------------------------
/src/client_task.h:
--------------------------------------------------------------------------------
1 | /**
2 | * \file
3 | * \brief Client Application (MQTT) Task & Controller
4 | *
5 | * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries.
6 | * You may use this software and any derivatives exclusively with
7 | * Microchip products.
8 | *
9 | * \page License
10 | *
11 | * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this
12 | * software and any derivatives exclusively with Microchip products.
13 | *
14 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
15 | * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
16 | * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
17 | * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION
18 | * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION.
19 | *
20 | * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
21 | * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
22 | * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
23 | * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
24 | * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN
25 | * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
27 | *
28 | * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE
29 | * TERMS.
30 | */
31 |
32 | #ifndef CLIENT_TASK_H_
33 | #define CLIENT_TASK_H_
34 |
35 | #define CLIENT_REPORT_PERIOD_DEFAULT (5000)
36 |
37 | #define CLIENT_MQTT_MAX_HOST_URI (100)
38 |
39 | #define CLIENT_MQTT_TIMEOUT_MS (2000)
40 | #define MQTT_YEILD_TIMEOUT_MS (500)
41 | #define MQTT_KEEP_ALIVE_INTERVAL_S (900)
42 |
43 | #define CLIENT_MQTT_RX_BUF_SIZE (1024)
44 | #define CLIENT_MQTT_TX_BUF_SIZE (1024)
45 |
46 | void client_task(void);
47 | void client_timer_update(void);
48 |
49 |
50 | #endif /* CLIENT_TASK_H_ */
--------------------------------------------------------------------------------
/src/devices/thermo5_click.h:
--------------------------------------------------------------------------------
1 | /**
2 | * \file
3 | * \brief Thermo 5 Click Driver (EMC1414)
4 | *
5 | * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries.
6 | * You may use this software and any derivatives exclusively with
7 | * Microchip products.
8 | *
9 | * \page License
10 | *
11 | * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this
12 | * software and any derivatives exclusively with Microchip products.
13 | *
14 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
15 | * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
16 | * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
17 | * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION
18 | * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION.
19 | *
20 | * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
21 | * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
22 | * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
23 | * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
24 | * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN
25 | * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
27 | *
28 | * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE
29 | * TERMS.
30 | */
31 |
32 | #ifndef THERMO5_CLICK_H_
33 | #define THERMO5_CLICK_H_
34 |
35 | uint32_t th5_read_sensor(uint8_t sensor);
36 |
37 | #endif /* THERMO5_CLICK_H_ */
--------------------------------------------------------------------------------
/src/paho_mqtt_embedded_c/MQTTPacket/MQTTFormat.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014 IBM Corp.
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * and Eclipse Distribution License v1.0 which accompany this distribution.
7 | *
8 | * The Eclipse Public License is available at
9 | * http://www.eclipse.org/legal/epl-v10.html
10 | * and the Eclipse Distribution License is available at
11 | * http://www.eclipse.org/org/documents/edl-v10.php.
12 | *
13 | * Contributors:
14 | * Ian Craggs - initial API and implementation and/or initial documentation
15 | *******************************************************************************/
16 |
17 | #if !defined(MQTTFORMAT_H)
18 | #define MQTTFORMAT_H
19 |
20 | #include "StackTrace.h"
21 | #include "MQTTPacket.h"
22 |
23 | const char* MQTTPacket_getName(unsigned short packetid);
24 | int MQTTStringFormat_connect(char* strbuf, int strbuflen, MQTTPacket_connectData* data);
25 | int MQTTStringFormat_connack(char* strbuf, int strbuflen, unsigned char connack_rc, unsigned char sessionPresent);
26 | int MQTTStringFormat_publish(char* strbuf, int strbuflen, unsigned char dup, int qos, unsigned char retained,
27 | unsigned short packetid, MQTTString topicName, unsigned char* payload, int payloadlen);
28 | int MQTTStringFormat_ack(char* strbuf, int strbuflen, unsigned char packettype, unsigned char dup, unsigned short packetid);
29 | int MQTTStringFormat_subscribe(char* strbuf, int strbuflen, unsigned char dup, unsigned short packetid, int count,
30 | MQTTString topicFilters[], int requestedQoSs[]);
31 | int MQTTStringFormat_suback(char* strbuf, int strbuflen, unsigned short packetid, int count, int* grantedQoSs);
32 | int MQTTStringFormat_unsubscribe(char* strbuf, int strbuflen, unsigned char dup, unsigned short packetid,
33 | int count, MQTTString topicFilters[]);
34 | char* MQTTFormat_toClientString(char* strbuf, int strbuflen, unsigned char* buf, int buflen);
35 | char* MQTTFormat_toServerString(char* strbuf, int strbuflen, unsigned char* buf, int buflen);
36 |
37 | #endif
38 |
--------------------------------------------------------------------------------
/src/paho_mqtt_embedded_c/MQTTPacket/MQTTPublish.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014 IBM Corp.
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * and Eclipse Distribution License v1.0 which accompany this distribution.
7 | *
8 | * The Eclipse Public License is available at
9 | * http://www.eclipse.org/legal/epl-v10.html
10 | * and the Eclipse Distribution License is available at
11 | * http://www.eclipse.org/org/documents/edl-v10.php.
12 | *
13 | * Contributors:
14 | * Ian Craggs - initial API and implementation and/or initial documentation
15 | * Xiang Rong - 442039 Add makefile to Embedded C client
16 | *******************************************************************************/
17 |
18 | #ifndef MQTTPUBLISH_H_
19 | #define MQTTPUBLISH_H_
20 |
21 | #if !defined(DLLImport)
22 | #define DLLImport
23 | #endif
24 | #if !defined(DLLExport)
25 | #define DLLExport
26 | #endif
27 |
28 | DLLExport int MQTTSerialize_publish(unsigned char* buf, int buflen, unsigned char dup, int qos, unsigned char retained, unsigned short packetid,
29 | MQTTString topicName, unsigned char* payload, int payloadlen);
30 |
31 | DLLExport int MQTTDeserialize_publish(unsigned char* dup, int* qos, unsigned char* retained, unsigned short* packetid, MQTTString* topicName,
32 | unsigned char** payload, int* payloadlen, unsigned char* buf, int len);
33 |
34 | DLLExport int MQTTSerialize_puback(unsigned char* buf, int buflen, unsigned short packetid);
35 | DLLExport int MQTTSerialize_pubrel(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid);
36 | DLLExport int MQTTSerialize_pubcomp(unsigned char* buf, int buflen, unsigned short packetid);
37 |
38 | #endif /* MQTTPUBLISH_H_ */
39 |
--------------------------------------------------------------------------------
/src/paho_mqtt_embedded_c/MQTTPacket/MQTTSubscribe.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014 IBM Corp.
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * and Eclipse Distribution License v1.0 which accompany this distribution.
7 | *
8 | * The Eclipse Public License is available at
9 | * http://www.eclipse.org/legal/epl-v10.html
10 | * and the Eclipse Distribution License is available at
11 | * http://www.eclipse.org/org/documents/edl-v10.php.
12 | *
13 | * Contributors:
14 | * Ian Craggs - initial API and implementation and/or initial documentation
15 | * Xiang Rong - 442039 Add makefile to Embedded C client
16 | *******************************************************************************/
17 |
18 | #ifndef MQTTSUBSCRIBE_H_
19 | #define MQTTSUBSCRIBE_H_
20 |
21 | #if !defined(DLLImport)
22 | #define DLLImport
23 | #endif
24 | #if !defined(DLLExport)
25 | #define DLLExport
26 | #endif
27 |
28 | DLLExport int MQTTSerialize_subscribe(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid,
29 | int count, MQTTString topicFilters[], int requestedQoSs[]);
30 |
31 | DLLExport int MQTTDeserialize_subscribe(unsigned char* dup, unsigned short* packetid,
32 | int maxcount, int* count, MQTTString topicFilters[], int requestedQoSs[], unsigned char* buf, int len);
33 |
34 | DLLExport int MQTTSerialize_suback(unsigned char* buf, int buflen, unsigned short packetid, int count, int* grantedQoSs);
35 |
36 | DLLExport int MQTTDeserialize_suback(unsigned short* packetid, int maxcount, int* count, int grantedQoSs[], unsigned char* buf, int len);
37 |
38 |
39 | #endif /* MQTTSUBSCRIBE_H_ */
40 |
--------------------------------------------------------------------------------
/src/paho_mqtt_embedded_c/MQTTPacket/MQTTUnsubscribe.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014 IBM Corp.
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * and Eclipse Distribution License v1.0 which accompany this distribution.
7 | *
8 | * The Eclipse Public License is available at
9 | * http://www.eclipse.org/legal/epl-v10.html
10 | * and the Eclipse Distribution License is available at
11 | * http://www.eclipse.org/org/documents/edl-v10.php.
12 | *
13 | * Contributors:
14 | * Ian Craggs - initial API and implementation and/or initial documentation
15 | * Xiang Rong - 442039 Add makefile to Embedded C client
16 | *******************************************************************************/
17 |
18 | #ifndef MQTTUNSUBSCRIBE_H_
19 | #define MQTTUNSUBSCRIBE_H_
20 |
21 | #if !defined(DLLImport)
22 | #define DLLImport
23 | #endif
24 | #if !defined(DLLExport)
25 | #define DLLExport
26 | #endif
27 |
28 | DLLExport int MQTTSerialize_unsubscribe(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid,
29 | int count, MQTTString topicFilters[]);
30 |
31 | DLLExport int MQTTDeserialize_unsubscribe(unsigned char* dup, unsigned short* packetid, int max_count, int* count, MQTTString topicFilters[],
32 | unsigned char* buf, int len);
33 |
34 | DLLExport int MQTTSerialize_unsuback(unsigned char* buf, int buflen, unsigned short packetid);
35 |
36 | DLLExport int MQTTDeserialize_unsuback(unsigned short* packetid, unsigned char* buf, int len);
37 |
38 | #endif /* MQTTUNSUBSCRIBE_H_ */
39 |
--------------------------------------------------------------------------------
/src/paho_mqtt_embedded_c/README.md:
--------------------------------------------------------------------------------
1 | # Eclipse Paho MQTT C/C++ client for Embedded platforms
2 |
3 | This repository contains the source code for the [Eclipse Paho](http://eclipse.org/paho) MQTT C/C++ client library for Embedded platorms.
4 |
5 | It is dual licensed under the EPL and EDL (see about.html and notice.html for more details). You can choose which of these licenses you want to use the code under. The EDL allows you to embed the code into your application, and distribute your application in binary or source form without contributing any of your code, or any changes you make back to Paho. See the EDL for the exact conditions.
6 |
7 | The MQTTPacket directory contains the lowest level C library with the smallest requirements. This supplies simple serialization
8 | and deserialization routines. It is mainly up to you to write and read to and from the network.
9 |
10 | The MQTTClient directory contains the next level C++ library. This still avoids most networking code so that you can plugin the
11 | network of your choice.
12 |
13 | ## Build requirements / compilation
14 |
15 | There are helper scripts (build...) in various directories. The client library is a set of building blocks which you pick and choose from, so that the smallest MQTT application can be built.
16 |
17 | ## Usage and API
18 |
19 | See the samples directory for examples of intended use.
20 |
21 |
22 | ## Runtime tracing
23 |
24 | As yet, there is no tracing. For the smallest client, should we have tracing?
25 |
26 |
27 | ## Reporting bugs
28 |
29 | This project uses GitHub Issues here: [github.com/eclipse/paho.mqtt.embedded-c/issues](https://github.com/eclipse/paho.mqtt.embedded-c/issues) to track ongoing development and issues.
30 |
31 | ## More information
32 |
33 | Discussion of the Paho clients takes place on the [Eclipse paho-dev mailing list](https://dev.eclipse.org/mailman/listinfo/paho-dev).
34 |
35 | General questions about the MQTT protocol are discussed in the [MQTT Google Group](https://groups.google.com/forum/?hl=en-US&fromgroups#!forum/mqtt).
36 |
37 | There is much more information available via the [MQTT community site](http://mqtt.org).
38 |
--------------------------------------------------------------------------------
/src/paho_mqtt_embedded_c/about.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | About
5 |
6 |
7 | About This Content
8 |
9 | December 9, 2013
10 | License
11 |
12 | The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
13 | indicated below, the Content is provided to you under the terms and conditions of the
14 | Eclipse Public License Version 1.0 ("EPL") and Eclipse Distribution License Version 1.0 ("EDL").
15 | A copy of the EPL is available at
16 | http://www.eclipse.org/legal/epl-v10.html
17 | and a copy of the EDL is available at
18 | http://www.eclipse.org/org/documents/edl-v10.php.
19 | For purposes of the EPL, "Program" will mean the Content.
20 |
21 | If you did not receive this Content directly from the Eclipse Foundation, the Content is
22 | being redistributed by another party ("Redistributor") and different terms and conditions may
23 | apply to your use of any object code in the Content. Check the Redistributor's license that was
24 | provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
25 | indicated below, the terms and conditions of the EPL still apply to any source code in the Content
26 | and such source code may be obtained at http://www.eclipse.org.
27 |
28 |
29 |
--------------------------------------------------------------------------------
/src/paho_mqtt_embedded_c/edl-v10:
--------------------------------------------------------------------------------
1 |
2 | Eclipse Distribution License - v 1.0
3 |
4 | Copyright (c) 2007, Eclipse Foundation, Inc. and its licensors.
5 |
6 | All rights reserved.
7 |
8 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
9 |
10 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
11 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
12 | Neither the name of the Eclipse Foundation, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
13 |
14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15 |
16 |
--------------------------------------------------------------------------------
/src/paho_mqtt_embedded_c/platform/network_interface.h:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * \file
4 | *
5 | * \brief Platform network interface
6 | *
7 | * Copyright (c) 2014-2016 Atmel Corporation. All rights reserved.
8 | *
9 | * \asf_license_start
10 | *
11 | * \page License
12 | *
13 | * Redistribution and use in source and binary forms, with or without
14 | * modification, are permitted provided that the following conditions are met:
15 | *
16 | * 1. Redistributions of source code must retain the above copyright notice,
17 | * this list of conditions and the following disclaimer.
18 | *
19 | * 2. Redistributions in binary form must reproduce the above copyright notice,
20 | * this list of conditions and the following disclaimer in the documentation
21 | * and/or other materials provided with the distribution.
22 | *
23 | * 3. The name of Atmel may not be used to endorse or promote products derived
24 | * from this software without specific prior written permission.
25 | *
26 | * 4. This software may only be redistributed and used in connection with an
27 | * Atmel microcontroller product.
28 | *
29 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
30 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
31 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
32 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
33 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
37 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
38 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39 | * POSSIBILITY OF SUCH DAMAGE.
40 | *
41 | * \asf_license_stop
42 | *
43 | */
44 |
45 | #ifndef MQTT_NETWORK_INTERFACE_H
46 | #define MQTT_NETWORK_INTERFACE_H
47 |
48 | #include
49 |
50 | typedef struct mqtt_network {
51 | int (*mqttread)(struct mqtt_network *network, unsigned char *read_buffer, int length, int timeout_ms);
52 | int (*mqttwrite)(struct mqtt_network *network, unsigned char *send_buffer, int length, int timeout_ms);
53 | } Network;
54 |
55 | int mqtt_packet_read(Network *network, unsigned char *read_buffer, int length, int timeout_ms);
56 | int mqtt_packet_write(Network *network, unsigned char *send_buffer, int length, int timeout_ms);
57 |
58 | #endif // MQTT_NETWORK_INTERFACE_H
--------------------------------------------------------------------------------
/src/parson_json/Parson JSON License.txt:
--------------------------------------------------------------------------------
1 | Parson ( http://kgabis.github.com/parson/ )
2 | Copyright (c) 2012 - 2015 Krzysztof Gabis
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in
12 | all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/src/sensor_task.h:
--------------------------------------------------------------------------------
1 | /**
2 | * \file
3 | * \brief Sensor Monitoring and Logic
4 | *
5 | * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries.
6 | * You may use this software and any derivatives exclusively with
7 | * Microchip products.
8 | *
9 | * \page License
10 | *
11 | * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this
12 | * software and any derivatives exclusively with Microchip products.
13 | *
14 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
15 | * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
16 | * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
17 | * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION
18 | * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION.
19 | *
20 | * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
21 | * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
22 | * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
23 | * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
24 | * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN
25 | * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
27 | *
28 | * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE
29 | * TERMS.
30 | */
31 |
32 | #ifndef SENSOR_TASK_H_
33 | #define SENSOR_TASK_H_
34 |
35 | #include "config.h"
36 |
37 | void sensor_task(void);
38 | uint32_t sensor_get_temperature(void);
39 | uint16_t sensor_get_fan_speed(void);
40 |
41 | #ifdef CONFIG_USE_JSON_LIB
42 | #include "parson.h"
43 | bool update_settings_from_json(JSON_Array * json_map);
44 | bool override_from_json(JSON_Object * json_override_object);
45 | #endif
46 |
47 | #endif /* SENSOR_TASK_H_ */
--------------------------------------------------------------------------------
/src/time_utils.h:
--------------------------------------------------------------------------------
1 | /**
2 | * \file
3 | * \brief Date/Time Utilities (RTC)
4 | *
5 | * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries.
6 | * You may use this software and any derivatives exclusively with
7 | * Microchip products.
8 | *
9 | * \page License
10 | *
11 | * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this
12 | * software and any derivatives exclusively with Microchip products.
13 | *
14 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
15 | * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
16 | * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
17 | * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION
18 | * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION.
19 | *
20 | * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
21 | * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
22 | * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
23 | * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
24 | * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN
25 | * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
27 | *
28 | * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE
29 | * TERMS.
30 | */
31 |
32 | #ifndef TIME_UTILS_H_
33 | #define TIME_UTILS_H_
34 |
35 | uint32_t time_utils_get_utc(void);
36 |
37 | uint32_t time_utils_convert(uint32_t year, uint32_t month, uint32_t day, uint32_t hour, uint32_t minute, uint32_t second);
38 | void time_utils_set(uint32_t year, uint32_t month, uint32_t day, uint32_t hour, uint32_t minute, uint32_t second);
39 |
40 |
41 | #endif /* TIME_UTILS_H_ */
--------------------------------------------------------------------------------
/src/tiny_state_machine.h:
--------------------------------------------------------------------------------
1 | /*
2 | * tiny_state_machine.h
3 | */
4 |
5 |
6 | #ifndef TINY_STATE_MACHINE_H_
7 | #define TINY_STATE_MACHINE_H_
8 |
9 | /* Define to include state names */
10 | #define TINY_STATE_MACHINE_WITH_NAMES
11 |
12 | /* Time & Space Efficient State machine handler */
13 |
14 | /* Define the generic state element */
15 | typedef struct {
16 | uint32_t _s; /**< State Value */
17 | #ifdef TINY_STATE_MACHINE_WITH_NAMES
18 | const char* _n; /**< State Name */
19 | #endif
20 | void (*_f)(void*); /**< State Function */
21 | } tiny_state_def;
22 |
23 | /* Define the basic state machine context */
24 | typedef struct {
25 | uint16_t state;
26 | uint16_t count;
27 | tiny_state_def* states;
28 | } tiny_state_ctx;
29 |
30 | /* The most stripped down state machine driver you can create */
31 | static void inline tiny_state_init(void* context, tiny_state_def *states, uint16_t count, uint16_t initial)
32 | {
33 | ((tiny_state_ctx*)context)->states = states;
34 | ((tiny_state_ctx*)context)->count = count;
35 | ((tiny_state_ctx*)context)->state = initial;
36 | }
37 |
38 | /* Search through a states list for the match */
39 | static tiny_state_def * tiny_state_find(tiny_state_def *states, uint16_t count, uint16_t state)
40 | {
41 | uint16_t i;
42 | for(i=0;istates, pCtx->count, pCtx->state);
57 | if(pState && pState->_f)
58 | {
59 | pState->_f(context);
60 | }
61 | }
62 |
63 | /* Update the next state */
64 | static void inline tiny_state_update(void* context, uint32_t next)
65 | {
66 | ((tiny_state_ctx*)context)->state = next;
67 | }
68 |
69 | /* Retrieve the name of the state */
70 | static const char* tiny_state_name(void* context, uint32_t state)
71 | {
72 | #ifdef TINY_STATE_MACHINE_WITH_NAMES
73 | tiny_state_ctx * pCtx = (tiny_state_ctx*)context;
74 | tiny_state_def * pState = tiny_state_find(pCtx->states, pCtx->count, state);
75 |
76 | return (pState && pState->_n)?pState->_n:"";
77 | #else
78 | return "";
79 | #endif
80 | }
81 |
82 | /* Helper macros */
83 | #ifdef TINY_STATE_MACHINE_WITH_NAMES
84 | #define TINY_STATE_DEF(x,y) {x, #x, y}
85 | #else
86 | #define TINY_STATE_DEF(x,y) {x, y}
87 | #endif
88 |
89 |
90 | #endif /* TINY_STATE_MACHINE_H_ */
--------------------------------------------------------------------------------
/src/usb_hid.h:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * \file
4 | *
5 | * \brief USB HID Functions
6 | *
7 | * Copyright (c) 2016-2017 Atmel Corporation. All rights reserved.
8 | *
9 | * \asf_license_start
10 | *
11 | * \page License
12 | *
13 | * Redistribution and use in source and binary forms, with or without
14 | * modification, are permitted provided that the following conditions are met:
15 | *
16 | * 1. Redistributions of source code must retain the above copyright notice,
17 | * this list of conditions and the following disclaimer.
18 | *
19 | * 2. Redistributions in binary form must reproduce the above copyright notice,
20 | * this list of conditions and the following disclaimer in the documentation
21 | * and/or other materials provided with the distribution.
22 | *
23 | * 3. The name of Atmel may not be used to endorse or promote products derived
24 | * from this software without specific prior written permission.
25 | *
26 | * 4. This software may only be redistributed and used in connection with an
27 | * Atmel microcontroller product.
28 | *
29 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
30 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
31 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
32 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
33 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
37 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
38 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39 | * POSSIBILITY OF SUCH DAMAGE.
40 | *
41 | * \asf_license_stop
42 | *
43 | */
44 |
45 | #ifndef USB_HID_H
46 | #define USB_HID_H
47 |
48 | #include
49 | #include
50 |
51 | #include "atca_kit_client.h"
52 |
53 | extern uint8_t g_usb_buffer[KIT_MESSAGE_SIZE_MAX]; //! The USB message buffer
54 | extern uint16_t g_usb_buffer_length; //! The USB message buffer length
55 | extern uint32_t g_usb_message_received; //! Whether the USB message was received
56 |
57 | void usb_hid_init(void);
58 |
59 | bool usb_send_response_message(uint8_t *response, uint16_t response_length);
60 |
61 | bool usb_hid_enable_callback(void);
62 | void usb_hid_disable_callback(void);
63 |
64 | void usb_hid_wakeup_callback(void);
65 |
66 | void usb_hid_report_out_callback(uint8_t *report);
67 | void usb_hid_set_feature_callback(uint8_t *report);
68 |
69 | #endif // USB_HID_H
--------------------------------------------------------------------------------
/src/wifi_task.h:
--------------------------------------------------------------------------------
1 | /**
2 | * \file
3 | * \brief WIFI Management and Abstraction (WINC1500)
4 | *
5 | * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries.
6 | * You may use this software and any derivatives exclusively with
7 | * Microchip products.
8 | *
9 | * \page License
10 | *
11 | * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this
12 | * software and any derivatives exclusively with Microchip products.
13 | *
14 | * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
15 | * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
16 | * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
17 | * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION
18 | * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION.
19 | *
20 | * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
21 | * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
22 | * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
23 | * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
24 | * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN
25 | * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
26 | * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
27 | *
28 | * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE
29 | * TERMS.
30 | */
31 |
32 | #ifndef WIFI_TASK_H_
33 | #define WIFI_TASK_H_
34 |
35 | /* WIFI Control Configuration */
36 |
37 | /** Maximum Allowed SSID Length */
38 | #define WIFI_MAX_SSID_SIZE 32
39 |
40 | /** Maximum Allowed Password Length */
41 | #define WIFI_MAX_PASS_SIZE 64
42 |
43 | /** Maximum Static RX buffer to use */
44 | #define WIFI_BUFFER_SIZE (1500)
45 |
46 | /* Wait times are specified in milliseconds */
47 | #define WIFI_COUNTER_NO_WAIT 0
48 | #define WIFI_COUNTER_GET_TIME_WAIT 10000
49 | #define WIFI_COUNTER_CONNECT_WAIT 10000
50 | #define WIFI_COUNTER_RECONNECT_WAIT 30000
51 |
52 | /* WIFI Control API */
53 | void wifi_task(void);
54 | void wifi_timer_update(void);
55 | int wifi_is_ready(void);
56 | int wifi_is_busy(void);
57 | int wifi_has_error(void);
58 |
59 | /* WIFI Feature API */
60 | void wifi_request_time(void);
61 |
62 | /* WIFI Socket Handling API */
63 | int wifi_connect(char * host, int port);
64 | int wifi_read_data(uint8_t *read_buffer, uint32_t read_length, uint32_t timeout_ms);
65 | int wifi_send_data(uint8_t *send_buffer, uint32_t send_length, uint32_t timeout_ms);
66 |
67 | #endif /* WIFI_TASK_H_ */
--------------------------------------------------------------------------------