Library Conflict
i have been trying combine rf , ethernet in project while now, , keep encounter multiple problems.
my setup be:
2 arduinos, talking each other via nrf24l01.
in main arduino, have enc28j60 connecting router , communicate (listen , post data) web service.
also, try hash data too.
libraries:
the libraries have been using
https://github.com/maniacbug/rf24
https://github.com/maniacbug/cryptosuite/tree/master/sha
https://github.com/ntruchsess/arduino_uip
thanks owner.
milestone:
- have got rf talking each other fine.
- in separate test, got ethernet file compiled 31k bytes close limit, , not mentioning rf code. go 40k-ish when combine them.
- using ethernet shield alone, works fine, include sha.h sketch, ethernet.begin() stops or not getting ip or stuck in loop somewhere. don't know how fix this.
questions:
- (potential problem me) how set both rf , ethernet in listening mode @ time? isn't spi cs can set low 1 @ time?
- if code on 40k bytes, can still use uno or have other avenue (like mega) or keep using uno if insist?
- can point me right direction on how solve library conflict?
suggestions , solutions appreciated. below code use ethernet test:
note commented out sha part work. sketch break put #include <sha.h> in.
please advise.
my setup be:
2 arduinos, talking each other via nrf24l01.
in main arduino, have enc28j60 connecting router , communicate (listen , post data) web service.
also, try hash data too.
libraries:
the libraries have been using
https://github.com/maniacbug/rf24
https://github.com/maniacbug/cryptosuite/tree/master/sha
https://github.com/ntruchsess/arduino_uip
thanks owner.
milestone:
- have got rf talking each other fine.
- in separate test, got ethernet file compiled 31k bytes close limit, , not mentioning rf code. go 40k-ish when combine them.
- using ethernet shield alone, works fine, include sha.h sketch, ethernet.begin() stops or not getting ip or stuck in loop somewhere. don't know how fix this.
questions:
- (potential problem me) how set both rf , ethernet in listening mode @ time? isn't spi cs can set low 1 @ time?
- if code on 40k bytes, can still use uno or have other avenue (like mega) or keep using uno if insist?
- can point me right direction on how solve library conflict?
suggestions , solutions appreciated. below code use ethernet test:
code: [select]
#include <uipethernet.h> // used ethernet
#include <sha256.h>
// **** ethernet setting ****
byte mac[] = {
0x54, 0x34, 0x41, 0x30, 0x30, 0x31};
ipaddress ip(10,0,0,90);
ipaddress gateway(10,0,0,138);
ipaddress subnet(255, 255, 255, 0);
ethernetserver server(1701);
char *webservice = "https://dkduino-c9-dkosasih.c9.io";
// ==================================
// **** ecryption stuff ****//
string charhashed="";
uint8_t hmackey1[]={
0x61,0x61,0x61,0x61,0x61,0x61,0x61,0x61,0x61,0x61,0x61,0x61,0x61,0x61,0x61,0x61,0x61,0x61,0x61,0x61
};
char *key="aaaaaaaaaaaaaaaaaaaa";
// ===========================
void setup() {
serial.begin(9600);
// start ethernet connection , server:
ethernet.begin(mac);
// if( ethernet.begin(mac)==0){
// serial.println("dhcp failed");
// }
server.begin();
serial.print("ip address: ");
serial.println(ethernet.localip());
}
void loop() {
byte inchar;
ethernet.maintain();
ethernetclient client;
// inchar = serial.read();
//
// if(inchar == 'e')
// {
// if (client.connect(webservice,80)) {
// sha256.inithmac((uint8_t*)key,20);
// sha256.print("dkosasih");
// printhash(sha256.resulthmac());
// sendpostheader(client);
// serial.println(f("message sent"));
// }else{
// serial.println(f("message failed"));
// }
// }
// listen incoming clients
client = server.available();
string allchar = "";
if (client)
{
serial.println("-> new connection");
// http request ends blank line
boolean currentlineisblank = true;
int tcount = 0;
char tbuf[100];
int r,t;
char *pch;
while (client.connected())
{
if (client.available())
{
char c = client.read();
// if you've gotten end of line (received newline
// character) , line blank, http request has ended,
// can send reply
allchar.concat(c);
if (c == '\n' && currentlineisblank)
{
// retrieve post data
serial.print("post data: ");
while(client.available()) {
c = client.read();
// use buffer size limit here.
if(tcount < 63)
{
tbuf[tcount] = c;
tcount++;
tbuf[tcount] = 0;
}
}
serial.println();
pch = strtok(tbuf,"&");
while(pch != null)
{
if(strncmp(pch,"pind8=",7) == 0)
{
t = atoi(pch+6);
serial.print("strmsg=");
char test[50]="";
int x = 0;
(int = 7 ; < strlen(pch);i++){
test[x]=pch[i];
x++;
}
test[x]='\0';
serial.print(test);
}
pch = strtok(null,"&");
}
//serial.println("trying write");
client.println("<html><title>hello world!</title><body><h3>hello world!</h3></body>");
break;
}
if (c == '\n') {
// you're starting new line
serial.println("current line blank");
currentlineisblank = true;
}
else if (c != '\r')
{
// you've gotten character on current line
//serial.println("current line not blank");
currentlineisblank = false;
}
}
if (!client.connected()){
client.stop();
for(;;){
ethernet.maintain();
}
}
}
serial.println(allchar);
// give web browser time receive data
delay(10);
// close connection:
client.stop();
serial.println(" disconnected\n");
}
}
note commented out sha part work. sketch break put #include <sha.h> in.
please advise.
i suspect running out of ram. try new ethernet shield offloads tcp/ip stack wiznet chip. enc28j60 ethernet entire tcp/ip stack has implemented on arduino.
Arduino Forum > Development > Other Software Development > Library Conflict
arduino
Comments
Post a Comment