Good afternoon,
I’m currently having trouble trying to make a companion application for my Android phone and Samsung Watch. No matter what I do I can’t get them to connect, below is the code I used in the .NET app version.
.NET Service Accessory
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<application name="FireMate">
<serviceProfile id="/sample/hellofiremate"
name="helloaccessory"
role="consumer"
version="1.0">
<supportedTransports>
<transport type="TRANSPORT_BT"/>
<transport type="TRANSPORT_WIFI"/>
</supportedTransports>
<serviceChannel id="104" dataRate="low" priority="low"
reliability="enable">
</serviceChannel>
</serviceProfile>
</application>
</resources>
``
**.NET Application**
using Samsung.Sap;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xamarin.Forms;
namespace Tester_Firemate_version_4
{
public class App : Application
{
private Agent Agent;
private Connection Connection;
public App()
{
Console.WriteLine("Work mother fer");
// The root page of your application
MainPage = new ContentPage
{
Content = new StackLayout
{
VerticalOptions = LayoutOptions.Center,
Children = {
new Button {
Text = "Connect",
Command = new Command(Connect)
}
}
}
};
}
private async void Connect()
{
try
{
Console.WriteLine("At the Agent!!!!");
Agent = await Agent.GetAgent("/sample/hellofiremate");
var peers = await Agent.FindPeers();
if (peers.Count() > 0)
{
var peer = peers.First();
Connection = peer.Connection;
Connection.DataReceived -= Connection_DataReceived;
Connection.DataReceived += Connection_DataReceived;
await Connection.Open();
}
else
{
//Toast.DisplayText("Any peer not found");
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
//Toast.DisplayText(ex.Message);
}
}
private void Connection_DataReceived(object sender, DataReceivedEventArgs e)
{
//Toast.DisplayText("Message received");
}
protected override void OnStart()
{
// Handle when your app starts
}
protected override void OnSleep()
{
// Handle when your app sleeps
}
protected override void OnResume()
{
// Handle when your app resumes
}
}
}
**Android Service Accessory**
<resources>
<application name="FireMateWebWatch" >
<serviceProfile
id="/sample/hellofiremate"
name="helloaccessory"
role="provider"
serviceImpl="au.com.twentysixfifty.firematewebwatch.ProviderService"
version="1.0"
serviceLimit="ANY"
serviceTimeout="10">
<supportedTransports>
<transport type="TRANSPORT_BT" />
<transport type="TRANSPORT_WIFI" />
</supportedTransports>
<serviceChannel
id="104"
dataRate="low"
priority="low"
reliability= "enable"/>
</serviceProfile>
</application>
</resources>
All I want it to do initially is make a connection with the Accessory Service, and pick up if or if not there are peers present.
Thanks in advance..