Accurately obtain iPhone signal strength? - ios

I am currently utilising CTGetSignalStrength(); to obtain the signal strength from an iOS device.
Whilst this function does return a value, the value appears to range from 0-45.
What does this value actually mean in terms of dBm, as this appears to be an Apple graded value that doesn't relate to an actual measurement.
Is there a way to convert the value returned to dBm, or a private API to retrieve the value in dBm

Related

What are the valid range of values for the UIImpactFeedbackGenerator class's impactOccurredWithIntensity method?

The iOS UIKit class UIImpactFeedbackGenerator, in iOS 13+, has an instance method impactOccurredWithIntensity, which takes a single CGFloat parameter, intensity. The documented declaration is (in Objective-C):
- (void)impactOccurredWithIntensity:(CGFloat)intensity;
As of the time of this question, the linked documentation page provides no information on what the valid range of values are for that intensity parameter, and what effect the value has.
(Is the range 0 to 1? 0 to infinity? Some other maximum? Are negative values permitted? Do larger values generate more intense haptic feedback? How does the intensity value interact with the various UIImpactFeedbackStyle values, such as UIImpactFeedbackStyleHeavy, that the UIImpactFeedbackGenerator can be initialized with?)
Also as of the time of this question, a simple Google search for impactOccurredWithIntensity yields no meaningful results beyond that linked Apple documentation page.
My question: What are the valid range of values for the intensity parameter of the impactOccurredWithIntensity method, and what specific effect does the value have?

iOS determine data length of CBCharacteristic

