mjbrown / bgapi

A python package for communicating with BlueGiga modules through their proprietary API.
39 stars 25 forks source link

Refactor 00 #8

Closed pinkavaj closed 8 years ago

pinkavaj commented 8 years ago

Hi,

this is just prequell and minor cleanup for more changes which I intend to push latter (response-03) after more testing.

I have one question, it is necessary pass callbacks into parse_bgapi_packet/parse_bgapi_response/.. functions? I think about replace it by some more conviniet way for changing callbacks.

mjbrown commented 8 years ago

In one of my early projects I defined a large state machine for a BLE connection sequence. I had a set of callbacks defined for each state, so that I didn't have to have "if state == START: elif state == MIDDLE:" etc. in every single callback function. It made implementation of a hierarchical state machine very easy. I could inherit methods that were unchanged and override methods with different behavior.

pinkavaj commented 8 years ago

Makes sense, I'm now working on something similar but want to achieve it different way but this give mi new inspiration.