Пример #1
0
 private bool VerifyBleRequest(BleRequest request)
 {
     return(request != null &&
            !string.IsNullOrEmpty(request.DeviceUuid) &&
            !string.IsNullOrEmpty(request.ServiceUuid) &&
            !string.IsNullOrEmpty(request.CharacteristicUuid));
 }
Пример #2
0
        [ProducesResponseType(typeof(object), (int)HttpStatusCode.Accepted)]      // everything's OK
        public async Task <IActionResult> ReadFromCharacteristic([FromBody] BleRequest request)
        {
            if (!VerifyBleRequest(request))
            {
                return(BadRequest(
                           new
                {
                    data = request,
                    message = "Bad or missing data"
                }));
            }
            var res = await _blutoothService.ReadFromCharacteristic(request.DeviceUuid,
                                                                    request.ServiceUuid, request.CharacteristicUuid);

            return(res.ToActionResult());
        }
Пример #3
0
        [ProducesResponseType(typeof(object), (int)HttpStatusCode.Accepted)]      // everything's OK
        public async Task <IActionResult> WriteToCharacteristic([FromBody] BleRequest request)
        {
            if (!(VerifyBleRequest(request) && request.Buffer != null && request.Buffer.Any()))
            {
                return(BadRequest(
                           new
                {
                    data = request,
                    message = "Bad or missing data"
                }));
            }

            var res = await _blutoothService.WriteToCharacteristic(request.DeviceUuid,
                                                                   request.ServiceUuid, request.CharacteristicUuid, request.Buffer);

            return(res.ToActionResult());
        }