Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write a command without respose. #271

Open
jatin141141 opened this issue Feb 7, 2024 · 0 comments
Open

Write a command without respose. #271

jatin141141 opened this issue Feb 7, 2024 · 0 comments

Comments

@jatin141141
Copy link

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]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant