How do I find out which UUID I should use to request data from my Polar H10 sensor? - uuid

I want to connect to my Polar H10 and read its Heart Rate (PPI) values. I am basically following this example Python code which reads Acceleration from the same device. I am however stuck in finding out which UUID I should use to request the Heart Rate data. The example uses a byte array of unknown origin (to me) to request the Acceleration data and I have no clue where I should retrieve the UUID for heart rate from. All I can find is this document, but it gives a, I believe hexidecimal, code which I cannot use. What do I do to get the right UUID? I'm new to this kind of sensor stuff so nothing seems obvious to me.
EDIT 1:
So these are the GATT characteristics on my device
This is the PMD measurement type I am trying to extract
And of that I want Byte0: Heart rate in bpm
What I am doing now (I'm not sure if you want all the code so I'm gonna post what seems relevant). In Python:
For setting the request for specific data (I think? this is what the example does with different data from the same sensor)
ECG_WRITE = bytearray([0x02, 0x00, 0x00, 0x01, 0x82, 0x00, 0x01, 0x01, 0x0E, 0x00])
What I've tried to change ECG data to heart rate data is:
RR_UUID = "0000180D-0000-1000-8000-00805f9b34fb"
But I feel like it isn't working because it isn't a byte array.
Then later on these lines are executed for actual data retrievement I think (again, I'm following a guide I'm not 100% sure what the code does)
att_read = await client.read_gatt_char(PMD_CONTROL)
await client.write_gatt_char(PMD_CONTROL, ECG_WRITE)
## ECG stream started
await client.start_notify(PMD_DATA, data_conv)
And from there on the data_conv method converts the data into usable data, and in this same method I can just print out the data and see it. However, since I don't know what I should enter as byte array to request the heart rate data, I haven't been able to get any data out of it yet. It also gives no errors/exceptions whatshowever so I am not sure what is going wrong.
So I am working from a Windows computer using Python code, and the target machine is a Polar H10 heart sensor.

I've been trying to solve the same problem for some time now and finally got the hang of it.
The documentation is confusing as it leads one to think that the H10 sensor doesn't support HR and PPI readings. The reality, however, is that those measurements are of course supported by the sensor—just not through the PMD_DATA stream. The UUID for HR readings is:
HR_UUID = "00002A37-0000-1000-8000-00805F9B34FB"
So when you start a client.notify(HR_UUID), you will get a 6 byte data stream, that follows the specifications given in the Polar Specification Document (see image below)

Related

RxFrameNtf, TxFrameNtf and Ntf.data in unetpy

I am using Unetstack software along with Unetpy. I wish to retrieve transmit and recieve notifications when I run .py file which imports Unetpy python library. I followed this tutorial
I am successfully able to connect to the localhost and print values like phy.MTU and so on. When I transmit a packet I also receive a reply saying AGREE on the command prompt.output_of_my_script
my_script
Can you please help me in receiving Txframentf and rxframentf along with data payload.
I have made changes posted in bug reports suggested in this linkeven.
Please guide me on how to print notifications for rxframe and txframe.
Thank you``
Your script is fine until the last line:
print(phy << org_arl_unet_phy.TxFrameNtf())
Here you are trying to send a TxFrameNtf to the physical agent. This does not make sense, as it is the physical agent who sends you such a notification when a transmission is completed.
By the time you reach this line, you should have already received the notification as txntf as long as the transmission was completed within 5 seconds (timeout=5000). To print out the notification, all you need to do is:
print(txntf)
I just tested this against the 3-node-network.groovy sample. I am using unetpy-1.3b5 and fjagepy-1.4.2b3. Here's the modified code:
from unetpy import *
modem = UnetGateway('localhost', 1102)
phy = modem.agentForService(Services.PHYSICAL)
print(phy.MTU)
print(phy.basebandRate)
print(phy << org_arl_unet_phy.TxFrameReq(to=3, data=[1,2,3,4]))
txntf = modem.receive(timeout=5000)
print(txntf)
and the output:
16
4096
AGREE
TxFrameNtf:INFORM[type:1]
You can see that the TxFrameNtf is correctly received.
For reception, you need to subscribe to the agent's notifications and then receive a frame:
modem.subscribe(phy)
rxntf = modem.receive(org_arl_unet_phy.RxFrameNtf, timeout=5000)
print(rxntf)
Assuming you receive a frame within the 5 second timeout specified (in this example, on node 3), this should print out something like:
RxFrameNtf:INFORM[type:CONTROL from:1 to:3 protocol:0 rxTime:34587658 (4 bytes)]
You sent a datagram through some agent that supports the DATAGRAM service. There may be many agents that support this service (not just the physical layer). In any case, that datagram would be received on a different node, and so you wouldn't expect to receive DatagramNtf on the transmitting node.
The RangeReq should yield a RangeNtf if successful, but that might take more than the default receive timeout of 1 second, depending on how far node 2 is. So you might want to try a longer receive timeout to see if you get your notification.
To access the data from payload from the rxntf, you can try print(rxntf.data).

"send_nav_velocity" function does not work in "guided_set_speed_yaw" example

