c# - How can I connect to a Bluetooth service on Gear S3? -
i writing web app gear s3 , companion win-app uwp in c#. want do: s3 acting bt server, sending data, , win-app client, supposed receive data. in tizen used registerrfcommservicebyuuid() function below:
function publishtransferservice() { if(remotedevice.isconnented){ console.log("connection status: " + remotedevice.isconnected); var trans_service_uuid = '5bce9431-6c75-32ab-afe0-2ec108a30860'; adapter.registerrfcommservicebyuuid(trans_service_uuid, 'my service', servicesuccesscb, function(e) { console.log( "could not register service record, error: " + e.message); }); }else{ console.error("connection status: " + remotedevice.isconnected); }
in c# try connect service follows:
//to ulong converted mac-address of gear ulong gearbtaddress = 145914022804881; //create device-instance of gear bluetoothdevice geardevice = await bluetoothdevice.frombluetoothaddressasync(gearbtaddress); //list services found on gear , connect 1 //the same uuid in tizen var gearservices = await geardevice.getrfcommservicesasync(); foreach (var service in gearservices.services) { if(service.serviceid == rfcommserviceid.fromuuid(guid.parse("5bce9431-6c75-32ab-afe0-2ec108a30860"))) { _service = await rfcommdeviceservice.fromidasync(service.tostring()); } }
the problem facing is, c# won't find wanted uuid, although finds several other uuids. don't see gets lost?
thanks in advance.
i solved myself, problem was, uuid uncached. adding following do:
var cachemode = bluetoothcachemode.uncached; var gearservices = await geardevice.getrfcommservicesasync(cachemode);
Comments
Post a Comment