NSLocalizedDescription=Writing is not permitted
I tried to make an app that sends messages from iPhone to Bluetooth LE module. But for some reason, it gives the following error:
NSLocalizedDescription=Writing is not permitted.
Even though the types of the blePeripheral and the blePeripheral!.write are CBCharacteristicWrite.withResponse
, the error says that writing is not permitted. How come the following code does not work for me?
func writeValue(data: String) {
let valueString = (data as NSString).data(using: String.Encoding.utf8.rawValue)
//change the "data" to valueString
if let blePeripheral = blePeripheral {
if let txCharacteristic = txCharacteristic {
blePeripheral.writeValue(valueString!, for: txCharacteristic, type: CBCharacteristicWriteType.withResponse)
}
}
}
func writeCharacteristic(val: Int8) {
var val = val
let ns = NSData(bytes: &val, length: MemoryLayout<Int8>.size)
blePeripheral!.writeValue(ns as Data, for: txCharacteristic!, type: CBCharacteristicWriteType.withResponse)
}
The resource where I found the code is:
https://learn.adafruit.com/crack-the-code/communication
swift bluetooth-lowenergy permission-denied
add a comment |
I tried to make an app that sends messages from iPhone to Bluetooth LE module. But for some reason, it gives the following error:
NSLocalizedDescription=Writing is not permitted.
Even though the types of the blePeripheral and the blePeripheral!.write are CBCharacteristicWrite.withResponse
, the error says that writing is not permitted. How come the following code does not work for me?
func writeValue(data: String) {
let valueString = (data as NSString).data(using: String.Encoding.utf8.rawValue)
//change the "data" to valueString
if let blePeripheral = blePeripheral {
if let txCharacteristic = txCharacteristic {
blePeripheral.writeValue(valueString!, for: txCharacteristic, type: CBCharacteristicWriteType.withResponse)
}
}
}
func writeCharacteristic(val: Int8) {
var val = val
let ns = NSData(bytes: &val, length: MemoryLayout<Int8>.size)
blePeripheral!.writeValue(ns as Data, for: txCharacteristic!, type: CBCharacteristicWriteType.withResponse)
}
The resource where I found the code is:
https://learn.adafruit.com/crack-the-code/communication
swift bluetooth-lowenergy permission-denied
"the types of the blePeripheral and the blePeripheral!.write are CBCharacteristicWrite.withResponse" You mean the properties oftxCharacteristic
?
– Larme
Nov 23 '18 at 14:05
If I am not mistaken, txCharacteristic is for sending messages from my phone to a BLE module. So I am trying to permit the phone to send the data, but why does the xcode says to me that the permission is not allowed?
– Асмир Абдимажитов
Nov 23 '18 at 14:33
When you did indidDiscoverCharacterstic()
:txCharacteristic = characteristic
, could you add print("tx properties: (txCharacteristic.properties)") and give the output?
– Larme
Nov 23 '18 at 17:29
The app prints the following statements:Found 1 characteristics!
Rx Characteristic: FFE1
Tx Characteristic: FFE1
– Асмир Абдимажитов
Nov 24 '18 at 4:23
It doesn't answer if the property is writable or not.
– Larme
Nov 28 '18 at 11:37
add a comment |
I tried to make an app that sends messages from iPhone to Bluetooth LE module. But for some reason, it gives the following error:
NSLocalizedDescription=Writing is not permitted.
Even though the types of the blePeripheral and the blePeripheral!.write are CBCharacteristicWrite.withResponse
, the error says that writing is not permitted. How come the following code does not work for me?
func writeValue(data: String) {
let valueString = (data as NSString).data(using: String.Encoding.utf8.rawValue)
//change the "data" to valueString
if let blePeripheral = blePeripheral {
if let txCharacteristic = txCharacteristic {
blePeripheral.writeValue(valueString!, for: txCharacteristic, type: CBCharacteristicWriteType.withResponse)
}
}
}
func writeCharacteristic(val: Int8) {
var val = val
let ns = NSData(bytes: &val, length: MemoryLayout<Int8>.size)
blePeripheral!.writeValue(ns as Data, for: txCharacteristic!, type: CBCharacteristicWriteType.withResponse)
}
The resource where I found the code is:
https://learn.adafruit.com/crack-the-code/communication
swift bluetooth-lowenergy permission-denied
I tried to make an app that sends messages from iPhone to Bluetooth LE module. But for some reason, it gives the following error:
NSLocalizedDescription=Writing is not permitted.
Even though the types of the blePeripheral and the blePeripheral!.write are CBCharacteristicWrite.withResponse
, the error says that writing is not permitted. How come the following code does not work for me?
func writeValue(data: String) {
let valueString = (data as NSString).data(using: String.Encoding.utf8.rawValue)
//change the "data" to valueString
if let blePeripheral = blePeripheral {
if let txCharacteristic = txCharacteristic {
blePeripheral.writeValue(valueString!, for: txCharacteristic, type: CBCharacteristicWriteType.withResponse)
}
}
}
func writeCharacteristic(val: Int8) {
var val = val
let ns = NSData(bytes: &val, length: MemoryLayout<Int8>.size)
blePeripheral!.writeValue(ns as Data, for: txCharacteristic!, type: CBCharacteristicWriteType.withResponse)
}
The resource where I found the code is:
https://learn.adafruit.com/crack-the-code/communication
swift bluetooth-lowenergy permission-denied
swift bluetooth-lowenergy permission-denied
edited Nov 24 '18 at 13:24
wvteijlingen
8,59612544
8,59612544
asked Nov 23 '18 at 14:02
Асмир АбдимажитовАсмир Абдимажитов
216
216
"the types of the blePeripheral and the blePeripheral!.write are CBCharacteristicWrite.withResponse" You mean the properties oftxCharacteristic
?
– Larme
Nov 23 '18 at 14:05
If I am not mistaken, txCharacteristic is for sending messages from my phone to a BLE module. So I am trying to permit the phone to send the data, but why does the xcode says to me that the permission is not allowed?
– Асмир Абдимажитов
Nov 23 '18 at 14:33
When you did indidDiscoverCharacterstic()
:txCharacteristic = characteristic
, could you add print("tx properties: (txCharacteristic.properties)") and give the output?
– Larme
Nov 23 '18 at 17:29
The app prints the following statements:Found 1 characteristics!
Rx Characteristic: FFE1
Tx Characteristic: FFE1
– Асмир Абдимажитов
Nov 24 '18 at 4:23
It doesn't answer if the property is writable or not.
– Larme
Nov 28 '18 at 11:37
add a comment |
"the types of the blePeripheral and the blePeripheral!.write are CBCharacteristicWrite.withResponse" You mean the properties oftxCharacteristic
?
– Larme
Nov 23 '18 at 14:05
If I am not mistaken, txCharacteristic is for sending messages from my phone to a BLE module. So I am trying to permit the phone to send the data, but why does the xcode says to me that the permission is not allowed?
– Асмир Абдимажитов
Nov 23 '18 at 14:33
When you did indidDiscoverCharacterstic()
:txCharacteristic = characteristic
, could you add print("tx properties: (txCharacteristic.properties)") and give the output?
– Larme
Nov 23 '18 at 17:29
The app prints the following statements:Found 1 characteristics!
Rx Characteristic: FFE1
Tx Characteristic: FFE1
– Асмир Абдимажитов
Nov 24 '18 at 4:23
It doesn't answer if the property is writable or not.
– Larme
Nov 28 '18 at 11:37
"the types of the blePeripheral and the blePeripheral!.write are CBCharacteristicWrite.withResponse" You mean the properties of
txCharacteristic
?– Larme
Nov 23 '18 at 14:05
"the types of the blePeripheral and the blePeripheral!.write are CBCharacteristicWrite.withResponse" You mean the properties of
txCharacteristic
?– Larme
Nov 23 '18 at 14:05
If I am not mistaken, txCharacteristic is for sending messages from my phone to a BLE module. So I am trying to permit the phone to send the data, but why does the xcode says to me that the permission is not allowed?
– Асмир Абдимажитов
Nov 23 '18 at 14:33
If I am not mistaken, txCharacteristic is for sending messages from my phone to a BLE module. So I am trying to permit the phone to send the data, but why does the xcode says to me that the permission is not allowed?
– Асмир Абдимажитов
Nov 23 '18 at 14:33
When you did in
didDiscoverCharacterstic()
:txCharacteristic = characteristic
, could you add print("tx properties: (txCharacteristic.properties)") and give the output?– Larme
Nov 23 '18 at 17:29
When you did in
didDiscoverCharacterstic()
:txCharacteristic = characteristic
, could you add print("tx properties: (txCharacteristic.properties)") and give the output?– Larme
Nov 23 '18 at 17:29
The app prints the following statements:
Found 1 characteristics!
Rx Characteristic: FFE1
Tx Characteristic: FFE1
– Асмир Абдимажитов
Nov 24 '18 at 4:23
The app prints the following statements:
Found 1 characteristics!
Rx Characteristic: FFE1
Tx Characteristic: FFE1
– Асмир Абдимажитов
Nov 24 '18 at 4:23
It doesn't answer if the property is writable or not.
– Larme
Nov 28 '18 at 11:37
It doesn't answer if the property is writable or not.
– Larme
Nov 28 '18 at 11:37
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53448125%2fnslocalizeddescription-writing-is-not-permitted%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53448125%2fnslocalizeddescription-writing-is-not-permitted%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
"the types of the blePeripheral and the blePeripheral!.write are CBCharacteristicWrite.withResponse" You mean the properties of
txCharacteristic
?– Larme
Nov 23 '18 at 14:05
If I am not mistaken, txCharacteristic is for sending messages from my phone to a BLE module. So I am trying to permit the phone to send the data, but why does the xcode says to me that the permission is not allowed?
– Асмир Абдимажитов
Nov 23 '18 at 14:33
When you did in
didDiscoverCharacterstic()
:txCharacteristic = characteristic
, could you add print("tx properties: (txCharacteristic.properties)") and give the output?– Larme
Nov 23 '18 at 17:29
The app prints the following statements:
Found 1 characteristics!
Rx Characteristic: FFE1
Tx Characteristic: FFE1
– Асмир Абдимажитов
Nov 24 '18 at 4:23
It doesn't answer if the property is writable or not.
– Larme
Nov 28 '18 at 11:37