Skip to content

Commit

Permalink
Merge pull request #32 from kaaproject/develop/v1.1.1
Browse files Browse the repository at this point in the history
Develop/v1.1.1
  • Loading branch information
ashvayka committed Dec 29, 2015
2 parents 78ccf2a + 7f55614 commit 62948ca
Show file tree
Hide file tree
Showing 19 changed files with 666 additions and 120 deletions.
2 changes: 1 addition & 1 deletion citylights-controller/assembly/src-java.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<fileSet>
<directory>${project.build.directory}/lib</directory>
<useDefaultExcludes>true</useDefaultExcludes>
<outputDirectory>CityLightsController</outputDirectory>
<outputDirectory>CityLightsController/lib</outputDirectory>
</fileSet>
</fileSets>
</assembly>
2 changes: 1 addition & 1 deletion configurationdemo/assembly/src-java.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<fileSet>
<directory>${project.build.directory}/lib</directory>
<useDefaultExcludes>true</useDefaultExcludes>
<outputDirectory>JConfigurationDemo</outputDirectory>
<outputDirectory>JConfigurationDemo/lib</outputDirectory>
</fileSet>
</fileSets>
</assembly>
61 changes: 38 additions & 23 deletions configurationdemo/source/cpp/src/KaaDemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,27 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <memory>
#include <thread>

#include <kaa/Kaa.hpp>
#include <kaa/IKaaClient.hpp>

#include <kaa/configuration/storage/IConfigurationPersistenceManager.hpp>
#include <kaa/configuration/manager/IConfigurationReceiver.hpp>
#include <kaa/configuration/storage/FileConfigurationStorage.hpp>

#include <kaa/logging/Log.hpp>

#include <stdio.h>

using namespace kaa;

using std::cout;
using std::endl;

const char savedConfig[] = "saved_config.cfg";