Is there any way to dynamically sniff out the data length of a CBCharacteristic?
I'm evolving the characteristic API on a gadget I have, and I want to change the field width of one of the characteristics. If I make the change in the iOS side so that it writes a value of 9 bytes instead of 7 bytes, a device that has the old API (characteristic field width of 7) on it causes the following to occur when I attempt to write the value:
Error Domain=CBATTErrorDomain Code=13 "The value's length is invalid." UserInfo={NSLocalizedDescription=The value's length is invalid.}
What I'd like to determine is whether or not I can catch that error, and then somehow query the CBCharacteristic what its current field width is. Obviously at some point, it determined that 9 > 7 and caused the error to bubble up. I've tried reading the descriptor associated with the characteristic, but there's just one descriptor (<CBDescriptor: 0x2830cbe40, UUID = Client Characteristic Configuration, value = 2>) which doesn't tell me much.
This is a standard ATT protocol error that's generated by the peripheral, not iOS. It means you sent a value and the peripheral responded that the value was the wrong length. Characteristics do not necessarily have specific lengths. The correct length might be context dependent. For example, a characteristic might accept 2 bytes, 4 bytes, or 8 bytes. If you write 7 bytes, it could return this error. Or the first byte might be a command selector, and the rest might be the payload that needs to be of a specific length for that command. There's no simple "what's the length of this characteristic" for these designs.
There's no general way to know what a remote service wants. You need to know that through API documentation. This is the equivalent of getting back a 405 Method not allowed error from an HTTP server. It's up to you to know what methods are allowed. A particular system might give you a way to query it, and it might not. It's not part of the HTTP spec to provide that, and similarly it's not part of the BLE spec.
You can query the maximum packet length allowed by a characteristic with
peripheral.maximumWriteValueLength(for:CBCharacteristicWriteType.<>)

How to extract weight value from a Bluetooth LE (SIG) hex value

I'm developing a xamarin android app to connect to a bluetooth low energy weight scale. I can already connect to the device an explore it's services and characteristics, however i'm facing some problems extracting it's value.
The scale implements the Bluetooth SIG standards, so i was expecting it to have an Weight Scale service (org.bluetooth.service.weight_scale) and the Weight Measurement characteristic (org.bluetooth.characteristic.weight_measurement).
Aparently not.
Exploring the device services, the reading service seams to be an "unknown service" (0000ffe0-0000-1000-8000-00805f9b34fb) and the characteristic seams to be "TI SensorTag Keys Data" (0000ffe1-0000-1000-8000-00805f9b34fb).
Here's some sample readings from the refered service:
For 78.4 Kg i got E7-58-01-06-20
For 81.6 Kg i got E7-58-01-06-60
For 81.7 Kg i got E7-58-01-06-62
For 118.6 Kg i got E7-58-01-09-44
The scale supports weight reading, body fat, body water, muscle mass, bone mass, basel metabolic rate, and active metabolic rate. I think i'm using a weight read only mode.
I've already converted the hexadecimal values to decimal but the output values are not direct.
What formula should i use to extract the value?
If you care only about the last two bytes of your characteristic value: 06-20, 06-60, 0--62 and 09-44. You can compare those to the weight displayed on the scale:
> 0x620/78.4 -> 20.0
> 0x660/81.6 -> 20.0
> 0x662/81.7 -> 20.0
> 0x944/118.6 -> 20.0
This means that each digit in the number represented by the lower two bytes of the characteristic value is equal to 1/20th of one kilogram = 50g.
To display the weight in your application, just convert the last two bytes of the characteristic value into your host integer representation (ntohs or equivalent https://linux.die.net/man/3/ntohs) and divide it by 20.

Measure (frequency-weighted) sound levels with AudioKit

I am trying to implement an SLM app for iOS using AudioKit. Therefore I need to determine different loudness values to a) display the current loudness (averaged over a second) and b) do further calculations (e.g. to calculate the "Equivalent Continuous Sound Level" over a longer time span). The app should be able to track frequency-weighted decibel values like dB(A) and dB(C).
I do understand that some of the issues im facing are related to my general lack of understanding in the field of signal and audio processing. My question is how one would approach this task with AudioKit. I will describe my current process and would like to get some input:
Create an instance of AKMicrophone and a AKFrequencyTracker on this microphone
Create a Timer instance with some interval (currently 1/48_000.0)
Inside the timer: retrieve the amplitude and frequency. Calculate a decibel value from the amplitude with 20 * log10(amplitude) + calibrationOffset (calibration offset will be determined per device model with the help of a professional SLM). Calculate offsets for the retrieved frequency according to frequency-weighting (A and C) and apply these to the initial dB value. Store dB, dB(A) and dB(C) values in an array.
Calculate the average for arrays over the give timeframe (1 second).
I read somewhere else that using a Timer this is not the best approach. What else is there that I could use for the "sampling"? What exactly is the frequency of AKFrequencyTracker? Will this frequency be sufficient to determine dB(A) and dB(C) values or will I need an AKFFTTap for this? How are values retrieved from the AKFrequencyTracker averaged, i.e. what time frame is used for the RMS?
Possibly related questions: Get dB(a) level from AudioKit in swift, AudioKit FFT conversion to dB?

ESP8266 WiFi signal strength

how to use AT+CWLAP in esp8266 to get wifi signal strength? I want to get the signal strength which is displayed on the serial monitor and use it in my code in arduino IDE!
After sending the AT+CWLAP command, ESP8266 will answer with a list of all available AP's detected.
The format of the response will be like:
+CWLAP:<ecn>,<ssid>,<rssi>,<mac>,<freq offset,<freq calibration>
where:
<ecn>: indicates the security level, from 0 (OPEN) to 4 (Maximum security level)
<ssid>: it's the ssid of the AP
<rssi>: it's the signal strength, which is indicated in decibel format (e.g. -70)
<mac>: it's the MAC address
<ch>: channel
<freq offset>: ut's the frequency offset of AP,unit:KHz.
<freq calibration>: it's the calibration for frequency offset
So, the <rssi> parameter is what you are interested in.
Maybe, depending on the firmware version of your ESP8266, it's possible that AT+CWLAP command returns a different number of parameters, omitting, for example, the last four.

Resources