diff --git a/pyaci/aci/AciEvent.py b/pyaci/aci/AciEvent.py index 1eb139f..911149c 100644 --- a/pyaci/aci/AciEvent.py +++ b/pyaci/aci/AciEvent.py @@ -127,7 +127,8 @@ def __init__(self,pkt): logging.error("Invalid length for %s event: %s", self.__class__.__name__, str(pkt)) else: self.ValueHandle = (pkt[3] << 8) + pkt[2] - self.Data = pkt[4:] + self.VersionDelta = (pkt[5] << 8) + pkt[4] + self.Data = pkt[6:] def is_sensor_update(self): return self.ValueHandle >> 8 == 0x01 @@ -137,7 +138,7 @@ def sensor_values(self): def __repr__(self): if self.is_sensor_update(): - return str.format("%s %s" %(self.__class__.__name__, self.sensor_values())) + return str.format("%s(%d) %s" %(self.__class__.__name__, self.VersionDelta, self.sensor_values())) else: return str.format("%s length:%d opcode:0x%02x value_handle:0x%04x data:%s" %(self.__class__.__name__, self.Len, self.OpCode, self.ValueHandle, self.Data)) diff --git a/rbc_mesh/include/serial_evt.h b/rbc_mesh/include/serial_evt.h index 4770990..29a65ae 100644 --- a/rbc_mesh/include/serial_evt.h +++ b/rbc_mesh/include/serial_evt.h @@ -134,24 +134,28 @@ typedef __packed_armcc struct typedef __packed_armcc struct { rbc_mesh_value_handle_t handle; + uint16_t version_delta; uint8_t data[RBC_MESH_VALUE_MAX_LEN]; } __packed_gcc serial_evt_params_event_new_t; typedef __packed_armcc struct { rbc_mesh_value_handle_t handle; + uint16_t version_delta; uint8_t data[RBC_MESH_VALUE_MAX_LEN]; } __packed_gcc serial_evt_params_event_update_t; typedef __packed_armcc struct { rbc_mesh_value_handle_t handle; + uint16_t version_delta; uint8_t data[RBC_MESH_VALUE_MAX_LEN]; } __packed_gcc serial_evt_params_event_conflicting_t; typedef __packed_armcc struct { rbc_mesh_value_handle_t handle; + uint16_t version_delta; uint8_t data[RBC_MESH_VALUE_MAX_LEN]; } __packed_gcc serial_evt_params_event_tx_t; diff --git a/rbc_mesh/rbc_mesh.h b/rbc_mesh/rbc_mesh.h index 463198e..d4042ae 100644 --- a/rbc_mesh/rbc_mesh.h +++ b/rbc_mesh/rbc_mesh.h @@ -65,8 +65,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #if defined(WITH_ACK_MASTER) || defined (WITHOUT_ACK_MASTER) #define RBC_MESH_HANDLE_CACHE_ENTRIES (105) #else - #define RBC_MESH_HANDLE_CACHE_ENTRIES (10) - #endif + #define RBC_MESH_HANDLE_CACHE_ENTRIES (20) + #endif #endif /** @brief Default value for the number of data cache entries */ @@ -74,7 +74,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #if defined(WITH_ACK_MASTER) || defined (WITHOUT_ACK_MASTER) #define RBC_MESH_DATA_CACHE_ENTRIES (105) #else - #define RBC_MESH_DATA_CACHE_ENTRIES (10) + #define RBC_MESH_DATA_CACHE_ENTRIES (20) #endif #endif @@ -612,4 +612,3 @@ void rbc_mesh_event_release(rbc_mesh_event_t* p_evt); void rbc_mesh_packet_peek_cb_set(rbc_mesh_packet_peek_cb_t packet_peek_cb); #endif /* _RBC_MESH_H__ */ - diff --git a/rbc_mesh/src/mesh_aci.c b/rbc_mesh/src/mesh_aci.c index ffbe4f2..4851854 100644 --- a/rbc_mesh/src/mesh_aci.c +++ b/rbc_mesh/src/mesh_aci.c @@ -645,11 +645,12 @@ void mesh_aci_rbc_event_handler(rbc_mesh_event_t* evt) break; } - /* serial overhead: opcode + handle = 3 */ - serial_evt.length = 3 + evt->params.rx.data_len; + /* serial overhead: opcode + handle + version = 5 */ + serial_evt.length = 5 + evt->params.rx.data_len; /* all event parameter types are the same, just use event_update for all */ serial_evt.params.event_update.handle = evt->params.rx.value_handle; + serial_evt.params.event_update.version_delta = evt->params.rx.version_delta; memcpy(serial_evt.params.event_update.data, evt->params.rx.p_data, evt->params.rx.data_len); serial_handler_event_send(&serial_evt); diff --git a/src/main.c b/src/main.c index 573f51c..1a9a479 100644 --- a/src/main.c +++ b/src/main.c @@ -188,16 +188,27 @@ int main(void) sensor_init(); } + error_code = rbc_mesh_value_enable(TEST_LED_HANDLE); + APP_ERROR_CHECK(error_code); + // Start clock start_clock(0); //rbc_mesh_stop(); //rbc_mesh_start(); //sd_app_evt_wait(); - while(1) { - __WFE(); - __SEV(); - __WFE(); - } + // while(1) { + // __WFE(); + // __SEV(); + // __WFE(); + // } + rbc_mesh_event_t evt; + while (true) { + if (rbc_mesh_event_get(&evt) == NRF_SUCCESS) { + rbc_mesh_event_handler(&evt); + rbc_mesh_event_release(&evt); + } + sd_app_evt_wait(); + } } diff --git a/src/shoe_accel.c b/src/shoe_accel.c index 60692de..a27dcbc 100644 --- a/src/shoe_accel.c +++ b/src/shoe_accel.c @@ -9,7 +9,6 @@ #define Z_PIN 6 void shoe_accel_init() { - return; nrf_gpio_cfg_output(ACCEL_POWER_PIN); nrf_gpio_cfg_input(X_PIN, NRF_GPIO_PIN_NOPULL); nrf_gpio_cfg_input(Z_PIN, NRF_GPIO_PIN_NOPULL);