Skip to content

Write a command without respose. #271

@jatin141141

Description

@jatin141141

Screenshot 2024-02-07 at 8 10 11 PM

let OP_CODE_REPORT_STORED_RECORDS: UInt8 = 0x99
var OPERATOR_SENDING_RECORD_1: UInt8 = 0x00
var OPERATOR_SENDING_RECORD_2: UInt8 = 0x19

        let command: [UInt8] = [OP_CODE_REPORT_STORED_RECORDS, OPERATOR_SENDING_RECORD_1, OPERATOR_SENDING_RECORD_2]

        bluejay.write(to: sensorLocation, value: Data(command), type: .withResponse) { result in
            switch result {
            case .success:
                print("Write to sensor location is successful.")
                bluejay.read(from: sensorLocation) { [weak self] (result: ReadResult<Data>) in
                    guard let weakSelf = self else {
                         return
                    }
                    
                    switch result {
                    case .success(let data):
                       print(data)
                        let hexStringResult = weakSelf.hexString(from: data)
                        print("Hex String: \(hexStringResult)")
                        let yourDataByte = [UInt8](data)
                        print("Byte Data-----", yourDataByte)
                        
                    case .failure(let error):
                        debugPrint("Failed to read sensor location with error: \(error.localizedDescription)")
                    }
                }
            case .failure(let error):
                print("Failed to write sensor location with error: \(error.localizedDescription)")
            }
        }

We are using this method to get the data from the device write command is successfully response but when we are read the data getting 0 bytes value please check the screen shot.

Log :

Write to Characteristic: 0000FF01-0000-1000-8000-00805F9B34FB, Service: 0000FF12-0000-1000-8000-00805F9B34FB on 6FB59BAF-EEBC-BA48-6285-069A7386A1FB is successful.
LOG====== Started read for Characteristic: 0000FF01-0000-1000-8000-00805F9B34FB, Service: 0000FF12-0000-1000-8000-00805F9B34FB on 6FB59BAF-EEBC-BA48-6285-069A7386A1FB.

LOG====== Read for Characteristic: 0000FF01-0000-1000-8000-00805F9B34FB, Service: 0000FF12-0000-1000-8000-00805F9B34FB on 6FB59BAF-EEBC-BA48-6285-069A7386A1FB is successful.

20 bytes
Hex String: 0000000000000000000000000000000000000000
Byte Data----- [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions