Created
July 10, 2018 13:17
-
-
Save headHUB/09595c0f676cab5eab379c13ad48e6f1 to your computer and use it in GitHub Desktop.
testscript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<component name="ProjectCodeStyleConfiguration"> | |
<code_scheme name="Project" version="173"> | |
<Objective-C-extensions> | |
<file> | |
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" /> | |
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" /> | |
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" /> | |
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" /> | |
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" /> | |
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" /> | |
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" /> | |
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" /> | |
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" /> | |
</file> | |
<class> | |
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" /> | |
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" /> | |
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" /> | |
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" /> | |
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" /> | |
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" /> | |
</class> | |
<extensions> | |
<pair source="cpp" header="h" fileNamingConvention="NONE" /> | |
<pair source="c" header="h" fileNamingConvention="NONE" /> | |
</extensions> | |
</Objective-C-extensions> | |
</code_scheme> | |
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="JavaScriptSettings"> | |
<option name="languageLevel" value="ES6" /> | |
</component> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="ProjectModuleManager"> | |
<modules> | |
<module fileurl="file://$PROJECT_DIR$/.idea/RaspberryPi-send--ThingSpeak.iml" filepath="$PROJECT_DIR$/.idea/RaspberryPi-send--ThingSpeak.iml" /> | |
</modules> | |
</component> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<module type="CPP_MODULE" version="4"> | |
<component name="NewModuleRootManager"> | |
<content url="file://$MODULE_DIR$" /> | |
<orderEntry type="inheritedJdk" /> | |
<orderEntry type="sourceFolder" forTests="false" /> | |
</component> | |
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="SerialMonitorSettings" BaudRate="9600" LineEndingsIndex="0" /> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="VcsDirectoryMappings"> | |
<mapping directory="$PROJECT_DIR$" vcs="Git" /> | |
</component> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* File: main.c | |
* Author: osc | |
*Test1 | |
* Created on 13. oktober 2015, 15:05 | |
*https://github.com/gabrield/libthingspeak | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include "thingspeak.h" | |
#include "ts_http.h" | |
#include <time.h> | |
/* | |
* | |
*/ | |
int main(int argc, char** argv) { | |
printf("Put your value to update: "); | |
//API key: YP554VA5F9TKWN7J chanel:3227 | |
char n; | |
ts_context_t *ctx = NULL; | |
ts_datapoint_t data; | |
ts_datapoint_t data2; | |
char *result = NULL; | |
//arguments API key, channel | |
ctx = ts_create_context("APKE1QRG2BFAQY00 ", 1); //8JBI3RKMHU9PD1I4, 62438 | |
result = (char*)malloc(sizeof(char)*MAXLINE); | |
bzero(result, MAXLINE); | |
int value; | |
scanf("%d",&value); | |
ts_set_value_i32(&data, value); | |
//n=ts_http_post(ctx, HOST_API, "/update", "field1=21&field2=33"); for more than one data point | |
printf("%s\n", ts_http_get(HOST_API, "/channels/1/feeds/last",result)); | |
ts_datastream_update(ctx, 1, "Field1", &data); | |
printf("%s\n", ts_http_get(HOST_API, "/channels/1/feeds/last",result)); | |
printf("\n\nJSON:\n%s\n", ts_feed_get_all(ctx, 0, TS_DATA_JSON, result)); | |
printf("\n\nCSV:\n%s\n", ts_datastream_get(ctx, 0, TS_DATA_CSV, "Field1", result)); | |
ts_delete_context(ctx); | |
return 0; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# There exist several targets which are by default empty and which can be | |
# used for execution of your targets. These targets are usually executed | |
# before and after some main targets. They are: | |
# | |
# .build-pre: called before 'build' target | |
# .build-post: called after 'build' target | |
# .clean-pre: called before 'clean' target | |
# .clean-post: called after 'clean' target | |
# .clobber-pre: called before 'clobber' target | |
# .clobber-post: called after 'clobber' target | |
# .all-pre: called before 'all' target | |
# .all-post: called after 'all' target | |
# .help-pre: called before 'help' target | |
# .help-post: called after 'help' target | |
# | |
# Targets beginning with '.' are not intended to be called on their own. | |
# | |
# Main targets can be executed directly, and they are: | |
# | |
# build build a specific configuration | |
# clean remove built files from a configuration | |
# clobber remove all built files | |
# all build all configurations | |
# help print help mesage | |
# | |
# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and | |
# .help-impl are implemented in nbproject/makefile-impl.mk. | |
# | |
# Available make variables: | |
# | |
# CND_BASEDIR base directory for relative paths | |
# CND_DISTDIR default top distribution directory (build artifacts) | |
# CND_BUILDDIR default top build directory (object files, ...) | |
# CONF name of current configuration | |
# CND_PLATFORM_${CONF} platform name (current configuration) | |
# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration) | |
# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration) | |
# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration) | |
# CND_PACKAGE_DIR_${CONF} directory of package (current configuration) | |
# CND_PACKAGE_NAME_${CONF} name of package (current configuration) | |
# CND_PACKAGE_PATH_${CONF} path to package (current configuration) | |
# | |
# NOCDDL | |
# Environment | |
MKDIR=mkdir | |
CP=cp | |
CCADMIN=CCadmin | |
# build | |
build: .build-post | |
.build-pre: | |
# Add your pre 'build' code here... | |
.build-post: .build-impl | |
# Add your post 'build' code here... | |
# clean | |
clean: .clean-post | |
.clean-pre: | |
# Add your pre 'clean' code here... | |
.clean-post: .clean-impl | |
# Add your post 'clean' code here... | |
# clobber | |
clobber: .clobber-post | |
.clobber-pre: | |
# Add your pre 'clobber' code here... | |
.clobber-post: .clobber-impl | |
# Add your post 'clobber' code here... | |
# all | |
all: .all-post | |
.all-pre: | |
# Add your pre 'all' code here... | |
.all-post: .all-impl | |
# Add your post 'all' code here... | |
# build tests | |
build-tests: .build-tests-post | |
.build-tests-pre: | |
# Add your pre 'build-tests' code here... | |
.build-tests-post: .build-tests-impl | |
# Add your post 'build-tests' code here... | |
# run tests | |
test: .test-post | |
.test-pre: build-tests | |
# Add your pre 'test' code here... | |
.test-post: .test-impl | |
# Add your post 'test' code here... | |
# help | |
help: .help-post | |
.help-pre: | |
# Add your pre 'help' code here... | |
.help-post: .help-impl | |
# Add your post 'help' code here... | |
# include project implementation makefile | |
include nbproject/Makefile-impl.mk | |
# include project make variables | |
include nbproject/Makefile-variables.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Created by james on 7/10/2018. | |
// | |
extern "C" { | |
#include <asm/termbits.h> | |
#include <sys/ioctl.h> | |
#include <unistd.h> | |
#include <fcntl.h> | |
} | |
#include <iostream> | |
using namespace std; | |
#include "mySerial.h" | |
mySerial::mySerial(string deviceName, int baud) | |
{ | |
handle=-1; | |
Open(deviceName,baud); | |
} | |
mySerial::~mySerial() | |
{ | |
if(handle >=0) | |
Close(); | |
} | |
void mySerial::Close(void) | |
{ | |
if(handle >=0) | |
close(handle); | |
handle = -1; | |
} | |
bool mySerial::Open(string deviceName , int baud) | |
{ | |
struct termios tio; | |
struct termios2 tio2; | |
this->deviceName=deviceName; | |
this->baud=baud; | |
handle = open(this->deviceName.c_str(),O_RDWR | O_NOCTTY /* | O_NONBLOCK */); | |
if(handle <0) | |
return false; | |
tio.c_cflag = CS8 | CLOCAL | CREAD; | |
tio.c_oflag = 0; | |
tio.c_lflag = 0; //ICANON; | |
tio.c_cc[VMIN]=0; | |
tio.c_cc[VTIME]=1; // time out every .1 sec | |
ioctl(handle,TCSETS,&tio); | |
ioctl(handle,TCGETS2,&tio2); | |
tio2.c_cflag &= ~CBAUD; | |
tio2.c_cflag |= BOTHER; | |
tio2.c_ispeed = baud; | |
tio2.c_ospeed = baud; | |
ioctl(handle,TCSETS2,&tio2); | |
// flush buffer | |
ioctl(handle,TCFLSH,TCIOFLUSH); | |
return true; | |
} | |
bool mySerial::IsOpen(void) | |
{ | |
return( handle >=0); | |
} | |
bool mySerial::Send( unsigned char * data,int len) | |
{ | |
if(!IsOpen()) return false; | |
int rlen= write(handle,data,len); | |
return(rlen == len); | |
} | |
bool mySerial::Send( unsigned char value) | |
{ | |
if(!IsOpen()) return false; | |
int rlen= write(handle,&value,1); | |
return(rlen == 1); | |
} | |
bool mySerial::Send(std::string value) | |
{ | |
if(!IsOpen()) return false; | |
int rlen= write(handle,value.c_str(),value.size()); | |
return(rlen == value.size()); | |
} | |
int mySerial::Receive( unsigned char * data, int len) | |
{ | |
if(!IsOpen()) return -1; | |
// this is a blocking receives | |
int lenRCV=0; | |
while(lenRCV < len) | |
{ | |
int rlen = read(handle,&data[lenRCV],len - lenRCV); | |
lenRCV+=rlen; | |
} | |
return lenRCV; | |
} | |
bool mySerial::NumberByteRcv(int &bytelen) | |
{ | |
if(!IsOpen()) return false; | |
ioctl(handle, FIONREAD, &bytelen); | |
return true; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Created by james on 7/10/2018. | |
// | |
#ifndef SERIAL | |
#define SERIAL | |
#include <string> | |
class mySerial | |
{ | |
public: | |
int handle; | |
std::string deviceName; | |
int baud; | |
mySerial(std::string deviceName, int baud); | |
~mySerial(); | |
bool Send( unsigned char * data,int len); | |
bool Send(unsigned char value); | |
bool Send( std::string value); | |
int Receive( unsigned char * data, int len); | |
bool IsOpen(void); | |
void Close(void); | |
bool Open(std::string deviceName, int baud); | |
bool NumberByteRcv(int &bytelen); | |
}; | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<configurationDescriptor version="95"> | |
<logicalFolder name="root" displayName="root" projectFiles="true" kind="ROOT"> | |
<logicalFolder name="HeaderFiles" | |
displayName="Header Files" | |
projectFiles="true"> | |
<itemPath>thingspeak.h</itemPath> | |
<itemPath>ts_http.h</itemPath> | |
<itemPath>ts_time.h</itemPath> | |
</logicalFolder> | |
<logicalFolder name="ResourceFiles" | |
displayName="Resource Files" | |
projectFiles="true"> | |
</logicalFolder> | |
<logicalFolder name="SourceFiles" | |
displayName="Source Files" | |
projectFiles="true"> | |
<itemPath>main.c</itemPath> | |
<itemPath>thingspeak.c</itemPath> | |
<itemPath>ts_http.c</itemPath> | |
<itemPath>ts_time.c</itemPath> | |
</logicalFolder> | |
<logicalFolder name="TestFiles" | |
displayName="Test Files" | |
projectFiles="false" | |
kind="TEST_LOGICAL_FOLDER"> | |
</logicalFolder> | |
<logicalFolder name="ExternalFiles" | |
displayName="Important Files" | |
projectFiles="false" | |
kind="IMPORTANT_FILES_FOLDER"> | |
<itemPath>Makefile</itemPath> | |
</logicalFolder> | |
</logicalFolder> | |
<projectmakefile>Makefile</projectmakefile> | |
<confs> | |
<conf name="Debug" type="1"> | |
<toolsSet> | |
<compilerSet>default</compilerSet> | |
<dependencyChecking>true</dependencyChecking> | |
<rebuildPropChanged>false</rebuildPropChanged> | |
</toolsSet> | |
<compileType> | |
</compileType> | |
<item path="main.c" ex="false" tool="0" flavor2="0"> | |
</item> | |
<item path="thingspeak.c" ex="false" tool="0" flavor2="0"> | |
</item> | |
<item path="thingspeak.h" ex="false" tool="3" flavor2="0"> | |
</item> | |
<item path="ts_http.c" ex="false" tool="0" flavor2="0"> | |
</item> | |
<item path="ts_http.h" ex="false" tool="3" flavor2="0"> | |
</item> | |
<item path="ts_time.c" ex="false" tool="0" flavor2="0"> | |
</item> | |
<item path="ts_time.h" ex="false" tool="3" flavor2="0"> | |
</item> | |
</conf> | |
<conf name="Release" type="1"> | |
<toolsSet> | |
<compilerSet>default</compilerSet> | |
<dependencyChecking>true</dependencyChecking> | |
<rebuildPropChanged>false</rebuildPropChanged> | |
</toolsSet> | |
<compileType> | |
<cTool> | |
<developmentMode>5</developmentMode> | |
</cTool> | |
<ccTool> | |
<developmentMode>5</developmentMode> | |
</ccTool> | |
<fortranCompilerTool> | |
<developmentMode>5</developmentMode> | |
</fortranCompilerTool> | |
<asmTool> | |
<developmentMode>5</developmentMode> | |
</asmTool> | |
</compileType> | |
<item path="main.c" ex="false" tool="0" flavor2="0"> | |
</item> | |
<item path="thingspeak.c" ex="false" tool="0" flavor2="0"> | |
</item> | |
<item path="thingspeak.h" ex="false" tool="3" flavor2="0"> | |
</item> | |
<item path="ts_http.c" ex="false" tool="0" flavor2="0"> | |
</item> | |
<item path="ts_http.h" ex="false" tool="3" flavor2="0"> | |
</item> | |
<item path="ts_time.c" ex="false" tool="0" flavor2="0"> | |
</item> | |
<item path="ts_time.h" ex="false" tool="3" flavor2="0"> | |
</item> | |
</conf> | |
</confs> | |
</configurationDescriptor> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Generated Makefile - do not edit! | |
# | |
# Edit the Makefile in the project folder instead (../Makefile). Each target | |
# has a -pre and a -post target defined where you can add customized code. | |
# | |
# This makefile implements configuration specific macros and targets. | |
# Environment | |
MKDIR=mkdir | |
CP=cp | |
GREP=grep | |
NM=nm | |
CCADMIN=CCadmin | |
RANLIB=ranlib | |
CC=gcc | |
CCC=g++ | |
CXX=g++ | |
FC=gfortran | |
AS=as | |
# Macros | |
CND_PLATFORM=GNU-Linux-x86 | |
CND_DLIB_EXT=so | |
CND_CONF=Debug | |
CND_DISTDIR=dist | |
CND_BUILDDIR=build | |
# Include project Makefile | |
include Makefile | |
# Object Directory | |
OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM} | |
# Object Files | |
OBJECTFILES= \ | |
${OBJECTDIR}/main.o \ | |
${OBJECTDIR}/thingspeak.o \ | |
${OBJECTDIR}/ts_http.o \ | |
${OBJECTDIR}/ts_time.o | |
# C Compiler Flags | |
CFLAGS= | |
# CC Compiler Flags | |
CCFLAGS= | |
CXXFLAGS= | |
# Fortran Compiler Flags | |
FFLAGS= | |
# Assembler Flags | |
ASFLAGS= | |
# Link Libraries and Options | |
LDLIBSOPTIONS= | |
# Build Targets | |
.build-conf: ${BUILD_SUBPROJECTS} | |
"${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/thingspeaksenddata | |
${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/thingspeaksenddata: ${OBJECTFILES} | |
${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM} | |
${LINK.c} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/thingspeaksenddata ${OBJECTFILES} ${LDLIBSOPTIONS} | |
${OBJECTDIR}/main.o: main.c | |
${MKDIR} -p ${OBJECTDIR} | |
${RM} "$@.d" | |
$(COMPILE.c) -g -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/main.o main.c | |
${OBJECTDIR}/thingspeak.o: thingspeak.c | |
${MKDIR} -p ${OBJECTDIR} | |
${RM} "$@.d" | |
$(COMPILE.c) -g -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/thingspeak.o thingspeak.c | |
${OBJECTDIR}/ts_http.o: ts_http.c | |
${MKDIR} -p ${OBJECTDIR} | |
${RM} "$@.d" | |
$(COMPILE.c) -g -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/ts_http.o ts_http.c | |
${OBJECTDIR}/ts_time.o: ts_time.c | |
${MKDIR} -p ${OBJECTDIR} | |
${RM} "$@.d" | |
$(COMPILE.c) -g -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/ts_time.o ts_time.c | |
# Subprojects | |
.build-subprojects: | |
# Clean Targets | |
.clean-conf: ${CLEAN_SUBPROJECTS} | |
${RM} -r ${CND_BUILDDIR}/${CND_CONF} | |
${RM} ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/thingspeaksenddata | |
# Subprojects | |
.clean-subprojects: | |
# Enable dependency checking | |
.dep.inc: .depcheck-impl | |
include .dep.inc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Generated Makefile - do not edit! | |
# | |
# Edit the Makefile in the project folder instead (../Makefile). Each target | |
# has a pre- and a post- target defined where you can add customization code. | |
# | |
# This makefile implements macros and targets common to all configurations. | |
# | |
# NOCDDL | |
# Building and Cleaning subprojects are done by default, but can be controlled with the SUB | |
# macro. If SUB=no, subprojects will not be built or cleaned. The following macro | |
# statements set BUILD_SUB-CONF and CLEAN_SUB-CONF to .build-reqprojects-conf | |
# and .clean-reqprojects-conf unless SUB has the value 'no' | |
SUB_no=NO | |
SUBPROJECTS=${SUB_${SUB}} | |
BUILD_SUBPROJECTS_=.build-subprojects | |
BUILD_SUBPROJECTS_NO= | |
BUILD_SUBPROJECTS=${BUILD_SUBPROJECTS_${SUBPROJECTS}} | |
CLEAN_SUBPROJECTS_=.clean-subprojects | |
CLEAN_SUBPROJECTS_NO= | |
CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}} | |
# Project Name | |
PROJECTNAME=ThingSpeakSendData | |
# Active Configuration | |
DEFAULTCONF=Debug | |
CONF=${DEFAULTCONF} | |
# All Configurations | |
ALLCONFS=Debug Release | |
# build | |
.build-impl: .build-pre .validate-impl .depcheck-impl | |
@#echo "=> Running $@... Configuration=$(CONF)" | |
"${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf | |
# clean | |
.clean-impl: .clean-pre .validate-impl .depcheck-impl | |
@#echo "=> Running $@... Configuration=$(CONF)" | |
"${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf | |
# clobber | |
.clobber-impl: .clobber-pre .depcheck-impl | |
@#echo "=> Running $@..." | |
for CONF in ${ALLCONFS}; \ | |
do \ | |
"${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf; \ | |
done | |
# all | |
.all-impl: .all-pre .depcheck-impl | |
@#echo "=> Running $@..." | |
for CONF in ${ALLCONFS}; \ | |
do \ | |
"${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf; \ | |
done | |
# build tests | |
.build-tests-impl: .build-impl .build-tests-pre | |
@#echo "=> Running $@... Configuration=$(CONF)" | |
"${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-tests-conf | |
# run tests | |
.test-impl: .build-tests-impl .test-pre | |
@#echo "=> Running $@... Configuration=$(CONF)" | |
"${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .test-conf | |
# dependency checking support | |
.depcheck-impl: | |
@echo "# This code depends on make tool being used" >.dep.inc | |
@if [ -n "${MAKE_VERSION}" ]; then \ | |
echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES}))" >>.dep.inc; \ | |
echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \ | |
echo "include \$${DEPFILES}" >>.dep.inc; \ | |
echo "endif" >>.dep.inc; \ | |
else \ | |
echo ".KEEP_STATE:" >>.dep.inc; \ | |
echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \ | |
fi | |
# configuration validation | |
.validate-impl: | |
@if [ ! -f nbproject/Makefile-${CONF}.mk ]; \ | |
then \ | |
echo ""; \ | |
echo "Error: can not find the makefile for configuration '${CONF}' in project ${PROJECTNAME}"; \ | |
echo "See 'make help' for details."; \ | |
echo "Current directory: " `pwd`; \ | |
echo ""; \ | |
fi | |
@if [ ! -f nbproject/Makefile-${CONF}.mk ]; \ | |
then \ | |
exit 1; \ | |
fi | |
# help | |
.help-impl: .help-pre | |
@echo "This makefile supports the following configurations:" | |
@echo " ${ALLCONFS}" | |
@echo "" | |
@echo "and the following targets:" | |
@echo " build (default target)" | |
@echo " clean" | |
@echo " clobber" | |
@echo " all" | |
@echo " help" | |
@echo "" | |
@echo "Makefile Usage:" | |
@echo " make [CONF=<CONFIGURATION>] [SUB=no] build" | |
@echo " make [CONF=<CONFIGURATION>] [SUB=no] clean" | |
@echo " make [SUB=no] clobber" | |
@echo " make [SUB=no] all" | |
@echo " make help" | |
@echo "" | |
@echo "Target 'build' will build a specific configuration and, unless 'SUB=no'," | |
@echo " also build subprojects." | |
@echo "Target 'clean' will clean a specific configuration and, unless 'SUB=no'," | |
@echo " also clean subprojects." | |
@echo "Target 'clobber' will remove all built files from all configurations and," | |
@echo " unless 'SUB=no', also from subprojects." | |
@echo "Target 'all' will will build all configurations and, unless 'SUB=no'," | |
@echo " also build subprojects." | |
@echo "Target 'help' prints this message." | |
@echo "" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Generated Makefile - do not edit! | |
# | |
# Edit the Makefile in the project folder instead (../Makefile). Each target | |
# has a -pre and a -post target defined where you can add customized code. | |
# | |
# This makefile implements configuration specific macros and targets. | |
# Environment | |
MKDIR=mkdir | |
CP=cp | |
GREP=grep | |
NM=nm | |
CCADMIN=CCadmin | |
RANLIB=ranlib | |
CC=gcc | |
CCC=g++ | |
CXX=g++ | |
FC=gfortran | |
AS=as | |
# Macros | |
CND_PLATFORM=GNU-Linux-x86 | |
CND_DLIB_EXT=so | |
CND_CONF=Release | |
CND_DISTDIR=dist | |
CND_BUILDDIR=build | |
# Include project Makefile | |
include Makefile | |
# Object Directory | |
OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM} | |
# Object Files | |
OBJECTFILES= \ | |
${OBJECTDIR}/main.o \ | |
${OBJECTDIR}/thingspeak.o \ | |
${OBJECTDIR}/ts_http.o \ | |
${OBJECTDIR}/ts_time.o | |
# C Compiler Flags | |
CFLAGS= | |
# CC Compiler Flags | |
CCFLAGS= | |
CXXFLAGS= | |
# Fortran Compiler Flags | |
FFLAGS= | |
# Assembler Flags | |
ASFLAGS= | |
# Link Libraries and Options | |
LDLIBSOPTIONS= | |
# Build Targets | |
.build-conf: ${BUILD_SUBPROJECTS} | |
"${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/thingspeaksenddata | |
${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/thingspeaksenddata: ${OBJECTFILES} | |
${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM} | |
${LINK.c} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/thingspeaksenddata ${OBJECTFILES} ${LDLIBSOPTIONS} | |
${OBJECTDIR}/main.o: main.c | |
${MKDIR} -p ${OBJECTDIR} | |
${RM} "$@.d" | |
$(COMPILE.c) -O2 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/main.o main.c | |
${OBJECTDIR}/thingspeak.o: thingspeak.c | |
${MKDIR} -p ${OBJECTDIR} | |
${RM} "$@.d" | |
$(COMPILE.c) -O2 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/thingspeak.o thingspeak.c | |
${OBJECTDIR}/ts_http.o: ts_http.c | |
${MKDIR} -p ${OBJECTDIR} | |
${RM} "$@.d" | |
$(COMPILE.c) -O2 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/ts_http.o ts_http.c | |
${OBJECTDIR}/ts_time.o: ts_time.c | |
${MKDIR} -p ${OBJECTDIR} | |
${RM} "$@.d" | |
$(COMPILE.c) -O2 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/ts_time.o ts_time.c | |
# Subprojects | |
.build-subprojects: | |
# Clean Targets | |
.clean-conf: ${CLEAN_SUBPROJECTS} | |
${RM} -r ${CND_BUILDDIR}/${CND_CONF} | |
${RM} ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/thingspeaksenddata | |
# Subprojects | |
.clean-subprojects: | |
# Enable dependency checking | |
.dep.inc: .depcheck-impl | |
include .dep.inc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Generated - do not edit! | |
# | |
# NOCDDL | |
# | |
CND_BASEDIR=`pwd` | |
CND_BUILDDIR=build | |
CND_DISTDIR=dist | |
# Debug configuration | |
CND_PLATFORM_Debug=GNU-Linux-x86 | |
CND_ARTIFACT_DIR_Debug=dist/Debug/GNU-Linux-x86 | |
CND_ARTIFACT_NAME_Debug=thingspeaksenddata | |
CND_ARTIFACT_PATH_Debug=dist/Debug/GNU-Linux-x86/thingspeaksenddata | |
CND_PACKAGE_DIR_Debug=dist/Debug/GNU-Linux-x86/package | |
CND_PACKAGE_NAME_Debug=thingspeaksenddata.tar | |
CND_PACKAGE_PATH_Debug=dist/Debug/GNU-Linux-x86/package/thingspeaksenddata.tar | |
# Release configuration | |
CND_PLATFORM_Release=GNU-Linux-x86 | |
CND_ARTIFACT_DIR_Release=dist/Release/GNU-Linux-x86 | |
CND_ARTIFACT_NAME_Release=thingspeaksenddata | |
CND_ARTIFACT_PATH_Release=dist/Release/GNU-Linux-x86/thingspeaksenddata | |
CND_PACKAGE_DIR_Release=dist/Release/GNU-Linux-x86/package | |
CND_PACKAGE_NAME_Release=thingspeaksenddata.tar | |
CND_PACKAGE_PATH_Release=dist/Release/GNU-Linux-x86/package/thingspeaksenddata.tar | |
# | |
# include compiler specific variables | |
# | |
# dmake command | |
ROOT:sh = test -f nbproject/private/Makefile-variables.mk || \ | |
(mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk) | |
# | |
# gmake command | |
.PHONY: $(shell test -f nbproject/private/Makefile-variables.mk || (mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk)) | |
# | |
include nbproject/private/Makefile-variables.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -x | |
# | |
# Generated - do not edit! | |
# | |
# Macros | |
TOP=`pwd` | |
CND_PLATFORM=GNU-Linux-x86 | |
CND_CONF=Debug | |
CND_DISTDIR=dist | |
CND_BUILDDIR=build | |
CND_DLIB_EXT=so | |
NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging | |
TMPDIRNAME=tmp-packaging | |
OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/thingspeaksenddata | |
OUTPUT_BASENAME=thingspeaksenddata | |
PACKAGE_TOP_DIR=thingspeaksenddata/ | |
# Functions | |
function checkReturnCode | |
{ | |
rc=$? | |
if [ $rc != 0 ] | |
then | |
exit $rc | |
fi | |
} | |
function makeDirectory | |
# $1 directory path | |
# $2 permission (optional) | |
{ | |
mkdir -p "$1" | |
checkReturnCode | |
if [ "$2" != "" ] | |
then | |
chmod $2 "$1" | |
checkReturnCode | |
fi | |
} | |
function copyFileToTmpDir | |
# $1 from-file path | |
# $2 to-file path | |
# $3 permission | |
{ | |
cp "$1" "$2" | |
checkReturnCode | |
if [ "$3" != "" ] | |
then | |
chmod $3 "$2" | |
checkReturnCode | |
fi | |
} | |
# Setup | |
cd "${TOP}" | |
mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package | |
rm -rf ${NBTMPDIR} | |
mkdir -p ${NBTMPDIR} | |
# Copy files and create directories and links | |
cd "${TOP}" | |
makeDirectory "${NBTMPDIR}/thingspeaksenddata/bin" | |
copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755 | |
# Generate tar file | |
cd "${TOP}" | |
rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/thingspeaksenddata.tar | |
cd ${NBTMPDIR} | |
tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/thingspeaksenddata.tar * | |
checkReturnCode | |
# Cleanup | |
cd "${TOP}" | |
rm -rf ${NBTMPDIR} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -x | |
# | |
# Generated - do not edit! | |
# | |
# Macros | |
TOP=`pwd` | |
CND_PLATFORM=GNU-Linux-x86 | |
CND_CONF=Release | |
CND_DISTDIR=dist | |
CND_BUILDDIR=build | |
CND_DLIB_EXT=so | |
NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging | |
TMPDIRNAME=tmp-packaging | |
OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/thingspeaksenddata | |
OUTPUT_BASENAME=thingspeaksenddata | |
PACKAGE_TOP_DIR=thingspeaksenddata/ | |
# Functions | |
function checkReturnCode | |
{ | |
rc=$? | |
if [ $rc != 0 ] | |
then | |
exit $rc | |
fi | |
} | |
function makeDirectory | |
# $1 directory path | |
# $2 permission (optional) | |
{ | |
mkdir -p "$1" | |
checkReturnCode | |
if [ "$2" != "" ] | |
then | |
chmod $2 "$1" | |
checkReturnCode | |
fi | |
} | |
function copyFileToTmpDir | |
# $1 from-file path | |
# $2 to-file path | |
# $3 permission | |
{ | |
cp "$1" "$2" | |
checkReturnCode | |
if [ "$3" != "" ] | |
then | |
chmod $3 "$2" | |
checkReturnCode | |
fi | |
} | |
# Setup | |
cd "${TOP}" | |
mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package | |
rm -rf ${NBTMPDIR} | |
mkdir -p ${NBTMPDIR} | |
# Copy files and create directories and links | |
cd "${TOP}" | |
makeDirectory "${NBTMPDIR}/thingspeaksenddata/bin" | |
copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755 | |
# Generate tar file | |
cd "${TOP}" | |
rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/thingspeaksenddata.tar | |
cd ${NBTMPDIR} | |
tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/thingspeaksenddata.tar * | |
checkReturnCode | |
# Cleanup | |
cd "${TOP}" | |
rm -rf ${NBTMPDIR} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<configurationDescriptor version="95"> | |
<projectmakefile>Makefile</projectmakefile> | |
<confs> | |
<conf name="Debug" type="1"> | |
<toolsSet> | |
<developmentServer>root@raspb10:22</developmentServer> | |
<platform>2</platform> | |
</toolsSet> | |
<dbx_gdbdebugger version="1"> | |
<gdb_pathmaps> | |
</gdb_pathmaps> | |
<gdb_interceptlist> | |
<gdbinterceptoptions gdb_all="false" gdb_unhandled="true" gdb_unexpected="true"/> | |
</gdb_interceptlist> | |
<gdb_options> | |
<DebugOptions> | |
</DebugOptions> | |
</gdb_options> | |
<gdb_buildfirst gdb_buildfirst_overriden="false" gdb_buildfirst_old="false"/> | |
</dbx_gdbdebugger> | |
<nativedebugger version="1"> | |
<engine>gdb</engine> | |
</nativedebugger> | |
<runprofile version="9"> | |
<runcommandpicklist> | |
<runcommandpicklistitem>"${OUTPUT_PATH}"</runcommandpicklistitem> | |
</runcommandpicklist> | |
<runcommand>"${OUTPUT_PATH}"</runcommand> | |
<rundir></rundir> | |
<buildfirst>true</buildfirst> | |
<terminal-type>0</terminal-type> | |
<remove-instrumentation>0</remove-instrumentation> | |
<environment> | |
</environment> | |
</runprofile> | |
</conf> | |
<conf name="Release" type="1"> | |
<toolsSet> | |
<developmentServer>root@10.16.226.78:22</developmentServer> | |
<platform>2</platform> | |
</toolsSet> | |
<dbx_gdbdebugger version="1"> | |
<gdb_pathmaps> | |
</gdb_pathmaps> | |
<gdb_interceptlist> | |
<gdbinterceptoptions gdb_all="false" gdb_unhandled="true" gdb_unexpected="true"/> | |
</gdb_interceptlist> | |
<gdb_options> | |
<DebugOptions> | |
</DebugOptions> | |
</gdb_options> | |
<gdb_buildfirst gdb_buildfirst_overriden="false" gdb_buildfirst_old="false"/> | |
</dbx_gdbdebugger> | |
<nativedebugger version="1"> | |
<engine>gdb</engine> | |
</nativedebugger> | |
<runprofile version="9"> | |
<runcommandpicklist> | |
<runcommandpicklistitem>"${OUTPUT_PATH}"</runcommandpicklistitem> | |
</runcommandpicklist> | |
<runcommand>"${OUTPUT_PATH}"</runcommand> | |
<rundir></rundir> | |
<buildfirst>true</buildfirst> | |
<terminal-type>0</terminal-type> | |
<remove-instrumentation>0</remove-instrumentation> | |
<environment> | |
</environment> | |
</runprofile> | |
</conf> | |
</confs> | |
</configurationDescriptor> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Launchers File syntax: | |
# | |
# [Must-have property line] | |
# launcher1.runCommand=<Run Command> | |
# [Optional extra properties] | |
# launcher1.displayName=<Display Name, runCommand by default> | |
# launcher1.buildCommand=<Build Command, Build Command specified in project properties by default> | |
# launcher1.runDir=<Run Directory, ${PROJECT_DIR} by default> | |
# launcher1.symbolFiles=<Symbol Files loaded by debugger, ${OUTPUT_PATH} by default> | |
# launcher1.env.<Environment variable KEY>=<Environment variable VALUE> | |
# (If this value is quoted with ` it is handled as a native command which execution result will become the value) | |
# [Common launcher properties] | |
# common.runDir=<Run Directory> | |
# (This value is overwritten by a launcher specific runDir value if the latter exists) | |
# common.env.<Environment variable KEY>=<Environment variable VALUE> | |
# (Environment variables from common launcher are merged with launcher specific variables) | |
# common.symbolFiles=<Symbol Files loaded by debugger> | |
# (This value is overwritten by a launcher specific symbolFiles value if the latter exists) | |
# | |
# In runDir, symbolFiles and env fields you can use these macroses: | |
# ${PROJECT_DIR} - project directory absolute path | |
# ${OUTPUT_PATH} - linker output path (relative to project directory path) | |
# ${OUTPUT_BASENAME}- linker output filename | |
# ${TESTDIR} - test files directory (relative to project directory path) | |
# ${OBJECTDIR} - object files directory (relative to project directory path) | |
# ${CND_DISTDIR} - distribution directory (relative to project directory path) | |
# ${CND_BUILDDIR} - build directory (relative to project directory path) | |
# ${CND_PLATFORM} - platform name | |
# ${CND_CONF} - configuration name | |
# ${CND_DLIB_EXT} - dynamic library extension | |
# | |
# All the project launchers must be listed in the file! | |
# | |
# launcher1.runCommand=... | |
# launcher2.runCommand=... | |
# ... | |
# common.runDir=... | |
# common.env.KEY=VALUE | |
# launcher1.runCommand=<type your run command here> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Generated - do not edit! | |
# | |
# NOCDDL | |
# | |
# Debug configuration | |
# Release configuration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project-private xmlns="http://www.netbeans.org/ns/project-private/1"> | |
<data xmlns="http://www.netbeans.org/ns/make-project-private/1"> | |
<activeConfTypeElem>1</activeConfTypeElem> | |
<activeConfIndexElem>0</activeConfIndexElem> | |
</data> | |
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/> | |
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2"> | |
<group> | |
<file>file:/D:/Documents/NetBeansProjects/ThingSpeakSendData/ts_http.h</file> | |
<file>file:/D:/Documents/NetBeansProjects/ThingSpeakSendData/thingspeak.c</file> | |
<file>file:/D:/Documents/NetBeansProjects/ThingSpeakSendData/main.c</file> | |
<file>file:/D:/Documents/NetBeansProjects/ThingSpeakSendData/thingspeak.h</file> | |
<file>file:/D:/Documents/NetBeansProjects/ThingSpeakSendData/ts_http.c</file> | |
<file>file:/D:/Documents/NetBeansProjects/ThingSpeakSendData/ts_time.c</file> | |
</group> | |
</open-files> | |
</project-private> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Tue Oct 27 16:58:28 CET 2015 | |
d\:\\documents\\netbeansprojects\\thingspeak3\\nbproject\\makefile-impl.mk=c1445955079327 | |
d\:\\documents\\netbeansprojects\\thingspeak3\\ts_http.h=c1445955393184 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\nbproject\\makefile-debug.mk=c1445957956834 | |
d\:\\documents\\netbeansprojects\\thingspeak3\\nbproject\\package-release.bash=c1445955079351 | |
d\:\\documents\\netbeansprojects\\thingspeak3\\nbproject\\makefile-release.mk=c1445957473425 | |
d\:\\documents\\netbeansprojects\\thingspeak3\\ts_http.c=c1445955795573 | |
d\:\\documents\\netbeansprojects\\thingspeak3\\nbproject\\makefile-debug.mk=c1445957761482 | |
d\:\\documents\\netbeansprojects\\thingspeak3\\thingspeak.h=c1445955370012 | |
d\:\\documents\\netbeansprojects\\thingspeak3\\nbproject\\private\\makefile-variables.mk=c1445955079359 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\makefile=c1445955079417 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\nbproject\\private\\makefile-variables.mk=c1445955079359 | |
d\:\\documents\\netbeansprojects\\thingspeak3\\thingspeak.c=c1445956867810 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\nbproject\\makefile-impl.mk=c1445957799187 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\main2.c=c1445957694298 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\thingspeak.h=c1445955370012 | |
VERSION=1.3 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\thingspeak.c=c1445956867810 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\main.c=c1445958280968 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\ts_time.h=c1445955767775 | |
d\:\\documents\\netbeansprojects\\thingspeak3\\nbproject\\package-debug.bash=c1445955079340 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\nbproject\\package-debug.bash=c1445957799215 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\ts_time.c=c1445955667689 | |
d\:\\documents\\netbeansprojects\\thingspeak3\\nbproject\\project.xml=c1445957473457 | |
d\:\\documents\\netbeansprojects\\thingspeak3\\main.cpp=c1445956808762 | |
d\:\\documents\\netbeansprojects\\thingspeak3\\main2.c=c1445957694298 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\nbproject\\makefile-variables.mk=c1445957799252 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\nbproject\\project.xml=c1445957795507 | |
d\:\\documents\\netbeansprojects\\thingspeak3\\ts_time.h=c1445955767775 | |
d\:\\documents\\netbeansprojects\\thingspeak3\\ts_time.c=c1445955667689 | |
d\:\\documents\\netbeansprojects\\thingspeak3\\makefile=c1445955079417 | |
d\:\\documents\\netbeansprojects\\thingspeak3\\nbproject\\makefile-variables.mk=c1445955079357 | |
d\:\\downloads\\1susie\\libthingspeak-master\\src\\makefile=c1412240134000 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\ts_http.h=c1445955393184 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\nbproject\\package-release.bash=c1445957799239 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\nbproject\\makefile-release.mk=c1445957956849 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\ts_http.c=c1445955795573 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Tue Nov 10 10:05:54 CET 2015 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\e8\\630927445d97d24aa5cd2daa980026bc38d771=c1446204458481 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\97\\e84e672871b0985f5cc93f558c4167c2f8413a=c1446216291622 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\index=c1446918475571 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\config=c1446216133530 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\96\\30c67276b7879bac3cf550823311975b2d7b9c=c1446213639630 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\f4\\8b7d7007df0475407a1b4f9ca8c054d2d6365a=c1446216291627 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\6c\\c2127d074d8bc9be0f93c90b425e84b3e5d5ff=c1446204458432 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\e3\\c4acd2c9c2970ae21b60283ba5429768e4a34c=c1446204458530 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\nbproject\\makefile-debug.mk=c1445957956834 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\18\\91a8f42ded9fa83441b0bde756563789f15f9f=c1446204458522 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\c9\\91c9b74c67fcf1103dac013cf3fcfd83828f48=c1446204458445 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\a5\\9e41b195f7328571178668cae1a63642ea1ca3=c1446204458361 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\c7\\ca5c96cd5793a13a8b6a28d80d0131ac7c3a0e=c1446204458435 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\45\\ca81bf3eb6a9d307810e23b02df57fe6cac0b9=c1446216375295 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\logs\\head=c1446216672196 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\05\\de621e858db82f833158636204309122e2dfa5=c1446204458350 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\makefile=c1445955079417 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\58\\c8d5127a523796ca024e7be202aee1fa4d006c=c1446204458525 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\refs\\heads\\master=c1446216672194 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\nbproject\\private\\makefile-variables.mk=c1445955079359 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\a6\\4183e1078487c7564f3af83e8ffe7283062bb2=c1446204458418 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\nbproject\\makefile-impl.mk=c1445957799187 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\f8\\2d742e47834367bb1ab01d059c5e6f5469d035=c1446204458442 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\4b\\6c9479b6010ebe5287fa49fa8b85908100d807=c1446213639600 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\37\\c86baa27f77185a472154304942c576fa3da19=c1446204458401 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\thingspeak.h=c1445955370012 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\25\\3f1c0a0b828a91fc9787236cda0565340115fe=c1446204458394 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\b8\\18e68b2eb958e2a1ba50b7b33c1a1007b72326=c1446204458451 | |
VERSION=1.3 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\thingspeak.c=c1445956867810 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\73\\87905390607c264b4131a7ecc2975a842bfcc9=c1446216291603 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\ea\\3d309860e721da599c3fd4c0f71a8a4df429a0=c1446204458488 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\logs\\refs\\remotes\\origin\\master=c1446216688607 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\f2\\b802526f189067dda007475af1020f7eb0d1d4=c1446213639636 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\main.c=c1447146341491 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\f1\\43f5660434b492ccaa3f5f56ceb5a89999b835=c1446204458466 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\ts_time.h=c1445955767775 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\nbproject\\package-debug.bash=c1445957799215 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\ef\\f120f5d3fe410fb0ef657dbfe04fa584018195=c1446216375269 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\ts_time.c=c1445955667689 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\e1\\b05452fce345eba45f5a071068b6a596a55935=c1446204458413 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\head=c1446203967333 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\0e\\b7063573c677f7db75675eaa7ab4111af824ab=c1446216672157 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\6c\\cde1b4a6814f610d37eed1343ddf7ba7504e4b=c1446204458386 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\24\\fd54768c5a637f005b1211d21e7a6d2709bd4f=c1446204458367 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\nbproject\\makefile-variables.mk=c1445957799252 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\nbproject\\project.xml=c1445957795507 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\d0\\ac3ee0500ba7aeb43f43fbf74bd479f7a160de=c1446216375291 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\4f\\b67d17ffcb170ea13af0b0cb451796b5b00af0=c1446204458517 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\f8\\c7c9fadb8a11e5f8641ca5eb6178a8d21e4004=c1446204458377 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\4e\\b3e9a1bf0fb2cba8be02f0da94f84f5e5e5c0a=c1446204458460 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\f3\\7ab1aa223da36782a06ec0a89654eed5a22537=c1446204458425 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\ts_http.h=c1447145866372 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\nbproject\\package-release.bash=c1445957799239 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\de\\7f1c11ddc4c9b010c4741556d1d1a7cc3a188f=c1446204458475 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\ae\\382aeab15b586c5af4da75ed045288dd0becdd=c1446216672181 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\logs\\refs\\heads\\master=c1446216672197 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\nbproject\\makefile-release.mk=c1445957956849 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\ts_http.c=c1447146180349 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\9a\\8258933f095f5aa90e8df5911b4764d95a6f51=c1446204458409 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\refs\\remotes\\origin\\master=c1446216688604 | |
d\:\\documents\\netbeansprojects\\thingspeaksenddata\\.git\\objects\\31\\f1db94a30480682cae260d3d4256cce5c3f254=c1446216672191 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://www.netbeans.org/ns/project/1"> | |
<type>org.netbeans.modules.cnd.makeproject</type> | |
<configuration> | |
<data xmlns="http://www.netbeans.org/ns/make-project/1"> | |
<name>ThingSpeakSendData</name> | |
<c-extensions>c</c-extensions> | |
<cpp-extensions/> | |
<header-extensions>h</header-extensions> | |
<sourceEncoding>UTF-8</sourceEncoding> | |
<make-dep-projects/> | |
<sourceRootList/> | |
<confList> | |
<confElem> | |
<name>Debug</name> | |
<type>1</type> | |
</confElem> | |
<confElem> | |
<name>Release</name> | |
<type>1</type> | |
</confElem> | |
</confList> | |
<formatting> | |
<project-formatting-style>false</project-formatting-style> | |
</formatting> | |
</data> | |
</configuration> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "thingspeak.h" | |
#include "ts_http.h" | |
#include "ts_time.h" | |
ts_context_t *ts_create_context(char *api_key, ts_feed_id_t feed_id) | |
{ | |
ts_context_t *ctx = NULL; | |
if(api_key != NULL) | |
{ | |
ctx = (ts_context_t*)malloc(sizeof(ts_context_t)); | |
bzero(ctx->api_key, 16); | |
strcpy(ctx->api_key, api_key); | |
ctx->api_key[16] = '\0'; | |
ctx->feed_id = feed_id; | |
} | |
return ctx; | |
} | |
void ts_delete_context(ts_context_t *ctx) | |
{ | |
if(ctx) | |
free(ctx); | |
} | |
ts_datapoint_t *ts_set_value_i32(ts_datapoint_t *datapoint, int32_t val) | |
{ | |
datapoint->value_type = TS_VALUE_TYPE_I32; | |
datapoint->value.i32_value = val; | |
return datapoint; | |
} | |
int32_t ts_get_value_i32(ts_datapoint_t *datapoint) | |
{ | |
return datapoint->value.i32_value; | |
} | |
ts_datapoint_t *ts_set_value_f32(ts_datapoint_t *datapoint, float val) | |
{ | |
datapoint->value_type = TS_VALUE_TYPE_F32; | |
datapoint->value.f32_value = val; | |
return datapoint; | |
} | |
float ts_get_value_f32(ts_datapoint_t *datapoint) | |
{ | |
return datapoint->value.f32_value; | |
} | |
int32_t ts_datastream_update(ts_context_t* ctx, ts_feed_id_t feed_id, char * datastream_id, | |
ts_datapoint_t *datapoint) | |
{ | |
char num[200] = {0}; | |
ssize_t n = 0; | |
ts_context_t *tsx = NULL; | |
ts_tm_t *timeinfo; | |
if(datapoint->timestamp <= 0) | |
timeinfo = ts_settime(datapoint, TS_TIME_LOCAL); | |
switch(datapoint->value_type) | |
{ | |
case TS_VALUE_TYPE_I32: | |
sprintf(num, "%s=%d", datastream_id, datapoint->value.i32_value); | |
break; | |
case TS_VALUE_TYPE_F32: | |
sprintf(num, "%s=%f", datastream_id, datapoint->value.f32_value); | |
break; | |
case TS_VALUE_TYPE_STR: | |
sprintf(num, "%s=%s", datastream_id, datapoint->value.str_value); | |
break; | |
} | |
sprintf(num, "%s&created_at=%d-%d-%d %d:%d:%d", num, (1900/*unix time start*/+timeinfo->tm_year), | |
(timeinfo->tm_mon+1), | |
timeinfo->tm_mday, | |
timeinfo->tm_hour, | |
timeinfo->tm_min, | |
timeinfo->tm_sec); | |
#if TS_DEBUG | |
printf("%s\n", num); | |
#endif | |
if(feed_id == 0) | |
n = ts_http_post(ctx, HOST_API, "/update", num); | |
else | |
{ | |
tsx = ts_create_context(ctx->api_key, feed_id); | |
if(tsx) | |
{ | |
n = ts_http_post(ctx, HOST_API, "/update", num); | |
ts_delete_context(tsx); | |
} | |
else | |
return -1; | |
} | |
return (n > 0) ? 0 : 1; | |
} | |
char *ts_datastream_get(ts_context_t *ctx, ts_feed_id_t feed_id, | |
ts_data_type_t type, | |
char *datastream_id, | |
char *result) | |
{ | |
char *ans = NULL; | |
uint32_t id = 0; | |
char page[128] = {0}; | |
char d_id[2] = {0}; | |
id = (feed_id == 0) ? ctx->feed_id : feed_id; | |
sscanf(datastream_id, "field%s", d_id); | |
switch(type) | |
{ | |
case TS_DATA_CSV: | |
sprintf(page, "/channels/%d/feeds/%s.csv", id, d_id); | |
break; | |
case TS_DATA_XML: | |
sprintf(page, "/channels/%d/feeds/%s.xml", id, d_id); | |
break; | |
case TS_DATA_JSON: | |
sprintf(page, "/channels/%d/feeds/%s.json", id, d_id); | |
break; | |
} | |
#if TS_DEBUG | |
printf("%s\n", page); | |
#endif | |
ans = ts_http_get(HOST_API, page, result); | |
return ans; | |
} | |
char *ts_feed_get_all(ts_context_t* ctx, ts_feed_id_t feed_id, | |
ts_data_type_t type, | |
char *result) | |
{ | |
char *ans = NULL; | |
uint32_t id = 0; | |
char page[128] = {0}; | |
id = (feed_id == 0) ? ctx->feed_id : feed_id; | |
switch(type) | |
{ | |
case TS_DATA_CSV: | |
sprintf(page, "/channels/%d/feeds.csv", id); | |
break; | |
case TS_DATA_XML: | |
sprintf(page, "/channels/%d/feeds.xml", id); | |
break; | |
case TS_DATA_JSON: | |
sprintf(page, "/channels/%d/feeds.json", id); | |
break; | |
} | |
#if TS_DEBUG | |
printf("%s\n", page); | |
#endif | |
ans = ts_http_get(HOST_API, page, result); | |
return ans; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef _THINGSPEAK_H_ | |
#define _THINGSPEAK_H_ | |
#include <stdlib.h> | |
#include <stdint.h> | |
#include <malloc.h> | |
#define TS_MAX_DATASTREAMS 16 | |
#define TS_MAX_DATASTREAM_NAME 16 | |
#define TS_VALUE_STRING_MAX_SIZE 16 | |
#if defined(_WIN64) || defined(_WIN32) | |
#define MEM_SIZE(p) _msize((void*)p) | |
#else | |
#define MEM_SIZE(p) malloc_usable_size((void*)p) | |
#endif | |
typedef uint32_t ts_feed_id_t; | |
typedef long ts_timestamp_t; | |
/** Datapoint value types */ | |
typedef enum | |
{ /* 32-bit signed integer */ | |
TS_VALUE_TYPE_I32 = 0 , | |
/* 32-bit floating point number */ | |
TS_VALUE_TYPE_F32, | |
/* any string-econded data */ | |
TS_VALUE_TYPE_STR | |
} ts_value_type_t; | |
/** Response value types */ | |
typedef enum | |
{ | |
TS_DATA_CSV = 0, | |
TS_DATA_XML, | |
TS_DATA_JSON | |
} ts_data_type_t; | |
typedef union { | |
int32_t i32_value; | |
float f32_value; | |
char str_value[TS_VALUE_STRING_MAX_SIZE]; | |
} ts_datapoint_value_t; | |
typedef struct | |
{ | |
ts_datapoint_value_t value; | |
ts_value_type_t value_type; | |
ts_timestamp_t timestamp; | |
} ts_datapoint_t; | |
typedef struct | |
{ | |
char datastream_id[TS_MAX_DATASTREAM_NAME]; | |
ts_datapoint_t datapoint; | |
} ts_datastream_t; | |
typedef struct | |
{ | |
ts_feed_id_t feed_id; | |
ts_datastream_t datastreams[TS_MAX_DATASTREAMS]; | |
} ts_feed_t; | |
typedef struct | |
{ | |
char api_key[16 + 1]; /* ThingSpeak API key */ | |
ts_feed_id_t feed_id; /* ThingSpeak feed ID */ | |
} ts_context_t; | |
typedef struct | |
{ | |
uint32_t http_retcode; | |
} ts_response_t; | |
/*Context functions*/ | |
ts_context_t *ts_create_context(char *, ts_feed_id_t); | |
void ts_delete_context(ts_context_t *); | |
/*Datapoint values functions */ | |
ts_datapoint_t *ts_set_value_i32(ts_datapoint_t *, int32_t); | |
int32_t ts_get_value_i32(ts_datapoint_t *); | |
ts_datapoint_t *ts_set_value_f32(ts_datapoint_t *, float); | |
float ts_get_value_f32(ts_datapoint_t *); | |
/* Datastream functions */ | |
int32_t ts_datastream_update(ts_context_t *, ts_feed_id_t, char *, ts_datapoint_t *); | |
char *ts_datastream_get(ts_context_t *, ts_feed_id_t, ts_data_type_t, char *, char *); | |
/* Datastream functions */ | |
char *ts_feed_get_all(ts_context_t *, ts_feed_id_t, ts_data_type_t type, char *); | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "thingspeak.h" | |
#include "ts_http.h" | |
ssize_t ts_http_post(ts_context_t *ctx, char *host, char *page, char *poststr) | |
{ | |
int sockfd; | |
struct sockaddr_in servaddr; | |
char sendline[MAXLINE + 1], recvline[MAXLINE + 1]; | |
ssize_t n; | |
struct hostent *hptr; | |
char hstr[50]; | |
if ((hptr = gethostbyname(host)) == NULL) { | |
fprintf(stderr, "gethostbyname error for host: %s: %s", | |
host, hstrerror(h_errno)); | |
return -1; | |
} | |
if ((hptr->h_addrtype == AF_INET) && (hptr->h_addr_list) != NULL) { | |
inet_ntop(hptr->h_addrtype, hptr->h_addr_list[0], hstr, sizeof(hstr)); | |
} | |
else | |
{ | |
fprintf(stderr, "Error call inet_ntop \n"); | |
} | |
sockfd = socket(AF_INET, SOCK_STREAM, 0); | |
bzero(&servaddr, sizeof(servaddr)); | |
servaddr.sin_family = AF_INET; | |
servaddr.sin_port = htons(3000); // CHANGED PORT. | |
inet_pton(AF_INET, hstr, &servaddr.sin_addr); | |
connect(sockfd, (SA *) & servaddr, sizeof(servaddr)); | |
snprintf(sendline, MAXSUB, | |
"POST %s HTTP/1.1\r\n" | |
"Host: %s\r\n" | |
"Connection: close\r\n" | |
"X-THINGSPEAKAPIKEY: %s\r\n" | |
"Content-Type: application/x-www-form-urlencoded\r\n" | |
"Content-Length: %lu\r\n\r\n" | |
"%s", | |
page, | |
host, | |
ctx->api_key, | |
strlen(poststr), | |
poststr); | |
#if TS_DEBUG | |
printf("%s\n\n\n", sendline); | |
#endif | |
write(sockfd, sendline, strlen(sendline)); | |
while ((n = read(sockfd, recvline, MAXLINE)) > 0) | |
{ | |
recvline[n] = '\0'; | |
#if TS_DEBUG | |
printf("%s", recvline); | |
#endif | |
} | |
close(sockfd); | |
return n; | |
} | |
char *ts_http_get(char *host, char *page, char *buffer) | |
{ | |
int sockfd; | |
FILE *sockwrap = NULL; | |
struct sockaddr_in servaddr; | |
/*char buffer[MAXLINE];*/ | |
ssize_t n; | |
struct hostent *hptr; | |
char hstr[50]; | |
/*char *http_ans = NULL;*/ | |
int headers = 1; | |
if ((hptr = gethostbyname(host)) == NULL) { | |
fprintf(stderr, "gethostbyname error for host: %s: %s", host, hstrerror(h_errno)); | |
return NULL; | |
} | |
#if TS_DEBUG | |
printf("hostname: %s\n", hptr->h_name); | |
#endif | |
if ((hptr->h_addrtype == AF_INET) && (hptr->h_addr_list) != NULL) | |
inet_ntop(hptr->h_addrtype, hptr->h_addr_list[0], hstr, sizeof(hstr)); | |
else | |
fprintf(stderr, "Error call inet_ntop \n"); | |
sockfd = socket(AF_INET, SOCK_STREAM, 0); | |
bzero(&servaddr, sizeof(servaddr)); | |
servaddr.sin_family = AF_INET; | |
servaddr.sin_port = htons(3000); // CHANGED PORT | |
inet_pton(AF_INET, hstr, &servaddr.sin_addr); | |
connect(sockfd, (SA *) & servaddr, sizeof(servaddr)); | |
sprintf(buffer, "GET %s HTTP/1.0\r\n" | |
"Host: %s\r\n\r\n", | |
page, host); | |
n = strlen(buffer); | |
if(send(sockfd, buffer, strlen(buffer), 0) != n) | |
fprintf(stderr, "Error call send()\n"); | |
bzero(buffer, MAXLINE); | |
sockwrap = fdopen(sockfd, "r"); | |
if(fgets(buffer, MEM_SIZE(buffer), sockwrap) == NULL) | |
{ | |
if (ferror(sockwrap)) | |
fprintf(stderr, "Error sockwrap\n"); | |
else | |
fprintf(stderr, "No response: timeout\n"); | |
} | |
if(strstr(buffer, "200") == NULL) | |
{ | |
/* If fails, print the line */ | |
fprintf(stderr, "%s\n", buffer); | |
return NULL; | |
} | |
/*Skip over headers by going to single blank line*/ | |
while(headers) | |
{ | |
if (fgets(buffer, MEM_SIZE(buffer), sockwrap) == NULL) | |
{ | |
if(ferror(sockwrap)) | |
fprintf(stderr, "Error sockwrap\n"); | |
else | |
fprintf(stderr, "No response: timeout\n"); | |
} | |
if(strcmp("\r\n", buffer) == 0) | |
headers = 0; | |
} | |
fread(buffer, strlen(buffer), MEM_SIZE(buffer), sockwrap); | |
fclose(sockwrap); | |
close(sockfd); | |
return buffer; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef _TS_HTTP_H_ | |
# define _TS_HTTP_ | |
#include <arpa/inet.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <netdb.h> | |
#include <unistd.h> | |
#define SA struct sockaddr | |
#define MAXLINE 8192 | |
#define MAXSUB 1024 | |
#define LISTENQ 1024 | |
#define HOST_API "192.168.112.102"//"api.thingspeak.com" | |
extern int h_errno; | |
ssize_t ts_http_post(ts_context_t *, char *, char *, char *); | |
char *ts_http_get(char *, char *, char *); | |
#endif /*_TS_HTTP_*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "ts_time.h" | |
ts_tm_t *ts_settime(ts_datapoint_t *datapoint, ts_time_type_t type) | |
{ | |
ts_tm_t *timeinfo = NULL; | |
time((time_t*)&datapoint->timestamp); | |
switch(type) | |
{ | |
case TS_TIME_LOCAL: | |
timeinfo = (ts_tm_t*)localtime((time_t*)&datapoint->timestamp); | |
break; | |
case TS_TIME_GMT: | |
timeinfo = (ts_tm_t*)gmtime((time_t*)&datapoint->timestamp); | |
break; | |
} | |
return timeinfo; | |
} | |
void ts_mktime(ts_datapoint_t *datapoint, int year, int month, int mday, int hour, | |
int min, | |
int sec) | |
{ | |
ts_tm_t *timeinfo = NULL; | |
time((time_t*)&datapoint->timestamp); | |
timeinfo = localtime((time_t*)&datapoint->timestamp); | |
timeinfo->tm_year = year - 1900; | |
timeinfo->tm_mon = month - 1; | |
timeinfo->tm_mday = mday, | |
timeinfo->tm_hour = hour; | |
timeinfo->tm_min = min; | |
timeinfo->tm_sec = sec; | |
datapoint->timestamp = mktime (timeinfo); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef _TS_TIME_H_ | |
#define _TS_TIME_H_ | |
#include "thingspeak.h" | |
#include "time.h" | |
typedef struct tm ts_tm_t; | |
typedef enum | |
{ | |
TS_TIME_LOCAL = 0 , | |
TS_TIME_GMT | |
} ts_time_type_t; | |
/* set local time to datapoint */ | |
ts_tm_t *ts_settime(ts_datapoint_t *, ts_time_type_t); | |
/* create time to datapoint */ | |
void ts_mktime(ts_datapoint_t *, int, int, int, int, int, int); | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment