Skip to content

Commit 52bc6b1

Browse files
committed
Merge remote-tracking branch 'upstream/master' into update_libdivecomputer_20240725
2 parents 710fc40 + b0a5ce7 commit 52bc6b1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1561
-362
lines changed

.github/workflows/build.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
CC: ${{ matrix.compiler }}
2020

2121
steps:
22-
- uses: actions/checkout@v3
22+
- uses: actions/checkout@v4
2323
- name: Install dependencies
2424
run: sudo apt-get install libbluetooth-dev libusb-1.0-0-dev
2525
- run: autoreconf --install --force
@@ -30,7 +30,7 @@ jobs:
3030
run: |
3131
make install DESTDIR=$PWD/artifacts
3232
tar -czf ${{ github.job }}-${{ matrix.compiler }}.tar.gz -C artifacts usr
33-
- uses: actions/upload-artifact@v3
33+
- uses: actions/upload-artifact@v4
3434
with:
3535
name: ${{ github.job }}-${{ matrix.compiler }}
3636
path: ${{ github.job }}-${{ matrix.compiler }}.tar.gz
@@ -50,7 +50,7 @@ jobs:
5050
CC: ${{ matrix.compiler }}
5151

5252
steps:
53-
- uses: actions/checkout@v3
53+
- uses: actions/checkout@v4
5454
- name: Install dependencies
5555
run: brew install autoconf automake libtool hidapi libusb
5656
- run: autoreconf --install --force
@@ -61,7 +61,7 @@ jobs:
6161
run: |
6262
make install DESTDIR=$PWD/artifacts
6363
tar -czf ${{ github.job }}-${{ matrix.compiler }}.tar.gz -C artifacts usr
64-
- uses: actions/upload-artifact@v3
64+
- uses: actions/upload-artifact@v4
6565
with:
6666
name: ${{ github.job }}-${{ matrix.compiler }}
6767
path: ${{ github.job }}-${{ matrix.compiler }}.tar.gz
@@ -78,7 +78,7 @@ jobs:
7878
arch: [i686, x86_64]
7979

8080
steps:
81-
- uses: actions/checkout@v3
81+
- uses: actions/checkout@v4
8282
- name: Install dependencies
8383
run: sudo apt-get install gcc-mingw-w64 binutils-mingw-w64 mingw-w64-tools
8484
- name: Install libusb
@@ -118,7 +118,7 @@ jobs:
118118
run: |
119119
make install DESTDIR=$PWD/artifacts
120120
tar -czf ${{ github.job }}-${{ matrix.arch }}.tar.gz -C artifacts usr
121-
- uses: actions/upload-artifact@v3
121+
- uses: actions/upload-artifact@v4
122122
with:
123123
name: ${{ github.job }}-${{ matrix.arch }}
124124
path: ${{ github.job }}-${{ matrix.arch }}.tar.gz
@@ -161,13 +161,13 @@ jobs:
161161
runs-on: ubuntu-latest
162162

163163
steps:
164-
- uses: actions/checkout@v3
164+
- uses: actions/checkout@v4
165165
- run: |
166166
autoreconf --install --force
167167
./configure --prefix=/usr
168168
make -C src revision.h
169169
- run: $ANDROID_NDK/ndk-build -C contrib/android NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk
170-
- uses: actions/upload-artifact@v3
170+
- uses: actions/upload-artifact@v4
171171
with:
172172
name: ${{ github.job }}
173173
path: contrib/android/libs

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
name: Release
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v3
12+
- uses: actions/checkout@v4
1313

1414
- name: Version number
1515
id: version

contrib/android/Android.mk

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ LOCAL_SRC_FILES := \
7171
src/oceans_s1_parser.c \
7272
src/packet.c \
7373
src/parser.c \
74+
src/pelagic_i330r.c \
7475
src/platform.c \
7576
src/rbstream.c \
7677
src/reefnet_sensus.c \

contrib/msvc/libdivecomputer.vcxproj

+2
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@
239239
<ClCompile Include="..\..\src\oceans_s1_parser.c" />
240240
<ClCompile Include="..\..\src\packet.c" />
241241
<ClCompile Include="..\..\src\parser.c" />
242+
<ClCompile Include="..\..\src\pelagic_i330r.c" />
242243
<ClCompile Include="..\..\src\platform.c" />
243244
<ClCompile Include="..\..\src\rbstream.c" />
244245
<ClCompile Include="..\..\src\reefnet_sensus.c" />
@@ -357,6 +358,7 @@
357358
<ClInclude Include="..\..\src\oceans_s1_common.h" />
358359
<ClInclude Include="..\..\src\packet.h" />
359360
<ClInclude Include="..\..\src\parser-private.h" />
361+
<ClInclude Include="..\..\src\pelagic_i330r.h" />
360362
<ClInclude Include="..\..\src\platform.h" />
361363
<ClInclude Include="..\..\src\rbstream.h" />
362364
<ClInclude Include="..\..\src\reefnet_sensus.h" />

examples/common.c

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ static const backend_table_t g_backends[] = {
7272
{"vtpro", DC_FAMILY_OCEANIC_VTPRO, 0x4245},
7373
{"veo250", DC_FAMILY_OCEANIC_VEO250, 0x424C},
7474
{"atom2", DC_FAMILY_OCEANIC_ATOM2, 0x4342},
75+
{"i330r", DC_FAMILY_PELAGIC_I330R, 0x4744},
7576
{"nemo", DC_FAMILY_MARES_NEMO, 0},
7677
{"puck", DC_FAMILY_MARES_PUCK, 7},
7778
{"darwin", DC_FAMILY_MARES_DARWIN, 0},

examples/output_xml.c

+20
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,27 @@ dctool_xml_output_write (dctool_output_t *abstract, dc_parser_t *parser, const u
489489
break;
490490
fprintf (output->ostream, "<extradata key='%s' value='%s' />\n",
491491
str.desc, str.value);
492+
}
492493

494+
// Parse the GPS location.
495+
message ("Parsing the GPS location.\n");
496+
dc_location_t location = {0};
497+
status = dc_parser_get_field (parser, DC_FIELD_LOCATION, 0, &location);
498+
if (status != DC_STATUS_SUCCESS && status != DC_STATUS_UNSUPPORTED) {
499+
ERROR ("Error parsing the GPS location.");
500+
goto cleanup;
501+
}
502+
503+
if (status != DC_STATUS_UNSUPPORTED) {
504+
fprintf (output->ostream,
505+
"<location>\n"
506+
" <latitude>%.6f<latitude>\n"
507+
" <longitude>%.6f</longitude>\n"
508+
" <altitude>%.2f<altitude>\n"
509+
"</location>\n",
510+
location.latitude,
511+
location.longitude,
512+
convert_depth(location.altitude, output->units));
493513
}
494514

495515
// Parse the sample data.

include/libdivecomputer/ble.h

+15
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,21 @@ extern "C" {
3333
*/
3434
#define DC_IOCTL_BLE_GET_NAME DC_IOCTL_IOR('b', 0, DC_IOCTL_SIZE_VARIABLE)
3535

36+
/**
37+
* Get the bluetooth authentication PIN code.
38+
*
39+
* The data format is a NULL terminated string.
40+
*/
41+
#define DC_IOCTL_BLE_GET_PINCODE DC_IOCTL_IOR('b', 1, DC_IOCTL_SIZE_VARIABLE)
42+
43+
/**
44+
* Get/set the bluetooth authentication access code.
45+
*
46+
* The data format is a variable sized byte array.
47+
*/
48+
#define DC_IOCTL_BLE_GET_ACCESSCODE DC_IOCTL_IOR('b', 2, DC_IOCTL_SIZE_VARIABLE)
49+
#define DC_IOCTL_BLE_SET_ACCESSCODE DC_IOCTL_IOW('b', 2, DC_IOCTL_SIZE_VARIABLE)
50+
3651
#ifdef __cplusplus
3752
}
3853
#endif /* __cplusplus */

include/libdivecomputer/common.h

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ typedef enum dc_family_t {
7878
DC_FAMILY_OCEANIC_VTPRO = (4 << 16),
7979
DC_FAMILY_OCEANIC_VEO250,
8080
DC_FAMILY_OCEANIC_ATOM2,
81+
DC_FAMILY_PELAGIC_I330R,
8182
/* Mares */
8283
DC_FAMILY_MARES_NEMO = (5 << 16),
8384
DC_FAMILY_MARES_PUCK,

include/libdivecomputer/parser.h

+13
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ typedef enum dc_field_type_t {
6969
DC_FIELD_DIVEMODE,
7070
DC_FIELD_DECOMODEL,
7171
DC_FIELD_STRING,
72+
DC_FIELD_LOCATION,
7273
} dc_field_type_t;
7374

7475
// Make it easy to test support compile-time with "#ifdef DC_FIELD_STRING"
@@ -279,6 +280,18 @@ typedef struct dc_field_string_t {
279280
const char *value;
280281
} dc_field_string_t;
281282

283+
/*
284+
* GPS Location
285+
*
286+
* The latitude and longitude are in decimal degrees, and the (optional)
287+
* altitude in meters.
288+
*/
289+
typedef struct dc_location_t {
290+
double latitude;
291+
double longitude;
292+
double altitude;
293+
} dc_location_t;
294+
282295
typedef union dc_sample_value_t {
283296
unsigned int time; /* Milliseconds */
284297
double depth;

src/Makefile.am

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ libdivecomputer_la_SOURCES = \
4343
oceanic_atom2.h oceanic_atom2.c oceanic_atom2_parser.c \
4444
oceanic_veo250.h oceanic_veo250.c oceanic_veo250_parser.c \
4545
oceanic_vtpro.h oceanic_vtpro.c oceanic_vtpro_parser.c \
46+
pelagic_i330r.h pelagic_i330r.c \
4647
mares_common.h mares_common.c \
4748
mares_nemo.h mares_nemo.c mares_nemo_parser.c \
4849
mares_puck.h mares_puck.c \

src/cochran_commander.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ cochran_commander_profile_size(cochran_commander_device_t *device, cochran_data_
603603
// Corrupt dive, guess the end address
604604
sample_end_address = cochran_commander_guess_sample_end_address(device, data, dive_num);
605605

606-
return ringbuffer_distance(sample_start_address, sample_end_address, 0, device->layout->rb_profile_begin, device->layout->rb_profile_end);
606+
return ringbuffer_distance(sample_start_address, sample_end_address, DC_RINGBUFFER_EMPTY, device->layout->rb_profile_begin, device->layout->rb_profile_end);
607607
}
608608

609609

@@ -965,7 +965,7 @@ cochran_commander_device_foreach (dc_device_t *abstract, dc_dive_callback_t call
965965
last_start_address = base + array_uint32_le(data.config + layout->cf_last_log );
966966

967967
// Create the ringbuffer stream.
968-
status = dc_rbstream_new (&rbstream, abstract, 1, layout->rbstream_size, layout->rb_profile_begin, layout->rb_profile_end, last_start_address);
968+
status = dc_rbstream_new (&rbstream, abstract, 1, layout->rbstream_size, layout->rb_profile_begin, layout->rb_profile_end, last_start_address, DC_RBSTREAM_BACKWARD);
969969
if (status != DC_STATUS_SUCCESS) {
970970
ERROR (abstract->context, "Failed to create the ringbuffer stream.");
971971
goto error;

src/cressi_edy.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ cressi_edy_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, v
432432
}
433433

434434
// Get the number of logbook items.
435-
unsigned int count = ringbuffer_distance (first, last, 0, layout->rb_logbook_begin, layout->rb_logbook_end) + 1;
435+
unsigned int count = ringbuffer_distance (first, last, DC_RINGBUFFER_EMPTY, layout->rb_logbook_begin, layout->rb_logbook_end) + 1;
436436

437437
// Get the profile pointer.
438438
unsigned int eop = array_uint_le (logbook + layout->config + 2, layout->rb_logbook_size) * SZ_PAGE + layout->rb_profile_begin;
@@ -457,7 +457,7 @@ cressi_edy_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, v
457457
}
458458

459459
// Get the profile length.
460-
unsigned int length = ringbuffer_distance (current, previous, 1, layout->rb_profile_begin, layout->rb_profile_end);
460+
unsigned int length = ringbuffer_distance (current, previous, DC_RINGBUFFER_FULL, layout->rb_profile_begin, layout->rb_profile_end);
461461

462462
// Check for a ringbuffer overflow.
463463
if (total + length > layout->rb_profile_end - layout->rb_profile_begin) {
@@ -481,7 +481,7 @@ cressi_edy_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, v
481481

482482
// Create the ringbuffer stream.
483483
dc_rbstream_t *rbstream = NULL;
484-
rc = dc_rbstream_new (&rbstream, abstract, SZ_PAGE, SZ_PACKET, layout->rb_profile_begin, layout->rb_profile_end, eop);
484+
rc = dc_rbstream_new (&rbstream, abstract, SZ_PAGE, SZ_PACKET, layout->rb_profile_begin, layout->rb_profile_end, eop, DC_RBSTREAM_BACKWARD);
485485
if (rc != DC_STATUS_SUCCESS) {
486486
ERROR (abstract->context, "Failed to create the ringbuffer stream.");
487487
return rc;
@@ -510,7 +510,7 @@ cressi_edy_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, v
510510
}
511511

512512
// Get the profile length.
513-
unsigned int length = ringbuffer_distance (current, previous, 1, layout->rb_profile_begin, layout->rb_profile_end);
513+
unsigned int length = ringbuffer_distance (current, previous, DC_RINGBUFFER_FULL, layout->rb_profile_begin, layout->rb_profile_end);
514514

515515
// Move to the begin of the current dive.
516516
offset -= length;

src/cressi_leonardo.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
#define RB_PROFILE_BEGIN 0x1438
4343
#define RB_PROFILE_END SZ_MEMORY
44-
#define RB_PROFILE_DISTANCE(a,b) ringbuffer_distance (a, b, 0, RB_PROFILE_BEGIN, RB_PROFILE_END)
44+
#define RB_PROFILE_DISTANCE(a,b) ringbuffer_distance (a, b, DC_RINGBUFFER_EMPTY, RB_PROFILE_BEGIN, RB_PROFILE_END)
4545

4646
#define MAXRETRIES 4
4747
#define PACKETSIZE 32

src/descriptor.c

+8
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,9 @@ static const dc_descriptor_t g_descriptors[] = {
275275
{"Aqualung", "i470TC", DC_FAMILY_OCEANIC_ATOM2, 0x4743, DC_TRANSPORT_SERIAL | DC_TRANSPORT_BLE, dc_filter_oceanic},
276276
{"Aqualung", "i200Cv2", DC_FAMILY_OCEANIC_ATOM2, 0x4749, DC_TRANSPORT_SERIAL | DC_TRANSPORT_BLE, dc_filter_oceanic},
277277
{"Oceanic", "Geo Air", DC_FAMILY_OCEANIC_ATOM2, 0x474B, DC_TRANSPORT_SERIAL | DC_TRANSPORT_BLE, dc_filter_oceanic},
278+
/* Pelagic I330R */
279+
{"Apeks", "DSX", DC_FAMILY_PELAGIC_I330R, 0x4741, DC_TRANSPORT_BLE, dc_filter_oceanic},
280+
{"Aqualung", "i330R", DC_FAMILY_PELAGIC_I330R, 0x4744, DC_TRANSPORT_BLE, dc_filter_oceanic},
278281
/* Mares Nemo */
279282
{"Mares", "Nemo", DC_FAMILY_MARES_NEMO, 0, DC_TRANSPORT_SERIAL, NULL},
280283
{"Mares", "Nemo Steel", DC_FAMILY_MARES_NEMO, 0, DC_TRANSPORT_SERIAL, NULL},
@@ -365,6 +368,8 @@ static const dc_descriptor_t g_descriptors[] = {
365368
{"Shearwater", "Petrel 3", DC_FAMILY_SHEARWATER_PETREL, 10, DC_TRANSPORT_BLE, dc_filter_shearwater},
366369
{"Shearwater", "Perdix 2", DC_FAMILY_SHEARWATER_PETREL, 11, DC_TRANSPORT_BLE, dc_filter_shearwater},
367370
{"Shearwater", "Tern", DC_FAMILY_SHEARWATER_PETREL, 12, DC_TRANSPORT_BLE, dc_filter_shearwater},
371+
{"Shearwater", "Tern TX", DC_FAMILY_SHEARWATER_PETREL, 12, DC_TRANSPORT_BLE, dc_filter_shearwater},
372+
{"Shearwater", "Peregrine TX", DC_FAMILY_SHEARWATER_PETREL, 13, DC_TRANSPORT_BLE, dc_filter_shearwater},
368373
/* Dive Rite NiTek Q */
369374
{"Dive Rite", "NiTek Q", DC_FAMILY_DIVERITE_NITEKQ, 0, DC_TRANSPORT_SERIAL, NULL},
370375
/* Citizen Hyper Aqualand */
@@ -685,6 +690,7 @@ dc_filter_shearwater (dc_descriptor_t *descriptor, dc_transport_t transport, con
685690
"Perdix 2",
686691
"Teric",
687692
"Peregrine",
693+
"Peregrine TX",
688694
"Tern"
689695
};
690696

@@ -762,8 +768,10 @@ dc_filter_oceanic (dc_descriptor_t *descriptor, dc_transport_t transport, const
762768
0x4654, // Oceanic Veo 4.0
763769
0x4655, // Sherwood Wisdom 4
764770
0x4656, // Oceanic Pro Plus 4
771+
0x4741, // Apeks DSX
765772
0x4742, // Sherwood Beacon
766773
0x4743, // Aqualung i470TC
774+
0x4744, // Aqualung i330R
767775
0x4749, // Aqualung i200C (newer model)
768776
0x474B, // Oceanic Geo Air
769777
};

src/device.c

+4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "oceanic_atom2.h"
3939
#include "oceanic_veo250.h"
4040
#include "oceanic_vtpro.h"
41+
#include "pelagic_i330r.h"
4142
#include "mares_darwin.h"
4243
#include "mares_iconhd.h"
4344
#include "mares_nemo.h"
@@ -165,6 +166,9 @@ dc_device_open (dc_device_t **out, dc_context_t *context, dc_descriptor_t *descr
165166
case DC_FAMILY_OCEANIC_ATOM2:
166167
rc = oceanic_atom2_device_open (&device, context, iostream, dc_descriptor_get_model (descriptor));
167168
break;
169+
case DC_FAMILY_PELAGIC_I330R:
170+
rc = pelagic_i330r_device_open (&device, context, iostream, dc_descriptor_get_model (descriptor));
171+
break;
168172
case DC_FAMILY_MARES_NEMO:
169173
rc = mares_nemo_device_open (&device, context, iostream);
170174
break;

0 commit comments

Comments
 (0)