class UserConfigurationReceiver : public IConfigurationReceiver {
public:
void displayConfiguration(const KaaRootConfiguration &configuration)
{
if (!configuration.AddressList.is_null()) {
cout << "Configuration body:" << endl;
std::cout << "Configuration body:" << std::endl;
auto links = configuration.AddressList.get_array();
for (auto& e : links) {
cout << e.label << " - " << e.url << endl;
std::cout << e.label << " - " << e.url << std::endl;
}
}
}
Expand All @@ -53,19 +45,42 @@ class UserConfigurationReceiver : public IConfigurationReceiver {

int main()
{
Kaa::init();
cout << "Configuration demo started" << endl;
cout << "--= Press Enter to exit =--" << endl;
IKaaClient& kaaClient = Kaa::getKaaClient();
// Set up a configuration subsystem.
std::cout << "Configuration demo started" << std::endl;
std::cout << "--= Press Enter to exit =--" << std::endl;

/*
* Initialize the Kaa endpoint.
*/
auto kaaClient = Kaa::newClient();

/*
* Set up a configuration subsystem.
*/
IConfigurationStoragePtr storage(std::make_shared<FileConfigurationStorage>(savedConfig));
kaaClient.setConfigurationStorage(storage);
kaaClient->setConfigurationStorage(storage);

/*
* Set configuration update receiver.
*/
UserConfigurationReceiver receiver;
kaaClient.addConfigurationListener(receiver);
Kaa::start();
// Waiting for Enter key pressed before exiting.
kaaClient->addConfigurationListener(receiver);

/*
* Run the Kaa endpoint.
*/
kaaClient->start();

/*
* Wait for the Enter key before exiting.
*/
std::cin.get();
Kaa::stop();
cout << "Configuration demo stopped" << endl;

/*
* Stop the Kaa endpoint.
*/
kaaClient->stop();

std::cout << "Configuration demo stopped" << std::endl;

return 0;
}
2 changes: 1 addition & 1 deletion datacollectiondemo/assembly/src-java.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<fileSet>
<directory>${project.build.directory}/lib</directory>
<useDefaultExcludes>true</useDefaultExcludes>
<outputDirectory>JDataCollectionDemo</outputDirectory>
<outputDirectory>JDataCollectionDemo/lib</outputDirectory>
</fileSet>
</fileSets>
</assembly>
56 changes: 24 additions & 32 deletions datacollectiondemo/source/cpp/src/KaaDemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,56 +16,44 @@


#include <memory>
#include <thread>
#include <cstdint>
#include <string>

#include <kaa/Kaa.hpp>
#include <kaa/log/ILogStorageStatus.hpp>
#include <kaa/log/DefaultLogUploadStrategy.hpp>
#include <kaa/log/strategies/RecordCountLogUploadStrategy.hpp>
#include <kaa/KaaThread.hpp>

using namespace kaa;

// The default strategy uploads logs after either a threshold logs count
// or a threshold logs size has been reached.
// The following custom strategy uploads every log record as soon as it is created.
class LogUploadStrategy : public DefaultLogUploadStrategy {
public:
LogUploadStrategy() : DefaultLogUploadStrategy() {}

virtual LogUploadStrategyDecision isUploadNeeded(ILogStorageStatus& status)
{
if (status.getRecordsCount() >= 1) {
return LogUploadStrategyDecision::UPLOAD;
}
return LogUploadStrategyDecision::NOOP;
}
};

/*
* A demo application that shows how to use the Kaa logging API.
*/
int main()
{
const std::size_t LOGS_TO_SEND_COUNT = 5;

std::cout << "Data collection demo started" << std::endl;
std::cout << "--= Press Enter to exit =--" << std::endl;

//Create a Kaa client with the Kaa desktop context.
Kaa::init();
IKaaClient& kaaClient = Kaa::getKaaClient();
const std::size_t LOGS_TO_SEND_COUNT = 5;

/*
* Initialize the Kaa endpoint.
*/
auto kaaClient = Kaa::newClient();

// Set a custom strategy for uploading logs.
kaaClient.setLogUploadStrategy(std::make_shared<LogUploadStrategy>());
/*
* Set a custom strategy for uploading logs.
*/
kaaClient->setLogUploadStrategy(std::make_shared<RecordCountLogUploadStrategy>(1));

// Start the Kaa client and connect it to the Kaa server.
Kaa::start();
/*
* Run the Kaa endpoint.
*/
kaaClient->start();


// Send LOGS_TO_SEND_COUNT logs in a loop.
size_t logNumber = 0;
std::size_t logNumber = 0;
while (logNumber++ < LOGS_TO_SEND_COUNT) {
KaaUserLogRecord logRecord;
logRecord.level = kaa_log::Level::KAA_INFO;
Expand All @@ -74,14 +62,18 @@ int main()

std::cout << "Going to send " << logNumber << "th record" << std::endl;

kaaClient.addLogRecord(logRecord);
kaaClient->addLogRecord(logRecord);
}

// Wait for the Enter key before exiting.
/*
* Wait for the Enter key before exiting.
*/
std::cin.get();

// Stop the Kaa client and release all the resources which were in use.
Kaa::stop();
/*
* Stop the Kaa endpoint.
*/
kaaClient->stop();

std::cout << "Data collection demo stopped" << std::endl;

Expand Down
2 changes: 1 addition & 1 deletion eventdemo/assembly/src-java.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<fileSet>
<directory>${project.build.directory}/lib</directory>
<useDefaultExcludes>true</useDefaultExcludes>
<outputDirectory>JEventDemo</outputDirectory>
<outputDirectory>JEventDemo/lib</outputDirectory>
</fileSet>
</fileSets>
</assembly>
34 changes: 20 additions & 14 deletions eventdemo/source/cpp/src/KaaDemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@


#include <memory>
#include <thread>
#include <string>
#include <cstdint>
#include <iostream>

#include <kaa/Kaa.hpp>
#include <kaa/event/registration/IUserAttachCallback.hpp>
#include <kaa/event/IFetchEventListeners.hpp>
#include <kaa/event/gen/ThermostatEventClassFamilyGen.hpp>
#include <kaa/event/gen/EventFamilyFactory.hpp>
#include <kaa/event/gen/ThermostatEventClassFamily.hpp>

using namespace kaa;

Expand Down Expand Up @@ -136,33 +137,38 @@ class UserAttachCallback: public IUserAttachCallback {

int main()
{
const char * const KAA_USER_ID = "user@email.com";
const char * const KAA_USER_ACCESS_TOKEN = "token";
std::cout << "Event demo started" << std::endl;
std::cout << "--= Press Enter to exit =--" << std::endl;

const std::string KAA_USER_ID("user@email.com");
const std::string KAA_USER_ACCESS_TOKEN("token");

/*
* Initialize the Kaa endpoint.
*/
Kaa::init();
IKaaClient& kaaClient = Kaa::getKaaClient();

auto kaaClient = Kaa::newClient();

/*
* Run the Kaa endpoint.
*/
Kaa::start();
kaaClient->start();

ThermoEventClassFamilyListener thermoListener(kaaClient.getEventFamilyFactory());
ThermoEventClassFamilyListener thermoListener(kaaClient->getEventFamilyFactory());

kaaClient.getEventFamilyFactory().getThermostatEventClassFamily().addEventFamilyListener(thermoListener);
kaaClient.attachUser(KAA_USER_ID, KAA_USER_ACCESS_TOKEN, std::make_shared<UserAttachCallback>(kaaClient));
kaaClient->getEventFamilyFactory().getThermostatEventClassFamily().addEventFamilyListener(thermoListener);
kaaClient->attachUser(KAA_USER_ID, KAA_USER_ACCESS_TOKEN, std::make_shared<UserAttachCallback>(*kaaClient));

while (1)
std::this_thread::sleep_for(std::chrono::seconds(1));
/*
* Wait for the Enter key before exiting.
*/
std::cin.get();

/*
* Stop the Kaa endpoint.
*/
Kaa::stop();
kaaClient->stop();

std::cout << "Event demo stopped" << std::endl;

return 0;
}
32 changes: 32 additions & 0 deletions gpiocontrol/assembly/src-artik5.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!--
Copyright 2014-2015 CyberVision, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>gpio-src-artik5</id>
<formats>
<format>tar.gz</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${project.basedir}/source/artik5</directory>
<useDefaultExcludes>true</useDefaultExcludes>
<outputDirectory>gpio-artik5-client</outputDirectory>
</fileSet>
</fileSets>
</assembly>
45 changes: 23 additions & 22 deletions gpiocontrol/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@
<configuration>
<descriptors>
<descriptor>${project.basedir}/assembly/src.xml</descriptor>
<descriptor>assembly/src-cc32xx.xml</descriptor>
<descriptor>assembly/src-esp.xml</descriptor>
<descriptor>${project.basedir}/assembly/src-cc32xx.xml</descriptor>
<descriptor>${project.basedir}/assembly/src-esp.xml</descriptor>
<descriptor>${project.basedir}/assembly/src-artik5.xml</descriptor>
</descriptors>
</configuration>
<executions>
Expand All @@ -74,26 +75,26 @@
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>generate-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/generated-resources/demo/gpiocontrol</outputDirectory>
<resources>
<resource>
<directory>resources</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>generate-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/generated-resources/demo/gpiocontrol</outputDirectory>
<resources>
<resource>
<directory>resources</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Binary file added gpiocontrol/resources/gpio_slave_artik5/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 62948ca

Please sign in to comment.