Skip to content

Commit 38013ce

Browse files
tekka007henrikekblad
authored andcommitted
Fix bug preventing msgs from GW-attached sensors (#698)
1 parent 6a68510 commit 38013ce

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

core/MySensorsCore.cpp

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -223,29 +223,35 @@ void presentNode(void)
223223

224224
uint8_t getNodeId(void)
225225
{
226-
#if defined(MY_SENSOR_NETWORK)
227-
return transportGetNodeId();
228-
#else
229-
return 0xFF;
226+
uint8_t result = VALUE_NOT_DEFINED;
227+
#if defined(MY_GATEWAY_FEATURE)
228+
result = GATEWAY_ADDRESS;
229+
#elif defined(MY_SENSOR_NETWORK)
230+
result = transportGetNodeId();
230231
#endif
232+
return result;
231233
}
232234

233235
uint8_t getParentNodeId(void)
234236
{
235-
#if defined(MY_SENSOR_NETWORK)
236-
return transportGetParentNodeId();
237-
#else
238-
return 0xFF;
237+
uint8_t result = VALUE_NOT_DEFINED;
238+
#if defined(MY_GATEWAY_FEATURE)
239+
result = VALUE_NOT_DEFINED; // GW doesn't have a parent
240+
#elif defined(MY_SENSOR_NETWORK)
241+
result = transportGetParentNodeId();
239242
#endif
243+
return result;
240244
}
241245

242246
uint8_t getDistanceGW(void)
243247
{
244-
#if defined(MY_SENSOR_NETWORK)
245-
return transportGetDistanceGW();
246-
#else
247-
return 0xFF;
248+
uint8_t result = VALUE_NOT_DEFINED;
249+
#if defined(MY_GATEWAY_FEATURE)
250+
result = 0;
251+
#elif defined(MY_SENSOR_NETWORK)
252+
result = transportGetDistanceGW();
248253
#endif
254+
return result;
249255
}
250256

251257
controllerConfig_t getConfig(void)

core/MySensorsCore.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
#define MY_SLEEP_NOT_POSSIBLE ((int8_t)-2) //!< Sleeping not possible
8484
#define INTERRUPT_NOT_DEFINED ((uint8_t)255) //!< _sleep() param: no interrupt defined
8585
#define MODE_NOT_DEFINED ((uint8_t)255) //!< _sleep() param: no mode defined
86+
#define VALUE_NOT_DEFINED ((uint8_t)255) //!< Value not defined
8687

8788

8889
#ifdef MY_DEBUG

0 commit comments

Comments
 (0)