/OTH

OpenTherm HAT for RPi

Primary LanguageC

features

todo

  • PA9 add devider 3.3/(3.3+1)

  • make openterm lib

  • make coverstion with RPi

  • make battery control

  • f8.8 covert to float

  • parity calc

  • UNION usage for UART STM-RPi Protocol

  • separate power for sim800l module

  • HUART1 àùê SIM800L use DMA for TX

electronics issue

  • make R4 700 Ohm

  • STM UART3 - RPi UART0

  • PA8 Output

  • PA15 Input

  • Vin to SIM800L Vcc (4V)

  • strhex to ascii

    const char* st = "00370037002E0030003200200440002E000A041E0431044904300439044204350441044C0020044100200434044004430433043E043C0020043F043E00200053004D00530020043104350441043F043B04";
            int length = strlen(st);
            int i;
            char buf = 0;
            for(i = 0; i < length; i++){
                    if(i % 2 != 0){
                            printf("%c", hex_to_ascii(buf, st[i]));
                    }else{
                            buf = st[i];
                    }
            }
    char buffer[RPI_RX_BUFFER_SIZE] = {20,0,3,0,23,1,1,1,3,0,0};

    char RX[5];
    for(int i=0;i<RPI_RX_BUFFER_SIZE;i++){
        char CRC=0;
        for(int j=0;j<4;j++)
            CRC = CRC + buffer[((i+j)>RPI_RX_BUFFER_SIZE-1)?(i+j-RPI_RX_BUFFER_SIZE):(i+j)];
        if(CRC==buffer[((i+4)>RPI_RX_BUFFER_SIZE-1)?(i+4-RPI_RX_BUFFER_SIZE):(i+4)] && buffer[i]!=0){
            printf("start%d\n",i);
            for(int k=0;k<5;k++){
                RX[k]=buffer[((i+k)>RPI_RX_BUFFER_SIZE-1)?(i+k-RPI_RX_BUFFER_SIZE):(i+k)];
                buffer[((i+k)>RPI_RX_BUFFER_SIZE-1)?(i+k-RPI_RX_BUFFER_SIZE):(i+k)] = 0;
            }
            if(RX[0]==20){
                printf("multiple buffer\n");
                char CRC2=0;
                for(int m=0;m<RX[2];m++){
                    CRC2 += buffer[((i+5+m)>RPI_RX_BUFFER_SIZE-1)?(i+5+m-RPI_RX_BUFFER_SIZE):(i+5+m)];
                    printf("%d:",buffer[((i+5+m)>RPI_RX_BUFFER_SIZE-1)?(i+5+m-RPI_RX_BUFFER_SIZE):(i+5+m)]);
                //
                }
                printf("\nCRC%d\n",CRC2==buffer[((i+5+RX[2])>RPI_RX_BUFFER_SIZE-1)?(i+5+RX[2]-RPI_RX_BUFFER_SIZE):(i+5+RX[2])]);
            }
      
char* buff =
		"AT+CUSD=1,\"*102#\"\r\r\nOK\r\n\r\n+CUSD: 0, \"00370037002E0030003200200440002E000A041E0431044904300439044204350441044C0020044100200434044004430433043E043C0020043F043E00200053004D00530020043104350441043F043B04";

int fff = strpos(buff, "hello", 0);
printf("%d\n\n", fff );

printf("%d\n\n", strlen(buff) );
char* found = strstr(buff, "+CUSD: ");
//printf(  found+7 );

found = strstr(found + 7, "\"");
//printf(  found+1 );

//printf("\n\n");
char* str2 = found + 1;
int length = strpos(str2, "00200440", 0);		//strlen(str2);
printf( "len=%d\n\n", length );
char* buffer = "";
int i;
char buf = 0;
for (i = 0; i < length; i++) {
	if (i % 2 != 0) {
		printf("%c", hex_to_ascii(buf, str2[i]));
		//str2[i/2] = hex_to_ascii(buf, str2[i]);
		size_t len = strlen(buffer);
		char* str3 = (char*) malloc(len + 1+1);
		strcpy(str3, buffer);
		str3[len] = (char) hex_to_ascii(buf, str2[i]);
		str3[len+1] = 0;
		buffer = str3;
		//gprs.at[gprs.subaddress].args = str2;
	} else {
		buf = str2[i];
	}
}
printf("\n\n");
printf("%f", atof(buffer));

EEPROM MAP

RPi bluetooth issue for Wi-Fi login password enter