Skip to content

Commit

Permalink
reinstate mesh event handler
Browse files Browse the repository at this point in the history
  • Loading branch information
ps2 committed Apr 29, 2017
1 parent d2ecd29 commit cd3e98f
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 14 deletions.
5 changes: 3 additions & 2 deletions pyaci/aci/AciEvent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))

Expand Down
4 changes: 4 additions & 0 deletions rbc_mesh/include/serial_evt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
7 changes: 3 additions & 4 deletions rbc_mesh/rbc_mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,16 @@ 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 */
#ifndef RBC_MESH_DATA_CACHE_ENTRIES
#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

Expand Down Expand Up @@ -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__ */

5 changes: 3 additions & 2 deletions rbc_mesh/src/mesh_aci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
21 changes: 16 additions & 5 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
1 change: 0 additions & 1 deletion src/shoe_accel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit cd3e98f

Please sign in to comment.