Hello everybody,
I am creating a custom protocol to share data over I2C bus. It is still a work in progress, but I am hoping to be able to complete it soon. I need that protocol, for a project of mine, which will allow me to better communicate between several Arduinos (uno, mega… etc.). I have made some tests, have written some code and voala - it is far from perfect, and surely needs a lot of improvement, but it works.
Recently, I decided to export that protocol and create it in a separate library called DataFrame, in order to be able to use this piece of code in other projects, and this is where my problems began…
The problem, that I am currently facing, is in the class constructor. Here is the relevant code:
/*
Library for using data protocol over I2C bus
Created by Atanas Hristov
*/
#include "DataFrame.h"
#include "Arduino.h"
#include "Wire.h"
DataFrame::DataFrame(uint8_t devAddress){
Wire.begin(devAddress);
Wire.onReceive(receiveDataPacket); //Attach interrupt for receive
Wire.onRequest(respondToMaster); //Attach interrupt for request
setDefaultCommand(); //Used to set default data to private variables
} //End of default class constructor DataFrame();
The problem is located in those two lines:
Wire.onReceive(receiveDataPacket); //Attach interrupt for receive
Wire.onRequest(respondToMaster); //Attach interrupt for request
Both functions receiveDataPacket and respondToMaster are member functions of the class DataFrame. I have tried some variations, but for some reason this is not working and it is still beyond my knowledge.
I am also attaching the whole library, if you think that would help as well.
If you need me to clarify something, or to provide further information, don’t hesitate to ask
I would appreciate any help making this work.
Thank you in advance!
DataFrame.zip (2.25 KB)