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 failed for device: errorCode: 401 attErrorCode: 128 #1145

Closed
4 tasks done
webjay opened this issue Nov 21, 2023 · 1 comment
Closed
4 tasks done

Write failed for device: errorCode: 401 attErrorCode: 128 #1145

webjay opened this issue Nov 21, 2023 · 1 comment
Labels

Comments

@webjay
Copy link

webjay commented Nov 21, 2023

Prerequisites

  • I checked the documentation and FAQ without finding a solution
  • I checked to make sure that this issue has not already been filed
  • I'm sure that question is related to the library itself and not Bluetooth Low Energy or Classic in general. If that so, please post your question on StackOverflow.
  • I'm running the latest version

Question

I have a Moko M1 based on nRF52810 which I am trying to write to.
I can write to it successfully via the "nRF Connect" app.

I know that the error 401 means "Couldn't write to specified characteristic", however isWritableWithResponse: true.
I don't know what the error attErrorCode: 128 indicates?

In both nRF Connect and via console.log I only see one service and one characteristic.

I have the content stored as a string for now, from this:
const fileContent = readFileSync('/Users/jacob/Downloads/EA140CF93E0D.zip', { encoding: 'base64' });

What might I be doing wrong?

const isConnected = await device.isConnected();
if (!isConnected) await device.connect();
await device.discoverAllServicesAndCharacteristics();
const services = await device.services();
const characteristics = await device.characteristicsForService(services[0].uuid);
await characteristics[0].writeWithResponse(fileContent).catch((error) => {
  console.log(JSON.stringify(error));
});
@webjay
Copy link
Author

webjay commented Nov 22, 2023

It turns out I needed to use react-native-nordic-dfu:
Pilloxa/react-native-nordic-dfu#171 (comment)

@webjay webjay closed this as completed Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant