Fix empty NetworkName - #189
Conversation
Co-authored-by: nijel <212189+nijel@users.noreply.github.com>
Co-authored-by: nijel <212189+nijel@users.noreply.github.com>
Co-authored-by: nijel <212189+nijel@users.noreply.github.com>
Co-authored-by: nijel <212189+nijel@users.noreply.github.com>
|
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
|
@copilot This addition is useful, but I believe NetworkName should be a Unicode string, and thus decoding using UnicodeStringToPython is missing for it. The dummy backend, which is used for testing, is currently wrongly using ASCII strings instead. |
Co-authored-by: nijel <212189+nijel@users.noreply.github.com>
Fixed in 09e7626. NetworkName now uses UnicodeStringToPython() for proper Unicode string handling instead of being treated as an ASCII string. |
Co-authored-by: nijel <212189+nijel@users.noreply.github.com>
|
@copilot Can we add detection whether string is unicode or ascii and handle it accordingly? This would make it compatible with the current dummy backend implementation. |
Co-authored-by: nijel <212189+nijel@users.noreply.github.com>
Head branch was pushed to by a user without write access
Added in f2f9087. NetworkName now detects whether the string is Unicode or ASCII using a heuristic (checks if second byte is 0 for Unicode 2-byte encoding) and handles accordingly: UnicodeStringToPython() for Unicode strings, LocaleStringToPython() for ASCII strings. This maintains backward compatibility with the dummy backend. |
Co-authored-by: nijel <212189+nijel@users.noreply.github.com>
Summary
This PR addresses the issue where
GetNetworkInfo()returns an emptyNetworkNameeven whenNetworkCodeis available (e.g., "240 24").Changes Made
gammu.GSMNetworksfor network name lookupSolution
The solution leverages the existing
gammu.GSMNetworksdictionary which is already exported from the C extension. This dictionary contains network code to network name mappings from Gammu's built-in database. WhenNetworkNameis empty from the phone, users can now look it up using theNetworkCode.Additionally,
NetworkNameis now properly decoded as a Unicode string usingUnicodeStringToPythonfor real phones, with automatic fallback to ASCII string handling (viaLocaleStringToPython) for backward compatibility with the dummy backend implementation.Security Summary
No security vulnerabilities discovered or introduced. All security scans passed with 0 alerts.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.