aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Native/Tango.ProtoTest/ProtoTester.h
blob: 7bb7ee4d220bffd521ba90d97f353562962f3b07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <cstdlib>
#include "PMR/CalculateRequest.pb.h"
#include "PMR/CalculateResponse.pb.h"

#pragma once

#define EXPORT_API __declspec(dllexport)

using namespace std;
using namespace Tango::PMR::Stubs;

namespace Tango
{
	namespace ProtoTest
	{

		class ProtoTester
		{
		public:
			ProtoTester();
			~ProtoTester();

		};
	}
}

extern "C" EXPORT_API int __cdecl Calculate(unsigned char* data, int size, unsigned char* *output)
{
	CalculateRequest request;
	request.ParseFromArray(data, size);

	CalculateResponse* response = new CalculateResponse();
	response->set_sum(request.a() + request.b());


	unsigned char* stream = (unsigned char*)malloc(response->ByteSize());
	response->SerializeToArray(stream, response->ByteSize());
	*output = stream;

	return response->ByteSize();
}
pan>} public String Name { get { return AccessPoint.Name; } } public double SignalStrength { get { return AccessPoint.SignalStrength; } } public bool IsSecure { get { return AccessPoint.IsSecure; } } public bool HasProfile { get { return AccessPoint.HasProfile; } } private AccessPoint _accessPoint; public AccessPoint AccessPoint { get { return _accessPoint; } set { _accessPoint = value; foreach (var prop in this.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public)) { RaisePropertyChanged(prop.Name); } } } private bool _autoConnect; public bool AutoConnect { get { return _autoConnect; } set { _autoConnect = value; RaisePropertyChangedAuto(); } } private bool _connecting; public bool Connecting { get { return _connecting; } set { _connecting = value; RaisePropertyChangedAuto(); } } private bool _disconnecting; public bool Disconnecting { get { return _disconnecting; } set { _disconnecting = value; RaisePropertyChangedAuto(); } } public WiFiNetwork(AccessPoint accessPoint, Wifi wifi) { _wifi = wifi; AccessPoint = accessPoint; } public WiFiAuthentication CreateAuthenticationRequest() { return new WiFiAuthentication(new AuthRequest(AccessPoint)); } public Task<bool> Connect(WiFiAuthentication request) { return Task.Factory.StartNew<bool>(() => { try { Connecting = true; return AccessPoint.Connect(request.AuthRequest, false); } catch (Exception) { throw; } finally { Connecting = false; } }); } public Task Disconnect() { return Task.Factory.StartNew(() => { try { Disconnecting = true; _wifi.Disconnect(); AccessPoint.DeleteProfile(); } catch (Exception) { throw; } finally { Disconnecting = false; } }); } } }