afLib update 2/23/17


#1

Hi, everybody!

Today Afero is releasing an update to our Arduino library afLib, available at https://github.com/aferodeveloper/afLib

From developer feedback, we renamed a couple of functions to be more descriptively named:

onAttrSet is now attrSetHandler
onAttrSetComplete is now attrNotifyHandler

Most simple sketches probably won’t need to be changed, but if you were using onAttrSet to get notified when an attribute was changed from the service and onAttrSetComplete to get notified when an attribute was read from the service, then you’ll need to make some simple changes to your sketch.

creating the aflib instance:
`- aflib = iafLib::create(digitalPinToInterrupt(INT_PIN), ISRWrapper, onAttrSet, onAttrSetComplete, &Serial, arduinoSPI);

  • aflib = iafLib::create(digitalPinToInterrupt(INT_PIN), ISRWrapper, attrSetHandler, attrNotifyHandler, &Serial, arduinoSPI); `

handler changes:

// This is called when the service changes one of our attributes. -void onAttrSet(const uint8_t requestId, const uint16_t attributeId, const uint16_t valueLen, const uint8_t *value) +bool attrSetHandler(const uint8_t requestId, const uint16_t attributeId, const uint16_t valueLen, const uint8_t *value)

Also, in attrSetHandler return “true” to let the service know you were able to process the changed value, or, if for some reason you can’t process the change, return “false” to let the service know the value didn’t change. (Returning “false” here is expected to be an extremely rare case.)

// This is called when either an Afero attribute has been changed via setAttribute or in response // to a getAttribute call. -void onAttrSetComplete(const uint8_t requestId, const uint16_t attributeId, const uint16_t valueLen, const uint8_t *value) +void attrNotifyHandler(const uint8_t requestId, const uint16_t attributeId, const uint16_t valueLen, const uint8_t *value)

As always, please let us know if you have any questions or feedback!

Happy developing!