I am new to Ardupilot.
Recently, I am trying to run the example "guided_set_speed_yaw" in dronekit-python api. here
Oddly, the "send_nav_velocity" in line 47 does not work (no "Got MAVLink msg" response and nothing happened during real flight tests), while "condition_yaw" in line 67 works.
I am running the script in Odroid U3 with an IRIS quadcopter. The firmware version is V3.3-dev. I basically followed this website to come to this far.
Maybe it's because of the firmware version? Thanks for any help!
The URL to the example is https://github.com/diydrones/dronekit-python/blob/master/examples/guided_set_speed_yaw/guided_set_speed_yaw.py (note "examples" not "example"). This is much more "full" version of the example code.
The reason you're not getting a response is that I don't think one is sent - ArduPilot sends a response for COMMAND_LONG messages (as used to send CONDITION_YAW), but not necessarily other message types (as used to send the velocity).

How to get partial results from Google App Engine's urlfetch?

When I'm using google.appengine.api.urlfetch.fetch (or the asynchronous variant with make_rpc) to fetch a URL that steadily streams data, after a while I will get a google.appengine.api.urlfetch_errors.DeadlineExceededError as expected. Since it is a stream that I want to sample, setting the deadline to a higher value can't ever help, unless the stream finishes (which I do not expect to happen).
It seems there is no possibility of getting the partially downloaded result. At least the API doesn't offer anything. Is it possible to
either request the downloaded part
or only ask for a certain amount of data (since I can estimate the stream's rate) to be downloaded?
[Clarification: Since it is a stream, requests with a Range header will be answered with 200 OK and not 206 Partial Content.]
In your call to urlfetch.fetch, you can set HTTP headers. The Range header is how you specify a partial-download request in HTTP:
resp = urlfetch.fetch(
url=whatever,
headers={'Range': 'bytes=100-199'})
if those are the 100 bytes you want. The HTTP status code you get should be 206 for such a partial download, etc (none of that's GAE-specific). See e.g http://en.wikipedia.org/wiki/Byte_serving for details.

Why are these deferred tasks not being executed in the order in which they were added?

I'm using Twilio to send sms's with appengine. Twilio doesn't accept sms's longer than 160 characters so I have to split them. I am splitting the sms's and sending them as follows:
def send_sms_via_twilio(mobile_number, message_text):
client = TwilioRestClient(twilio_account_sid , twilio_auth_token)
message = client.sms.messages.create(to=mobile_number, from_=my_twilio_number, body=message_text)
split_list = split_sms(long_message)
for each_message in split_list:
send_sms_via_twilio(each_message)
However I found that the order of sending varied. For example sometimes I'd recieve message 2/5 then 1/5 then 4/5 etc and other times the order would be correct. The order of the split_list is definately correct. To overcome the incorrect order of the sms's I tried
for each_message in split_list:
deferred.defer(send_sms_via_twilio, each_message, _countdown=1)
However I encountered the same problem. I then tried
for each_message in split_list:
deferred.defer(send_sms_via_twilio, each_message, _countdown=1, _queue="send-text-message")
and defined my queue as
- name: send-text-message
rate: 1/s
bucket_size: 10
max_concurrent_requests: 1
retry_parameters:
task_retry_limit: 5
Thinking that the issue was concurrency (running in python27) and that if I limited max_concurrent_requests this issue would be solved. However the issue is still present i.e. the texts still get sent in the wrong order. I checked the logs but couldnt see any notification of task failure - they just seem to be executing in the wrong order.
Is there something I am missing? How can I fix this issue.
Note that the SMS messaging (specifically the underlying protocols like SMPP) are asynchronous by definition. It means there is no way you can specify the order of distinct SMS messages.
There is a way to specify the order of SMS packets by using the UDH (user defined headers) in the binary body of those messages. But this works only for long SMS messages -- those that are too long to be sent in one message. For example, if your msg exceeds 160 GSM-7 characters or 80 UTF-16 characters it will be send as more than one message with UDH.
In that case the mobile phone won't show message parts as they arrive. It will collect them in memory until the last one comes and then assembles them in the right order. For the end user this is just a message longer than usual and you don't have to write "1/3", "2/3", ... in the message.
Disclaimer: I work for a company that enables you to send and receive both multiple binary messages with user-specified headers (UDH) and/or standard long messages.
If you are not tied to Twilio try using SMSified. They automatically split the message for you, insure it is in the correct order, and add "1/2, 2/2..." to the end of the message. In other words you just send the complete message to their REST API, no matter the length, and they handle the rest. Since they also use a REST API you can continue to use Python.

NtQueryDirectoryFile enumerate files partial and continue from previous

As i need to create an application using Nt level apis only , Here i want to write a wrapper for same behaviour of Ntquerydirectoryfile ,so i collect lot of things abt this api ,but i could not understand some in this api .
NTSTATUS status = ZwQueryDirectoryFile(FileHandle,Event,ApcRoutine,ApcContext,IoStatusBlock,FileInformation,Length,FileInformationClass,ReturnSingleEntry,FileName,RestartScan);
Here IoStatusBlock(out) contains Information and status of queried dir or file ,status should be a return type of this api and information should be data written into fileinformation and fileinformation having full details(any fileinformation class structure) of given file/dir then length - how much data should fill ..
o/p parameters are IOstatusblock and fileinformation only
ZwQueryDirectoryFile
here i saw an one property of this api which was enumerating a drive with some allocated length it fetches some files from it ,then return details partial regarding to length After that, Zwquerydirectory call comes again with same handle with some other length ,it fetches the data from last received one of previous call ..its only i could not understand ,because where should the api set this information to remind the position to start exact location(offset)...if u know abt it let me know ,it really appreciative...

Resources