示例#1
0
        public async Task <ServiceResponse <string> > GetCharacteristicNotifications(string deviceUuid, string serviceUuid, string characteristicUuid)
        {
            bool res;
            var  errMessage = "";
            var  response   = new ServiceResponse <string>
            {
                Data = characteristicUuid,
            };

            try
            {
                res = await _bluetoothManager.RegisterToCharacteristicNotifications(deviceUuid, serviceUuid, characteristicUuid);
            }
            catch (Exception e)
            {
                res             = false;
                errMessage      = "\nInternal Error: " + e.Message;
                response.Result = ServiceResponseResult.NotAcceptable;
            }

            response.Result = response.Result != ServiceResponseResult.NotSet ?
                              response.Result :
                              res ? ServiceResponseResult.Success : ServiceResponseResult.Fail;


            if (!res)
            {
                response.Message =
                    $"Failed to register to characteristic notifications. device Id: \'{deviceUuid}\' gatt-service Id: \'{serviceUuid}\' characteristic id: \'{characteristicUuid}\'{errMessage}";
            }
            return(response);
        }