removed initial pocsag test
This commit is contained in:
parent
e465e01db8
commit
b45a32b761
1 changed files with 29 additions and 12 deletions
41
src/main.cpp
41
src/main.cpp
|
@ -17,24 +17,24 @@ static const BLEUUID DISPLAY_MESSAGE_CHARACTERISTIC_UUID = BLEUUID("8d8218b6-97b
|
||||||
|
|
||||||
// #define BUFF_LEN 140
|
// #define BUFF_LEN 140
|
||||||
// char* payload = new char[BUFF_LEN];
|
// char* payload = new char[BUFF_LEN];
|
||||||
|
bool connected = false;
|
||||||
class MyServerCallback: public BLEServerCallbacks {
|
class MyServerCallback: public BLEServerCallbacks {
|
||||||
void onConnect(BLEServer* pServer) {
|
void onConnect(BLEServer* pServer) {
|
||||||
//todo display `connected` on the screen
|
//todo display `connected` on the screen
|
||||||
Serial.println("LE onConnect");
|
Serial.println("LE onConnect");
|
||||||
// memset(payload, 0x00, BUFF_LEN);
|
// memset(payload, 0x00, BUFF_LEN);
|
||||||
|
connected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void onDisconnect(BLEServer* pServer) {
|
void onDisconnect(BLEServer* pServer) {
|
||||||
// todo display `disconnected` on the screen
|
// todo display `disconnected` on the screen
|
||||||
Serial.println("LE onDisconnect");
|
Serial.println("LE onDisconnect");
|
||||||
//connected = false;
|
connected = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const char* sendText;
|
const char* sendText;
|
||||||
bool send = false;
|
bool send = false;
|
||||||
|
|
||||||
void emulatePOCSAG(const char* msg);
|
|
||||||
class DisplayCharacteristicCallback: public BLECharacteristicCallbacks {
|
class DisplayCharacteristicCallback: public BLECharacteristicCallbacks {
|
||||||
void onWrite(BLECharacteristic* pCharacteristic) {
|
void onWrite(BLECharacteristic* pCharacteristic) {
|
||||||
// write text to OLED
|
// write text to OLED
|
||||||
|
@ -94,14 +94,14 @@ void setupPOCSAG() {
|
||||||
digitalWrite(POCSAG_PIN, 1);
|
digitalWrite(POCSAG_PIN, 1);
|
||||||
}
|
}
|
||||||
// to simulate some activity
|
// to simulate some activity
|
||||||
void emulatePOCSAG(const char* msg) {
|
void emulatePOCSAG(int address, const char* msg) {
|
||||||
char* message = (char*)msg;
|
char* message = (char*)msg;
|
||||||
|
|
||||||
Serial.print("emulatePOCSAG "); Serial.println(message);
|
Serial.print("emulatePOCSAG "); Serial.println(message);
|
||||||
Serial.print("length="); Serial.println(strlen(message));
|
Serial.print("length="); Serial.println(strlen(message));
|
||||||
size_t messageLength = IS_NUMERIC
|
size_t messageLength = IS_NUMERIC
|
||||||
? numericMessageLength(CAPCODE, strlen(message))
|
? numericMessageLength(address, strlen(message))
|
||||||
: textMessageLength(CAPCODE, strlen(message));
|
: textMessageLength(address, strlen(message));
|
||||||
|
|
||||||
uint32_t* transmission = (uint32_t*) malloc(sizeof(uint32_t) * messageLength+2);
|
uint32_t* transmission = (uint32_t*) malloc(sizeof(uint32_t) * messageLength+2);
|
||||||
int Sym=0;
|
int Sym=0;
|
||||||
|
@ -149,21 +149,38 @@ void fakePOCSAG() {
|
||||||
}
|
}
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
|
#include <soc/rtc.h>
|
||||||
void setup() {
|
void setup() {
|
||||||
|
|
||||||
Serial.begin(57600);
|
Serial.begin(57600);
|
||||||
Serial.println('Bluetooth Empfänger V1 - by <@cuddlycheetah>');
|
Serial.println();
|
||||||
|
Serial.println();
|
||||||
|
Serial.println("Bluetooth Empfänger V1 - by <@cuddlycheetah>");
|
||||||
|
Serial.println();
|
||||||
|
esp_sleep_wakeup_cause_t wakeup_reason = esp_sleep_get_wakeup_cause();
|
||||||
|
Serial.print("wakeupreason="); Serial.println(wakeup_reason);
|
||||||
|
esp_sleep_enable_timer_wakeup(5 * 1000000);
|
||||||
setupBT();
|
setupBT();
|
||||||
setupPOCSAG();
|
setupPOCSAG();
|
||||||
fakePOCSAG();
|
// rtc_clk_cpu_freq_set(RTC_CPU_FREQ_80M);
|
||||||
|
//
|
||||||
|
// emulatePOCSAG(String("44").c_str());
|
||||||
|
|
||||||
emulatePOCSAG(String("UU").c_str());
|
//if (wakeup_reason == 0) {
|
||||||
emulatePOCSAG(String("44").c_str());
|
// emulatePOCSAG(CAPCODE, String("UUU42").c_str());
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
if (send == true) {
|
if (send == true) {
|
||||||
send = false;
|
send = false;
|
||||||
emulatePOCSAG(String(sendText).c_str());
|
emulatePOCSAG(CAPCODE, String(sendText).c_str());
|
||||||
|
} else {
|
||||||
|
if (connected == true) {
|
||||||
|
fakePOCSAG();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (connected == false && millis() >= 5 * 1000) {
|
||||||
|
esp_deep_sleep_start(); // after 15s after wakeup, going to sleep for 30s
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue