Hexa decimal interpretation - bluetooth

I am trying to connect a pedometer watch to my phone with bluetooth and want to read the steps from it to an app I have made. The connection is made successfully and I am able to read the data from the watch but I am not so clear how to interpret it.
Below is the document,
Eigenvalue content:
(1) all the eigenvalue content inside the endian order are small endian order.
(2) current_pedometer_measurement
The value of the current_pedometer_measurement consists of four parts
Value type description
Flag Uint8 0x01: Number of Steps (Required)
0x02: Distance (optional)
0x04: Calories (optional)
Such as 0x05 that contains the number of steps and calories
StepCount Uint24 The number of steps
StepDistancer Uint24 How far, in meters
StepCalorie Uint24 calories
Description:
1. Distance and calories are optional, may or may not appear
If only the number of steps, then the value is: 01 (steps) 10 27 00 (1 million steps)
If there are steps and distances, then the value is: 03 (number of steps, distance) 10 27 00 (1 million steps) 70 17 00 (6 km)
Other cases and so on.
2. Time value to mobile phone time as the standard, that is, the moment the phone receives the data that is the time of this data.
(3) target
The target value is
Value type description
Flag Uint8 0x01: Number of Steps (Required)
StepCount Uint24 The number of steps
Description:
1. If the target is 10,000 steps, then the value is: 01 (steps) 10 27 00 (1 million steps)
2. If the device writes to the target value, the device is updated. If the device updates the target value, notify the phone.
The reading I am getting from the pedometer watch is:
[7, 64, 1, 0, 144, 0, 0, 24, 0, 0]
Can anyone help me to interpret it?

The data appears to follow your description exactly. The first byte is the flag field and in this case it indicates that all 3 measurement types are being reported. Or`ing bits 1 and 2 and 3 equals 7.
The next 9 bytes are the 3 24-bit data values, where 64,1,0 are steps, 144,0,0 are distance, and 24,0,0 are calories. How you convert the bytes is a bit confusing, but if you use little-endian format and assume you printed them in decimal do these values make sense?
Steps: 00 01 64 = 0x000140 = 320
Distance: 00 00 144 = 0x000090 = 144
Calories: 00 00 24 = 0x000018 = 24
From your examples above the values are probably in hex:
10 27 00 = 0x002710 = 10000
70 17 00 = 0x001770 = 6000
Hope that helps!
grace

Related

Different next states for same current state?

So I'm working on this state machine which is supposed to emulate a sequence as follows:
state machine table
However, the state 00 goes to both 01 and 10 at different times. How can I design a circuit that allows me to go from the same initial state to two different next states?
Based on the table you shared, I'm assuming that this machine wants to iterate in the loop 00->01->00->10 an again. In this case, your machine can be modeled using 4 states instead of just 3. These states are:
A represents 00 but when the previous state was 10
B represents 01
C represents 00 but when the previous state was 01
D represents 10
With A as the initial state, your table will then be:
S
S'
A
B
B
C
C
D
D
A
If you want to use the original values, then you must build a circuit that for each of these new states gives you those values. This circuit would be in this case:
S
V
A
00
B
01
C
00
D
10

In Excel I need to convert seconds in days hours min sec

I've already figure out that I can divide the number of seconds/86400 and then use the format: dd \d\a\y\s hh:mm:ss, but when it goes over 31 days 23:59:59, the number of days goes back to 0.
How can I keep on going with the days (like 32 days 00:00:01)?
Thank you
---- Adding more ---
I forgot to mention that I'm trying to do it in a Pivot table and I have not been able to figure out how to use text in it...
I've also found the following format but it won't give me a 00 in the month:
Nb of seconds: 13670
Format : yy \y\e\a\r\s MM \m\o\n\t\h\s dd \d\a\y\s hh:mm:ss
will give: 00 years 01 months 00 days 03:47:50
The time is ok but it should shows 00 months.
You can split your result by whole part and decimal part and operate with them:
=INT(A1/86400) & " " & TEXT((A1/86400)-INT(A1/86400),"hh:mm:ss")

How do the numbers and letters differ in hexadecimal colours?

I had a look at how hexadecimal colour codes work, for the most part, it seems pretty simple. But one thing I don't understand. If I have the code #37136F, how does the 6 and the F work together? Does this mean that the two number values are added together? So the blue value is 21? Or do they add together like: 615? If it is added together (which I feel like if the most logical way) then the maximum value you can get is 30, which gives me a range of 0-30... I feel like this isn't right, please enlighten me.
First you split the hex code into pairs of digits (so #37136F becomes 37, 13, and 6F), and those are the values for red, green, and blue respectively. Let's focus on the blue component, 6F.
6F is a two digit hexadecimal number (base 16). Just as 25 in base 10 is actually 2*10 + 5, 6F in hexadecimal is actually 6*16 + 15 = 111 in base 10. In general, if X and Y are hexadecimal digits (0 through F), then XY in base 16 is X*16 + Y.
Note that the minimum and maximum two-digit hex numbers are 00 and FF respectively, which equal 0*16 + 0 = 0 and 15*16 + 15 = 255 respectively. This is why RGB values range from 0 to 255 inclusive, when written in base 10.

Reading from an Excel File and manipulating Data

I'm using Matlab to read from an Excel file. I'm supposed to be reading a column of integers called Change Due. After I read the column I am supposed to be calculating the change,in Quarters,Dimes..etc
I can read the column no problem,and I understand the math of how to calculate the change. however using a condition to check the amount of change is difficult...
Problem:
I know that for Multiplication/Division of Vectors you can add a period to make it a scalar .* or ./
But how do I parse through a vector with a condition?
if(Change.<25&&Change.>=10)
I get this Error:
Operands to the || and && operators must be convertible to logical scalar values.
If I was to just simple leave the period out I would not get an error message but it only goes through the first row for calculations.
Code:
% Filename: Program_04_1
% Author: Stewart Moon
% Assisted by: No one
% Program Description:
% The purpose of this program is to demonstrate how to read from an Excel
% file and to then calculate the amount of coins it will take per row
clc % clc clears the contents of the command window
clear % clear, clears all defined variables form the Matlab workspace
close all % closes all figure windows
% Declare Variables
Quarters=0;
Dimes=0;
Nickels=0;
Pennies=0;
TotalCoins=0;
% Output of the title and author to the command window
fprintf('Output for Program_04_1 written by Stewart Moon.\n')
fprintf('\nOriginal Data read from Program_04_1_Data.xlsx\n')
fprintf('\nMinimum Number of Coins Needed to Make Change\n')
Change=xlsread('Tutorial_04_1_Data.xlsx','Coins','B4:B43'); % Reading the column in Excel and storing it the variable Change
% Output Header Format
fprintf('\nChangeDue(cents) Quarters Dimes Nickels Pennies Total Coins\n\n')
table=[Change];
disp([table])
Command Window Output:
Output for Program_04_1 written by Stewart Moon.
Original Data read from Program_04_1_Data.xlsx
Minimum Number of Coins Needed to Make Change
ChangeDue(cents) Quarters Dimes Nickels Pennies Total Coins
1
4
5
6
10
14
15
16
20
24
25
29
30
31
35
37
40
42
45
49
50
54
55
56
60
64
65
68
70
73
75
77
80
81
85
88
90
91
95
99
Calculating Change Pseudo Code:
while(Change>0)
if (Change>=25)
Change=Change-25;
TotalCoins=TotalCoins+1;
Quarters=Quarters+1;
end
if (Change<25&&Change>=10)
Change=Change-10;
TotalCoins=TotalCoins+1;
Dimes=Dimes+1;
end
if (Change<10&&Change>=5)
Change=Change-5;
TotalCoins=TotalCoins+1;
Nickels=Nickels+1;
end
if (Change<5&&Change>=1)
Change=Change-1;
TotalCoins=TotalCoins+1;
Pennies=Pennies+1;
end
end
From my understanding, you want to achieve something like:
for i = 1 : length(Change)
% your conditions using indices for the array
% example:
% if(Change(i) > 25)
% instructions
% end
end

Can anyone help crack this time format?

I have the following time samples. The time is stored in a 32-bit representation which I will depict in HEX along with the corresponding timestamp.
e2 51 14 68 = 2011-03-23 11:56:33.684237 (UTC-4)
e2 51 19 6f = 2011-03-23 11:56:33.812511 (UTC-4)
e2 51 a0 42 = 2011-03-23 11:56:37.542177 (UTC-4)
e7 25 49 4f = 2011-03-23 14:11:35.261131 (UTC-4)
e7 2e 71 0a = 2011-03-23 14:12:35.257552 (UTC-4)
Any help in correlating these binary values with the time to determine format would be greatly appreciated. Please note that the clock source is different for the binary value and the timestamp, so there could be a small offset or slight variation.
Using the differences:
~0.2 seconds = 1287
~3.7 seconds = 34515
~8098 seconds = 80980237
~60 seconds = 600000
so it's just a certain number of tenths of milliseconds stored as an unsigned integer.
2011-03-23 11:56:33.684237 is around 3796964456 tenths of a millisecond, which is 379696.4456 seconds or ~4.395 days. So the origin (time 0) is 2011-03-19 02:28:17.
So in summary: The number of tenths of milliseconds since about 2011-03-19 02:28:17.
All in all it won't last long.. it seems like a short-term counter which doesn't keep track of years or months so much. Its total range is ~5 days.
I subtracted E251 1468 from E72E 710A, converted it to decimal, and got 81,616,034.
I subtracted 11:56:33.684237 from 14:12:35.257552, converting to seconds, and got 8161.573315.
I'm guessing that the format is a tenth of a millisecond counter.
E251 1468 converted to decimal is 3,796,964,456. Converting to time units, I get 105 hours, 28 minutes, and 16.4456 seconds.
I can't tell what the starting point of the count is, unless there's more than a slight variation.

Resources