write peripheral.name Xcode - bluetooth

I have an app that connects to a bluetooth LE peripheral. Is it possible to change the peripheral's name from the app. In other words I want to rewrite the peripherals localized name from the central device. I can get the name through the advertised data and only connect to the peripheral if it have a certain name. but I would like the user to be able to change the peripheral's name so only they can connect to that specific peripheral from the app.
I'm not sure if my peripheral allows it or not. How would I check and How would I write the new name??
I have used the following code to get the service device information and then to get the manufacturers name
if([service.UUID isEqual:[CBUUID UUIDWithString:#"180A"]]) {
for (CBCharacteristic *characteristic in service.characteristics) {
NSLog(#"discovered characteristic %#", characteristic.UUID);
if([characteristic.UUID isEqual:[CBUUID UUIDWithString:#"2A29"]]) {
NSLog(#"Found Notified Characteristic %#", characteristic);
self.mycharacteristic2 = characteristic;
[self.testPeripheral setNotifyValue:YES forCharacteristic:characteristic];
[self.testPeripheral readValueForCharacteristic:mycharacteristic2];
NSLog(#"value:%#",mycharacteristic2.value);
}
} NSLog(#"services%#",service);}
however if I substitute 2A00 (which is supposed to be the UUID for the device Name) I get nothing.
I have also tried to use 1800 for generic access and 1801 for generic information but I don't get any response for the device name 2A00.
I do get a log that 1801 is Device information but no information for 2A00 which is supposed to be Device Name. Does anyone know how to access the Device Name characteristic UUID?

You need to check the properties property of the characteristic. You'd be looking for CBCharacteristicPropertyWrite.
Also, are you absolutely sure the peripheral supports 2A00? Try using the app LightBlue to browse all the available services and chacteristics.

Related

Use Iot hub edge module client to get device twin properties

I am trying to fetch device twin properties within an IoT Edge module, and while I am already connected with a module client (aka IoTHubModuleClient), I've found a method called get_twin() in the documentation that says that we can grab device or module twin properties. However, I am getting "empty" properties, here's the result:
{'desired': {'$version': 1}, 'reported': {'$version': 1}}
Which is not what I configured in the azure portal in device twin section. But using the IotHubDeviceClient with a device connection string (that's why I don't want to use that client), I am able to get the right device twin properties.
The code is pretty basic:
client = IoTHubModuleClient.create_from_edge_environment()
twin_properties = await client.get_twin()
logger.debug(f'Twin properties: {twin_properties}')
That is correct Mehdi, when you use the IoTHubModuleClient's get_twin method you are getting the module twin properties, you can add/modify/delete module twin properties independently of device twin properties.
Please take a look of this article

Is reading a NFC chip as a web app possible

I'd like to use Vaadin to create a web app in Java that reads a NFC chip to identify the user and then proceeds with other options, is that possible?
My reason why I don't want to do that in an android app is to decentralize myself to perform the same work for multiple versions and/or different systems
The Web NFC API is what you're looking for: https://web.dev/nfc
Web NFC is available only on Chrome for Android for now. It is limited to NDEF because the security properties of reading and writing NDEF data are more easily quantifiable. Low-level I/O operations (e.g. ISO-DEP, NFC-A/B, NFC-F), Peer-to-Peer communication mode and Host-based Card Emulation (HCE) are not supported.
Here's a sample for you to play with: https://googlechrome.github.io/samples/web-nfc/
const ndef = new NDEFReader();
await ndef.scan();
ndef.addEventListener("reading", ({ message, serialNumber }) => {
console.log(`> Serial Number: ${serialNumber}`);
console.log(`> Records: (${message.records.length})`);
});

Switch audio output to speakers

I work on own specialized VoIP client for W10 mobile & desktop. Basic things work ok.
However I cannot get audio output to speakers on my old Lumia.
foreach (var item in (await DeviceInformation.FindAllAsync(DeviceClass.AudioRender)).Where(i => i.Name.Contains("Speakers")))
RendererId = item.Id;
There is "Speakers (WaveRT)" in device list so RendererId is valid.
Later application tries to open audio device (WSAPI) with found RendererId. But anyway phone plays to receiver only.
I modified Voip sample app in attempt to reproduce issue - yes, it happens with Voip sample app also.
My collegue confirms he has same problem on his phone.
Is it possible to play audio via speaker for voip app ?
Thank you!
On the Phone devices only, you can use the AudioRoutingManager to change the audio output.
// to get the audio manager
IsAudioRoutingSupported = ApiInformation.IsApiContractPresent(typeof(PhoneContract).FullName, 1);
if(IsAudioRoutingSupported)
{
// audio routing is supported, we register for the output change events
m_audioRoutingManager = AudioRoutingManager.GetDefault();
m_audioRoutingManager.AudioEndpointChanged += OnAudioEndpointChanged;
}
// to change to output
m_audioRoutingManager.SetAudioEndpoint(AudioRoutingEndpoint.Speakerphone);

Get location/address of Amazon Echo device

I am making an Alexa skill which needs to send the location of the Echo being used to an API within my Lambda function.
https://www.amazon.com/gp/help/customer/display.html?nodeId=201601980 says we can access many details about the Echo, such as Device Location, but in my skill, I don't see this is available in the session:
exports.handler = function (event, context) {
try {
console.log("event.session: " + event.session);
How can I get this data?
The point is, while we have the address of the user coming from my App API, they may have set an address where they're not currently at (aka, they've placed an order from an Echo that's not the same as their address).
Thanks!
Access to the profile information doesn't appear to be available. If the account is linked, the only option I see is to route them back to your web site to provide information necessary to complete the order.
You can now get the address of the device, as specified in the customer’s device settings.
This is new as of 2017-04-05. See Amazon's blog post about their new Device Address API.

Detect Smartcard removal in J2ME (JSR257)?

I'm using the J2ME contactless API (JSR257 - javax.microedition.contactless.*) to read smartcards on a Nokia phone. The following code works just fine and the targetDetected method is called as expected when I put a card on the phone:
DiscoveryManager dm = DiscoveryManager.getInstance();
dm.addTargetListener(this, TargetType.ISO14443_CARD);
public void targetDetected(TargetProperties[] tps) {
logger.log("found card!");
}
However, I'm wondering if there is any way to get a callback when the card is removed? Or is the only way to check if the card has been removed to try and open or read from a connection and catch the appropriate exceptions?

Resources