Skip to content

Commit 9cc7891

Browse files
committed
Seems like enum:s are 7-bits on arduino
1 parent a67b82e commit 9cc7891

7 files changed

Lines changed: 66 additions & 61 deletions

File tree

components/robusto/include/robusto_media_def.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,27 +54,27 @@ extern "C"
5454

5555
/* Note: When adding a media type, update the conductor client.*/
5656

57-
typedef enum e_media_type
57+
typedef enum e_media_type
5858
{
59-
robusto_mt_none = 0,
59+
robusto_mt_none = 0U,
6060

6161
/* Wireless */
62-
robusto_mt_ble = 1,
63-
robusto_mt_espnow = 2,
64-
robusto_mt_lora = 4,
62+
robusto_mt_ble = 1U,
63+
robusto_mt_espnow = 2U,
64+
robusto_mt_lora = 4U,
6565

6666
/* Wired */
67-
robusto_mt_i2c = 8,
67+
robusto_mt_i2c = 8U,
6868

69-
robusto_mt_canbus = 16,
69+
robusto_mt_canbus = 16U,
7070
/* TODO: To be implemented
7171
72-
robusto_mt_umts = 32, // TODO: Only implemented as a gateway service.
73-
robusto_mt_wifi = 64, // TODO: On what level should UMTS and wifi be implemented? Neither are direct and both use IP adressing
72+
robusto_mt_umts = 32U, // TODO: Only implemented as a gateway service.
73+
robusto_mt_wifi = 64U, // TODO: On what level should UMTS and wifi be implemented? Neither are direct and both use IP adressing
7474
// TTL? Onewire? Probably this should be implemented in some way. Or onewire. (perhaps separate for testing connections)
7575
*/
7676
/* Special types */
77-
robusto_mt_mock = 128
77+
robusto_mt_mock = 128U
7878
} e_media_type;
7979

8080
typedef uint8_t robusto_media_types;

components/robusto/network/src/peer/robusto_peer.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,8 @@ robusto_media_t * get_media_info(robusto_peer_t * peer, e_media_type media_type)
325325
}
326326
#endif
327327

328-
ROB_LOGE(peer_log_prefix, "Invalid media type (%hhu) in get_media_info for peer %s", media_type, peer->name);
328+
ROB_LOGE(peer_log_prefix, "Invalid media type (%u) in get_media_info for peer %s", media_type, peer->name);
329+
r_delay(1000);
329330
return NULL;
330331
}
331332

@@ -339,6 +340,7 @@ robusto_media_t * get_media_info(robusto_peer_t * peer, e_media_type media_type)
339340
*/
340341
float score_peer(robusto_peer_t *peer, e_media_type media_type, int data_length)
341342
{
343+
342344
robusto_media_t *curr_info = get_media_info(peer, media_type);
343345

344346
ROB_LOGD(peer_log_prefix, "Mt: %s, peer: %s ss: %"PRIu32", rs: %"PRIu32", sf: %"PRIu32", rf: %"PRIu32" ",

components/robusto/network/src/peer/robusto_presentation.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ rob_ret_val_t robusto_send_presentation(robusto_peer_t *peer, robusto_media_type
8080
ROB_LOGD(presentation_log_prefix, ">> Presentation to send:");
8181
rob_log_bit_mesh(ROB_LOG_DEBUG, presentation_log_prefix, msg, msg_len);
8282
queue_state *q_state = robusto_malloc(sizeof(queue_state));
83+
e_media_type supported_mt = get_host_supported_media_types();
8384
rob_ret_val_t ret_val_flag;
84-
for (e_media_type media_type = 1; media_type < 256; media_type = media_type * 2)
85+
for (uint16_t media_type = 1; media_type < 25; media_type = media_type * 2)
8586
{
86-
if ((media_types & media_type) != media_type)
87+
if ((!(media_types & media_type) || !(supported_mt & media_type)))
8788
{
8889
continue;
8990
}
90-
9191
robusto_media_t *info = get_media_info(peer, media_type);
9292
/* Send presentation:
9393
* no receipt as a reply requires know outgoing id, which is only available after presentation is parsed

components/robusto/network/src/qos/qos_heartbeat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ void peer_heartbeat(robusto_peer_t *peer)
149149
uint64_t last_heartbeat = curr_time - HEARTBEAT_IDLE_MARGIN_MS;
150150
}
151151

152-
for (e_media_type media_type = 1; media_type < 256; media_type = media_type * 2)
152+
for (uint16_t media_type = 1; media_type < 256; media_type = media_type * 2)
153153
{
154154
if ((peer->supported_media_types & media_type) != media_type)
155155
{

components/robusto/network/src/qos/qos_scoring.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,13 @@ void add_to_history(robusto_media_t *stats, bool sending, rob_ret_val_t result)
120120
uint32_t robusto_calc_suitability(e_media_type media_type, uint32_t payloadSize) {
121121
int phc;
122122
switch (media_type) {
123+
#if CONFIG_ROBUSTO_SUPPORTS_CANBUS
123124
case robusto_mt_canbus:
124125
// CAN bus is great with small volumes, but quickly start losing out.
125126
phc = (payloadSize - CANBUS_MESSAGE_OFFSET <= 8) ? 100 : 80 - ((payloadSize - CANBUS_MESSAGE_OFFSET - 8) / 10);
126127
// TODO: Shoud stop showing the data length with a lot of data that won't be used in many cases, especially like the 20 bytes here
127128
break;
129+
#endif
128130
case robusto_mt_espnow:
129131
phc = 100; // ESP-NOW is quite flexible
130132
break;
@@ -136,6 +138,7 @@ uint32_t robusto_calc_suitability(e_media_type media_type, uint32_t payloadSize)
136138
phc = 80 - (payloadSize - ROBUSTO_CRC_LENGTH / 10); // Decrease with size
137139
break;
138140
default:
141+
ROB_LOGE(scoring_log_prefix, "robusto_calc_suitability: Unsupported media type: %s", media_type_to_str(media_type));
139142
phc = 50; // Default case
140143
}
141144
if (phc > 100) phc = 100; // Ensure not to exceed 100
@@ -231,7 +234,7 @@ void update_score(robusto_peer_t *peer, e_media_type media_type)
231234
void peer_scoring(robusto_peer_t *peer)
232235
{
233236

234-
for (e_media_type media_type = 1; media_type < 256; media_type = media_type * 2)
237+
for (uint16_t media_type = 1; media_type < 256; media_type = media_type * 2)
235238
{
236239
if ((peer->supported_media_types & media_type) != media_type)
237240
{

components/robusto/network/src/qos/qos_state.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ rob_ret_val_t check_peer(robusto_peer_t *peer)
290290
return ROB_OK;
291291
}
292292
// Loop all media types and check each
293-
for (e_media_type media_type = 1; media_type < 256; media_type = media_type * 2)
293+
for (uint16_t media_type = 1; media_type < 256; media_type = media_type * 2)
294294
{
295295
if (
296296
!(

platformio.ini

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -35,50 +35,6 @@ extra_scripts =
3535
${env.extra_scripts}
3636
test/test-coverage.py
3737

38-
39-
[env:TTGO-LoRa32-v1]
40-
; Used with the The TTGO LORA32 SX1278 board
41-
42-
platform = espressif32@6.5.0
43-
framework = espidf
44-
;platform_packages = platformio/framework-espidf@^3.50000.0
45-
board = ttgo-lora32-v1
46-
47-
monitor_port = /dev/cu.wchusbserial531C0101801
48-
upload_port = /dev/cu.wchusbserial531C0101801
49-
test_port = /dev/cu.wchusbserial531C0101801
50-
;debug_test = *
51-
monitor_speed = 115200
52-
monitor_filters = esp32_exception_decoder
53-
;lib_extra_dirs = test
54-
; Private: MAC 58bf250541e0
55-
lib_deps =
56-
${env.lib_deps}
57-
adafruit/Adafruit SSD1306@^2.5.7
58-
59-
; Better partioning
60-
;board_build.partitions = min_spiffs.csv
61-
62-
[env:TTGO-T-Beam]
63-
; Used with the TTGO T-BEAM SX1262 TCXO board
64-
platform = espressif32@6.5.0
65-
framework = espidf
66-
board = ttgo-t-beam
67-
monitor_port = /dev/cu.wchusbserial54FC0473971
68-
upload_port = /dev/cu.wchusbserial54FC0473971
69-
test_port = /dev/cu.wchusbserial54FC0473971
70-
71-
;monitor_port = /dev/cu.wchusbserial537E0890921
72-
;upload_port = /dev/cu.wchusbserial537E0890921
73-
;test_port = /dev/cu.wchusbserial537E0890921
74-
board_build.partitions = min_spiffs.csv
75-
debug_test = *
76-
;monitor_port = /dev/cu.wchusbserial537E0890921
77-
;upload_port = /dev/cu.wchusbserial537E0890921
78-
monitor_speed = 115200
79-
monitor_filters = esp32_exception_decoder
80-
81-
8238
[env:Devkit_v4_no_network]
8339
; Used with the The ESP32 devkit board
8440
platform = espressif32@6.5.0
@@ -96,3 +52,47 @@ monitor_filters = esp32_exception_decoder
9652
board_build.partitions = min_spiffs.csv
9753

9854

55+
56+
; --------------------------
57+
; The RaspberryPi Pico uses picotool for uploading.
58+
; Note: There is nothing that identifies the board, so having multiple
59+
; boards might be a problem. TODO: Check how to specify this.
60+
[env:RaspberryPi_Pico]
61+
#platform = raspberrypi
62+
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
63+
board = pico
64+
framework = arduino
65+
lib_extra_dirs = test, components
66+
lib_compat_mode = off
67+
test_framework= unity
68+
#test_framework= custom
69+
board_build.core = earlephilhower
70+
upload_protocol = picotool
71+
monitor_speed = 115200
72+
monitor_port = /dev/cu.usbmodem141101
73+
monitor_raw = yes
74+
test_port = /dev/cu.usbmodem141101
75+
;test_port = /Volumes/RPI-RP2
76+
;upload_port = /dev/cu.usbmodem141101
77+
;upload_port = /Volumes/RPI-RP2
78+
lib_deps =
79+
${env.lib_deps}
80+
Wire
81+
;https://github.com/nicklasb/RadioLib.git
82+
build_flags =
83+
-DUNITY_OUTPUT_CHAR=robusto_test_log
84+
;board_build.hwids = [0x2E8A,0x00C0]
85+
;board_build.hwids = [0x2E8A,0x000A]
86+
; monitor_port = /dev/cu.usbmodem1423301
87+
; upload_port = /dev/cu.usbmodem1423201
88+
; test_port = /dev/cu.usbmodem1423201
89+
90+
;upload_port = /dev/cu.wchusbserial1423201
91+
;test_port = /dev/cu.wchusbserial1423201
92+
93+
; Do not re-enable these
94+
;lib_deps = feilipu/FreeRTOS
95+
;We will have to add build flags fo
96+
;build_flags =
97+
; -DportUSE_WDTO=WDTO_15MS
98+
;/dev/cu.usbmodem4E8D368338001

0 commit comments

Comments
 (0)